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);
}
Aggregations