Search in sources :

Example 26 with Member

use of ast.ExpCore.ClassB.Member in project L42 by ElvisResearchGroup.

the class ErrorFormatter method printType.

private static void printType(int i, String prefix, ClassB top) {
    System.out.print("This" + i + prefix + " :{\n");
    printMembers(top);
    System.out.print("  }\n");
    for (Member m : top.getMs()) {
        if (!(m instanceof NestedClass)) {
            continue;
        }
        NestedClass nc = (NestedClass) m;
        if (nc.getInner() instanceof ClassB) {
            printType(i, "." + nc.getName(), (ClassB) nc.getInner());
        }
    }
}
Also used : NestedClass(ast.ExpCore.ClassB.NestedClass) Member(ast.ExpCore.ClassB.Member) ClassB(ast.ExpCore.ClassB)

Example 27 with Member

use of ast.ExpCore.ClassB.Member in project L42 by ElvisResearchGroup.

the class ErrorFormatter method displayAbstractMethods.

//TODO: what was this for
@SuppressWarnings("unused")
private static void displayAbstractMethods(ClassB cb, StringBuilder result, String nesting) {
    result.append("{\n");
    for (Member m : cb.getMs()) {
        m.match(nc -> {
            if (!(nc.getInner() instanceof ClassB)) {
                return null;
            }
            if (((ClassB) nc.getInner()).isInterface()) {
                return null;
            }
            StringBuilder inner = new StringBuilder();
            displayAbstractMethods((ClassB) nc.getInner(), inner, nesting + "  ");
            String innerStr = inner.toString();
            if (!innerStr.contains("method")) {
                return null;
            }
            result.append(nesting);
            result.append(nc.getName());
            result.append(":");
            result.append(innerStr);
            return null;
        }, mi -> {
            return null;
        }, mt -> {
            if (mt.get_inner().isPresent()) {
                return null;
            }
            if (mt.getMt().getMdf() == Mdf.Class) {
                return null;
            }
            result.append(nesting);
            result.append(ToFormattedText.of(mt).replace("\n", "\n" + nesting));
            result.append("\n");
            return null;
        });
    }
    result.append("}\n");
}
Also used : Member(ast.ExpCore.ClassB.Member) ClassB(ast.ExpCore.ClassB)

Example 28 with Member

use of ast.ExpCore.ClassB.Member in project L42 by ElvisResearchGroup.

the class ErrorFormatter method printMembers.

private static void printMembers(ClassB top) {
    for (Member m : top.getMs()) {
        if (!(m instanceof MethodWithType)) {
            continue;
        }
        MethodWithType mwt = (MethodWithType) m;
        mwt = mwt.withDoc(Doc.empty());
        mwt = mwt.with_inner(Optional.empty());
        String txt = sugarVisitors.ToFormattedText.of(mwt);
        txt = txt.replace("{", "");
        txt = txt.replace("}", "");
        txt = txt.replace("\n", " ");
        System.out.print("  " + txt + "\n");
    /*      System.out.print("  "+mwt.getMt().getReturnType());
      System.out.print(" "+mwt.getMs().getName());
      System.out.print("(");
      {int i=-1;for(String n:mwt.getMs().getNames()){i+=1;
      System.out.print(mwt.getMt().getTs()
      }}
      System.out.print(")\n");
  */
    }
}
Also used : MethodWithType(ast.ExpCore.ClassB.MethodWithType) Member(ast.ExpCore.ClassB.Member)

Example 29 with Member

use of ast.ExpCore.ClassB.Member in project L42 by ElvisResearchGroup.

the class RemoveMethod method liftMembers.

public List<Member> liftMembers(List<Member> s) {
    if (!path.isEmpty()) {
        return Map.of(this::liftM, s);
    }
    List<Member> result = new ArrayList<>(s);
    Optional<Member> mOpt = Functions.getIfInDom(s, ms);
    if (mOpt.isPresent()) {
        Member m = mOpt.get();
        result.remove(m);
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) Member(ast.ExpCore.ClassB.Member)

Example 30 with Member

use of ast.ExpCore.ClassB.Member in project L42 by ElvisResearchGroup.

the class FindPathUsage method ctxPos.

private Ast.Position ctxPos() {
    Ast.Position pos = p.top().getP();
    if (getLastCMs() != null) {
        if (getLastCMs() instanceof Ast.C) {
            List<Ast.C> cs = Collections.singletonList((Ast.C) getLastCMs());
            pos = p.top().getNested(cs).getP();
        }
        if (getLastCMs() instanceof Ast.MethodSelector) {
            Member m = p.top()._getMember((Ast.MethodSelector) getLastCMs());
            assert m != null;
            pos = m.getP();
        }
    }
    return pos;
}
Also used : Ast(ast.Ast) Member(ast.ExpCore.ClassB.Member)

Aggregations

Member (ast.ExpCore.ClassB.Member)54 ArrayList (java.util.ArrayList)32 ClassB (ast.ExpCore.ClassB)21 MethodWithType (ast.ExpCore.ClassB.MethodWithType)21 NestedClass (ast.ExpCore.ClassB.NestedClass)20 Ast (ast.Ast)14 ExpCore (ast.ExpCore)11 Path (ast.Ast.Path)10 List (java.util.List)7 Doc (ast.Ast.Doc)5 MethodSelector (ast.Ast.MethodSelector)5 MethodType (ast.Ast.MethodType)5 Collections (java.util.Collections)5 C (ast.Ast.C)4 MethodImplemented (ast.ExpCore.ClassB.MethodImplemented)4 Phase (ast.ExpCore.ClassB.Phase)4 HashSet (java.util.HashSet)4 Optional (java.util.Optional)4 Assertions (tools.Assertions)4 Position (ast.Ast.Position)3