use of platformSpecific.fakeInternet.PluginWithPart.UsingInfo 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 platformSpecific.fakeInternet.PluginWithPart.UsingInfo 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 platformSpecific.fakeInternet.PluginWithPart.UsingInfo 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