use of ast.ExpCore.ClassB.Member in project L42 by ElvisResearchGroup.
the class TestHelper method reportError.
public static void reportError(ErrorMessage e) {
if (Executor.last1 == null || Executor.last2 == null) {
throw e;
}
ClassB c1 = (ClassB) Executor.last1;
ClassB c2 = (ClassB) Executor.last2;
ArrayList<Member> ms1 = new ArrayList<>();
ArrayList<Member> ms2 = new ArrayList<>();
{
int i = -1;
for (Member e1 : c1.getMs()) {
i += 1;
Member e2 = c2.getMs().get(i);
if (e1.equals(e2)) {
continue;
}
ms1.add(e1);
ms2.add(e2);
}
}
c1 = c1.withMs(ms1);
c2 = c2.withMs(ms2);
//TestHelper.assertEqualExp(c1, c2);
}
use of ast.ExpCore.ClassB.Member in project L42 by ElvisResearchGroup.
the class Rename method renameMethod.
public static ClassB renameMethod(Program p, ClassB cb, List<Ast.C> path, MethodSelector src, MethodSelector dest) {
Member mem = Errors42.checkExistsPathMethod(cb, path, Optional.of(src));
assert mem instanceof MethodWithType;
Errors42.checkCompatibleMs(path, (MethodWithType) mem, dest);
CollectedLocatorsMap maps = CollectedLocatorsMap.from(Path.outer(0, path), (MethodWithType) mem, dest);
RenameAlsoDefinition ren = new RenameAlsoDefinition(cb, maps, p);
return (ClassB) ren.visit(cb);
}
use of ast.ExpCore.ClassB.Member in project L42 by ElvisResearchGroup.
the class SumMethods method sumMethods.
public static ClassB sumMethods(ClassB lib, List<Ast.C> path, MethodSelector m1, MethodSelector m2, MethodSelector mRes, String name) {
ClassB pathCb = pathCb(lib, path);
Member mem1 = Errors42.checkExistsPathMethod(lib, path, Optional.of(m1));
Member mem2 = Errors42.checkExistsPathMethod(lib, path, Optional.of(m2));
MethodType mt1 = ((MethodWithType) pathCb._getMember(m1)).getMt();
MethodType mt2 = ((MethodWithType) pathCb._getMember(m2)).getMt();
int index = m2.getNames().indexOf(name);
if (index == -1) {
throw Errors42.errorParameterMismatch(path, mem1, mem2, false, false, false);
}
checkParSize(index, path, m1, m2, mRes, mem1, mem2, mt1, mt2);
MethodType mtU = mtU(index, mt1, mt2);
if (mtU == null) {
throw Errors42.errorParameterMismatch(path, mem1, mem2, isReplacedParOk(index, mt1, mt2), false, true);
}
ExpCore eU = eU(index, mem2.getP(), mt1, mt2, m1, m2, mRes);
MethodWithType mwtU = new MethodWithType(Doc.empty(), mRes, mtU, Optional.of(eU), mem2.getP());
checkConflict(path, mRes, pathCb, mwtU);
boolean replOk = isReplacedParOk(index, mt1, mt2);
if (!replOk) {
throw Errors42.errorParameterMismatch(path, mem1, mem2, false, true, true);
}
return finalResult(lib, path, mwtU);
}
use of ast.ExpCore.ClassB.Member 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 ast.ExpCore.ClassB.Member in project L42 by ElvisResearchGroup.
the class TranslateClass method extractConstructors.
private static List<MethodWithType> extractConstructors(ClassB ct) {
List<MethodWithType> result = new ArrayList<>();
for (Member m : ct.getMs()) {
assert m instanceof MethodWithType;
MethodWithType mt = (MethodWithType) m;
if (mt.get_inner().isPresent()) {
continue;
}
if (mt.getMt().getMdf() != Ast.Mdf.Class) {
continue;
}
result.add(mt);
}
return result;
}
Aggregations