Search in sources :

Example 1 with LocalRecordDeclarationStmt

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());
}
Also used : LocalRecordDeclarationStmt(com.github.javaparser.ast.stmt.LocalRecordDeclarationStmt)

Example 2 with LocalRecordDeclarationStmt

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;
}
Also used : RecordDeclaration(com.github.javaparser.ast.body.RecordDeclaration) LocalClassDeclarationStmt(com.github.javaparser.ast.stmt.LocalClassDeclarationStmt) EnumConstantDeclaration(com.github.javaparser.ast.body.EnumConstantDeclaration) ClassOrInterfaceDeclaration(com.github.javaparser.ast.body.ClassOrInterfaceDeclaration) AnnotationDeclaration(com.github.javaparser.ast.body.AnnotationDeclaration) CompoundAssignmentTree(com.sun.source.tree.CompoundAssignmentTree) LiteralTree(com.sun.source.tree.LiteralTree) ExportsTree(com.sun.source.tree.ExportsTree) MethodInvocationTree(com.sun.source.tree.MethodInvocationTree) AssignmentTree(com.sun.source.tree.AssignmentTree) TypeCastTree(com.sun.source.tree.TypeCastTree) LambdaExpressionTree(com.sun.source.tree.LambdaExpressionTree) ForLoopTree(com.sun.source.tree.ForLoopTree) InstanceOfTree(com.sun.source.tree.InstanceOfTree) ModuleTree(com.sun.source.tree.ModuleTree) ParenthesizedTree(com.sun.source.tree.ParenthesizedTree) ConditionalExpressionTree(com.sun.source.tree.ConditionalExpressionTree) OpensTree(com.sun.source.tree.OpensTree) MemberSelectTree(com.sun.source.tree.MemberSelectTree) ExpressionStatementTree(com.sun.source.tree.ExpressionStatementTree) ThrowTree(com.sun.source.tree.ThrowTree) BlockTree(com.sun.source.tree.BlockTree) EnhancedForLoopTree(com.sun.source.tree.EnhancedForLoopTree) ReturnTree(com.sun.source.tree.ReturnTree) ArrayTypeTree(com.sun.source.tree.ArrayTypeTree) LabeledStatementTree(com.sun.source.tree.LabeledStatementTree) UnaryTree(com.sun.source.tree.UnaryTree) VariableTree(com.sun.source.tree.VariableTree) TypeParameterTree(com.sun.source.tree.TypeParameterTree) NewClassTree(com.sun.source.tree.NewClassTree) ParameterizedTypeTree(com.sun.source.tree.ParameterizedTypeTree) BreakTree(com.sun.source.tree.BreakTree) ImportTree(com.sun.source.tree.ImportTree) Tree(com.sun.source.tree.Tree) ExpressionTree(com.sun.source.tree.ExpressionTree) IntersectionTypeTree(com.sun.source.tree.IntersectionTypeTree) WildcardTree(com.sun.source.tree.WildcardTree) RequiresTree(com.sun.source.tree.RequiresTree) UnionTypeTree(com.sun.source.tree.UnionTypeTree) ArrayAccessTree(com.sun.source.tree.ArrayAccessTree) AnnotatedTypeTree(com.sun.source.tree.AnnotatedTypeTree) PackageTree(com.sun.source.tree.PackageTree) IdentifierTree(com.sun.source.tree.IdentifierTree) CatchTree(com.sun.source.tree.CatchTree) NewArrayTree(com.sun.source.tree.NewArrayTree) ContinueTree(com.sun.source.tree.ContinueTree) UsesTree(com.sun.source.tree.UsesTree) CaseTree(com.sun.source.tree.CaseTree) CompilationUnitTree(com.sun.source.tree.CompilationUnitTree) SwitchTree(com.sun.source.tree.SwitchTree) PrimitiveTypeTree(com.sun.source.tree.PrimitiveTypeTree) SynchronizedTree(com.sun.source.tree.SynchronizedTree) AssertTree(com.sun.source.tree.AssertTree) StatementTree(com.sun.source.tree.StatementTree) ModifiersTree(com.sun.source.tree.ModifiersTree) WhileLoopTree(com.sun.source.tree.WhileLoopTree) AnnotationTree(com.sun.source.tree.AnnotationTree) MethodTree(com.sun.source.tree.MethodTree) BinaryTree(com.sun.source.tree.BinaryTree) EmptyStatementTree(com.sun.source.tree.EmptyStatementTree) ClassTree(com.sun.source.tree.ClassTree) IfTree(com.sun.source.tree.IfTree) ProvidesTree(com.sun.source.tree.ProvidesTree) MemberReferenceTree(com.sun.source.tree.MemberReferenceTree) ErroneousTree(com.sun.source.tree.ErroneousTree) DoWhileLoopTree(com.sun.source.tree.DoWhileLoopTree) TryTree(com.sun.source.tree.TryTree) ArrayList(java.util.ArrayList) List(java.util.List) LocalRecordDeclarationStmt(com.github.javaparser.ast.stmt.LocalRecordDeclarationStmt) EnumDeclaration(com.github.javaparser.ast.body.EnumDeclaration)

Aggregations

LocalRecordDeclarationStmt (com.github.javaparser.ast.stmt.LocalRecordDeclarationStmt)2 AnnotationDeclaration (com.github.javaparser.ast.body.AnnotationDeclaration)1 ClassOrInterfaceDeclaration (com.github.javaparser.ast.body.ClassOrInterfaceDeclaration)1 EnumConstantDeclaration (com.github.javaparser.ast.body.EnumConstantDeclaration)1 EnumDeclaration (com.github.javaparser.ast.body.EnumDeclaration)1 RecordDeclaration (com.github.javaparser.ast.body.RecordDeclaration)1 LocalClassDeclarationStmt (com.github.javaparser.ast.stmt.LocalClassDeclarationStmt)1 AnnotatedTypeTree (com.sun.source.tree.AnnotatedTypeTree)1 AnnotationTree (com.sun.source.tree.AnnotationTree)1 ArrayAccessTree (com.sun.source.tree.ArrayAccessTree)1 ArrayTypeTree (com.sun.source.tree.ArrayTypeTree)1 AssertTree (com.sun.source.tree.AssertTree)1 AssignmentTree (com.sun.source.tree.AssignmentTree)1 BinaryTree (com.sun.source.tree.BinaryTree)1 BlockTree (com.sun.source.tree.BlockTree)1 BreakTree (com.sun.source.tree.BreakTree)1 CaseTree (com.sun.source.tree.CaseTree)1 CatchTree (com.sun.source.tree.CatchTree)1 ClassTree (com.sun.source.tree.ClassTree)1 CompilationUnitTree (com.sun.source.tree.CompilationUnitTree)1