Search in sources :

Example 1 with CompilationUnitTreeImpl

use of org.sonar.java.model.JavaTree.CompilationUnitTreeImpl in project sonar-java by SonarSource.

the class TreeFactory method newCompilationUnit.

// End of literals
// Compilation unit
public CompilationUnitTreeImpl newCompilationUnit(JavaTree spacing, Optional<PackageDeclarationTree> packageDeclaration, Optional<List<ImportClauseTree>> importDeclarations, Optional<ModuleDeclarationTree> moduleDeclaration, Optional<List<Tree>> typeDeclarations, InternalSyntaxToken eof) {
    ImmutableList.Builder<ImportClauseTree> imports = ImmutableList.builder();
    if (importDeclarations.isPresent()) {
        for (ImportClauseTree child : importDeclarations.get()) {
            imports.add(child);
        }
    }
    ImmutableList.Builder<Tree> types = ImmutableList.builder();
    if (typeDeclarations.isPresent()) {
        for (Tree child : typeDeclarations.get()) {
            types.add(child);
        }
    }
    return new CompilationUnitTreeImpl(packageDeclaration.orNull(), imports.build(), types.build(), moduleDeclaration.orNull(), eof);
}
Also used : CompilationUnitTreeImpl(org.sonar.java.model.JavaTree.CompilationUnitTreeImpl) ImportClauseTree(org.sonar.plugins.java.api.tree.ImportClauseTree) ImmutableList(com.google.common.collect.ImmutableList) ImportClauseTree(org.sonar.plugins.java.api.tree.ImportClauseTree) ModuleNameTree(org.sonar.plugins.java.api.tree.ModuleNameTree) ParameterizedTypeTree(org.sonar.plugins.java.api.tree.ParameterizedTypeTree) ExpressionTree(org.sonar.plugins.java.api.tree.ExpressionTree) VariableTree(org.sonar.plugins.java.api.tree.VariableTree) ArrayDimensionTree(org.sonar.plugins.java.api.tree.ArrayDimensionTree) Tree(org.sonar.plugins.java.api.tree.Tree) ListTree(org.sonar.plugins.java.api.tree.ListTree) TypeTree(org.sonar.plugins.java.api.tree.TypeTree) JavaTree(org.sonar.java.model.JavaTree) StatementTree(org.sonar.plugins.java.api.tree.StatementTree) ModifierTree(org.sonar.plugins.java.api.tree.ModifierTree) IdentifierTree(org.sonar.plugins.java.api.tree.IdentifierTree) PackageDeclarationTree(org.sonar.plugins.java.api.tree.PackageDeclarationTree) AnnotationTree(org.sonar.plugins.java.api.tree.AnnotationTree) TypeParameterTree(org.sonar.plugins.java.api.tree.TypeParameterTree) ModuleDirectiveTree(org.sonar.plugins.java.api.tree.ModuleDirectiveTree) ModuleDeclarationTree(org.sonar.plugins.java.api.tree.ModuleDeclarationTree)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 JavaTree (org.sonar.java.model.JavaTree)1 CompilationUnitTreeImpl (org.sonar.java.model.JavaTree.CompilationUnitTreeImpl)1 AnnotationTree (org.sonar.plugins.java.api.tree.AnnotationTree)1 ArrayDimensionTree (org.sonar.plugins.java.api.tree.ArrayDimensionTree)1 ExpressionTree (org.sonar.plugins.java.api.tree.ExpressionTree)1 IdentifierTree (org.sonar.plugins.java.api.tree.IdentifierTree)1 ImportClauseTree (org.sonar.plugins.java.api.tree.ImportClauseTree)1 ListTree (org.sonar.plugins.java.api.tree.ListTree)1 ModifierTree (org.sonar.plugins.java.api.tree.ModifierTree)1 ModuleDeclarationTree (org.sonar.plugins.java.api.tree.ModuleDeclarationTree)1 ModuleDirectiveTree (org.sonar.plugins.java.api.tree.ModuleDirectiveTree)1 ModuleNameTree (org.sonar.plugins.java.api.tree.ModuleNameTree)1 PackageDeclarationTree (org.sonar.plugins.java.api.tree.PackageDeclarationTree)1 ParameterizedTypeTree (org.sonar.plugins.java.api.tree.ParameterizedTypeTree)1 StatementTree (org.sonar.plugins.java.api.tree.StatementTree)1 Tree (org.sonar.plugins.java.api.tree.Tree)1 TypeParameterTree (org.sonar.plugins.java.api.tree.TypeParameterTree)1 TypeTree (org.sonar.plugins.java.api.tree.TypeTree)1 VariableTree (org.sonar.plugins.java.api.tree.VariableTree)1