use of is.L42.connected.withSafeOperators.pluginWrapper.RefactorErrors.UnresolvedOverloading in project L42 by ElvisResearchGroup.
the class PlgWrapperGenerator method usingMethod.
private static UsingInfo usingMethod(PlgInfo plgInfo, Method[] jms, MethodWithType mwt, String name) throws UnresolvedOverloading {
List<Method> jms0 = new ArrayList<>();
for (Method mi : jms) {
if (!mi.getName().equals(name)) {
continue;
}
if (argLessPData(mi) != mwt.getMs().getNames().size()) {
continue;
}
jms0.add(mi);
}
if (jms0.size() != 1) {
throw new RefactorErrors.UnresolvedOverloading().msg("The referred java class " + plgInfo.plgClass.getName() + " does not have exactly one method for " + name + " with right number of arguments.\n" + "List of candidate methods:" + jms0);
}
assert jms0.size() == 1 : jms0.size();
Method jm = jms0.get(0);
UsingInfo ui = new UsingInfo(plgInfo, jm);
return ui;
}
use of is.L42.connected.withSafeOperators.pluginWrapper.RefactorErrors.UnresolvedOverloading in project L42 by ElvisResearchGroup.
the class PlgWrapperGenerator method plgComplete1.
public static ClassB plgComplete1(List<Ast.C> cs, Program p, ClassB l) throws UnresolvedOverloading, ClassUnfit, MethodUnfit {
PluginWithPart pwp = OnLineCode._isPluginWithPart(l.getDoc1());
if (pwp == null) {
return l;
}
PlgInfo plgInfo = new PlgInfo(l.getDoc1());
if (!hasPluginUnresponsive(l)) {
throw new RefactorErrors.ClassUnfit().msg("Class " + Path.outer(0, cs) + " does not contain method #pluginUnresponsive(binaryRepr)");
}
Class<?> c = pwp.pointed;
Method[] jms = c.getMethods();
Constructor<?>[] jcs = c.getDeclaredConstructors();
List<Member> msResult = new ArrayList<>(templateWrapper);
Path pTop = Path.outer(0, cs);
for (Member m : l.getMs()) {
if (!(m instanceof MethodWithType)) {
msResult.add(m);
continue;
}
MethodWithType mwt = (MethodWithType) m;
if (mwt.get_inner().isPresent()) {
msResult.add(mwt);
continue;
}
addMwt(p, plgInfo, jms, jcs, msResult, pTop, mwt);
}
return l.withMs(msResult);
}
use of is.L42.connected.withSafeOperators.pluginWrapper.RefactorErrors.UnresolvedOverloading in project L42 by ElvisResearchGroup.
the class PlgWrapperGenerator method usingConstructor.
private static UsingInfo usingConstructor(PlgInfo plgInfo, Constructor<?>[] jcs, MethodWithType mwt, String name) throws UnresolvedOverloading {
List<Constructor<?>> jcs0 = new ArrayList<>();
for (Constructor<?> mi : jcs) {
if (argLessPData(mi) != mwt.getMs().getNames().size()) {
continue;
}
jcs0.add(mi);
}
if (jcs0.size() != 1) {
throw new RefactorErrors.UnresolvedOverloading().msg("The referred java class " + plgInfo.plgClass.getName() + " does not have exactly one constructor with right number of arguments.\n" + "List of candidate constructors:" + jcs0);
}
assert jcs0.size() == 1 : jcs0.size();
Constructor<?> jc = jcs0.get(0);
UsingInfo ui = new UsingInfo(plgInfo, jc);
return ui;
}
use of is.L42.connected.withSafeOperators.pluginWrapper.RefactorErrors.UnresolvedOverloading in project L42 by ElvisResearchGroup.
the class PlgWrapperGenerator method addMwt.
private static void addMwt(Program p, PlgInfo plgInfo, Method[] jms, Constructor<?>[] jcs, List<Member> msResult, Path pTop, MethodWithType mwt) throws UnresolvedOverloading, ClassUnfit, MethodUnfit {
//checks
try {
isOkAsReturn(p, pTop, mwt.getMt().getReturnType());
for (Type ti : mwt.getMt().getExceptions()) {
isOkAsException(p, pTop, ti.getPath());
}
for (Type ti : mwt.getMt().getTs()) {
isOkAsParameter(p, pTop, ti);
}
//TODO: we may want to cache those tests if performance is needed
} catch (ClassUnfit | MethodUnfit e) {
e.setMessage("While examining Class " + pTop + " method " + mwt.getMs() + ":\n" + e.getMessage());
throw e;
}
//add to msResult
//TODO: add behaviour if mwt have special comment to define specific ms for use
String name = mwt.getMs().nameToS();
if (name.startsWith("#")) {
name = name.substring(1);
}
UsingInfo ui;
if (!name.equals("new") && !name.equals("apply"))
ui = usingMethod(plgInfo, jms, mwt, name);
else
ui = usingConstructor(plgInfo, jcs, mwt, name);
MethodWithType tu = updateTemplateUsing(ui, mwt);
msResult.add(tu);
}
Aggregations