use of com.github.javaparser.ast.stmt.LocalRecordDeclarationStmt in project checker-framework by typetools.
the class DoubleJavaParserVisitor method visit.
@Override
public void visit(LocalRecordDeclarationStmt node1, final Node other) {
LocalRecordDeclarationStmt node2 = (LocalRecordDeclarationStmt) other;
defaultAction(node1, node2);
node1.getRecordDeclaration().accept(this, node2.getRecordDeclaration());
}
use of com.github.javaparser.ast.stmt.LocalRecordDeclarationStmt in project checker-framework by typetools.
the class JointJavacJavaParserVisitor method visitClass.
@Override
public Void visitClass(ClassTree javacTree, Node javaParserNode) {
if (javaParserNode instanceof ClassOrInterfaceDeclaration) {
ClassOrInterfaceDeclaration node = (ClassOrInterfaceDeclaration) javaParserNode;
processClass(javacTree, node);
visitLists(javacTree.getTypeParameters(), node.getTypeParameters());
if (javacTree.getKind() == Tree.Kind.CLASS) {
if (javacTree.getExtendsClause() == null) {
assert node.getExtendedTypes().isEmpty();
} else {
assert node.getExtendedTypes().size() == 1;
javacTree.getExtendsClause().accept(this, node.getExtendedTypes().get(0));
}
visitLists(javacTree.getImplementsClause(), node.getImplementedTypes());
} else if (javacTree.getKind() == Tree.Kind.INTERFACE) {
visitLists(javacTree.getImplementsClause(), node.getExtendedTypes());
}
visitClassMembers(javacTree.getMembers(), node.getMembers());
} else if (javaParserNode instanceof RecordDeclaration) {
RecordDeclaration node = (RecordDeclaration) javaParserNode;
processClass(javacTree, node);
visitLists(javacTree.getTypeParameters(), node.getTypeParameters());
visitLists(javacTree.getImplementsClause(), node.getImplementedTypes());
List<? extends Tree> membersWithoutAutoGenerated = Lists.newArrayList(Iterables.filter(javacTree.getMembers(), (Predicate<Tree>) (Tree m) -> {
// Filter out all auto-generated items:
return !TreeUtils.isAutoGeneratedRecordMember(m);
}));
visitClassMembers(membersWithoutAutoGenerated, node.getMembers());
} else if (javaParserNode instanceof AnnotationDeclaration) {
AnnotationDeclaration node = (AnnotationDeclaration) javaParserNode;
processClass(javacTree, node);
visitClassMembers(javacTree.getMembers(), node.getMembers());
} else if (javaParserNode instanceof LocalClassDeclarationStmt) {
javacTree.accept(this, ((LocalClassDeclarationStmt) javaParserNode).getClassDeclaration());
} else if (javaParserNode instanceof LocalRecordDeclarationStmt) {
javacTree.accept(this, ((LocalRecordDeclarationStmt) javaParserNode).getRecordDeclaration());
} else if (javaParserNode instanceof EnumDeclaration) {
EnumDeclaration node = (EnumDeclaration) javaParserNode;
processClass(javacTree, node);
visitLists(javacTree.getImplementsClause(), node.getImplementedTypes());
// members, whereas JavaParser stores them as one object. Need to match them.
assert javacTree.getKind() == Tree.Kind.ENUM;
List<Tree> javacMembers = new ArrayList<>(javacTree.getMembers());
// possibly a synthetic constructor.
if (!node.getEntries().isEmpty()) {
while (!javacMembers.isEmpty() && javacMembers.get(0).getKind() != Tree.Kind.VARIABLE) {
javacMembers.remove(0);
}
}
for (EnumConstantDeclaration entry : node.getEntries()) {
assert !javacMembers.isEmpty();
javacMembers.get(0).accept(this, entry);
javacMembers.remove(0);
}
visitClassMembers(javacMembers, node.getMembers());
} else {
throwUnexpectedNodeType(javacTree, javaParserNode);
}
return null;
}
Aggregations