@Test public void createIsSuccessful_fromPackageInfo() { TestCompilation compilation = TestCompilation.compile("package-info.java", "package foo.bar;"); FeatureGraph featureGraph = FeaturePlugin.createFeatureGraph(compilation.compilationUnit(), compilation.context()); assertThat(featureGraph.astNodes()).isNotEmpty(); }
static FeatureGraph createFeatureGraph( JCTree.JCCompilationUnit compilationUnit, Context context) { FeatureGraph featureGraph = new FeatureGraph( compilationUnit.getSourceFile().getName(), compilationUnit.endPositions, compilationUnit.lineMap); AstScanner.addToGraph(compilationUnit, featureGraph); Tokens.addToGraph(compilationUnit.getSourceFile(), context, featureGraph); linkTokensToAstNodes(featureGraph); featureGraph.pruneAstNodes(); JavacProcessingEnvironment processingEnvironment = JavacProcessingEnvironment.instance(context); ImmutableMap<ClassTree, ImmutableMap<MethodTree, DataflowOutputs>> analysisResults = DataflowOutputs.create(compilationUnit, processingEnvironment); DataflowOutputsScanner.addToGraph(compilationUnit, analysisResults, featureGraph); TypeAnalysis typeAnalysis = new TypeAnalysis(compilationUnit, processingEnvironment); TypeScanner.addToGraph(compilationUnit, featureGraph, typeAnalysis); AssignabilityAnalysis.addToGraph(featureGraph, typeAnalysis); ComputedFromScanner.addToGraph(compilationUnit, featureGraph); LastLexicalUseScanner.addToGraph(compilationUnit, featureGraph); ReturnsToScanner.addToGraph(compilationUnit, featureGraph); FormalArgScanner.addToGraph(compilationUnit, featureGraph); GuardedByScanner.addToGraph(compilationUnit, featureGraph); SymbolScanner.addToGraph(compilationUnit, featureGraph); linkCommentsToAstNodes(featureGraph); checkSymbols(featureGraph); return featureGraph; }
FeaturePlugin implements Plugin { static FeatureGraph createFeatureGraph( JCTree.JCCompilationUnit compilationUnit, Context context) { FeatureGraph featureGraph = new FeatureGraph( compilationUnit.getSourceFile().getName(), compilationUnit.endPositions, compilationUnit.lineMap); AstScanner.addToGraph(compilationUnit, featureGraph); Tokens.addToGraph(compilationUnit.getSourceFile(), context, featureGraph); linkTokensToAstNodes(featureGraph); featureGraph.pruneAstNodes(); JavacProcessingEnvironment processingEnvironment = JavacProcessingEnvironment.instance(context); ImmutableMap<ClassTree, ImmutableMap<MethodTree, DataflowOutputs>> analysisResults = DataflowOutputs.create(compilationUnit, processingEnvironment); DataflowOutputsScanner.addToGraph(compilationUnit, analysisResults, featureGraph); TypeAnalysis typeAnalysis = new TypeAnalysis(compilationUnit, processingEnvironment); TypeScanner.addToGraph(compilationUnit, featureGraph, typeAnalysis); AssignabilityAnalysis.addToGraph(featureGraph, typeAnalysis); ComputedFromScanner.addToGraph(compilationUnit, featureGraph); LastLexicalUseScanner.addToGraph(compilationUnit, featureGraph); ReturnsToScanner.addToGraph(compilationUnit, featureGraph); FormalArgScanner.addToGraph(compilationUnit, featureGraph); GuardedByScanner.addToGraph(compilationUnit, featureGraph); SymbolScanner.addToGraph(compilationUnit, featureGraph); linkCommentsToAstNodes(featureGraph); checkSymbols(featureGraph); return featureGraph; } }
FeaturePlugin implements Plugin { static FeatureGraph createFeatureGraph( JCTree.JCCompilationUnit compilationUnit, Context context) { FeatureGraph featureGraph = new FeatureGraph( compilationUnit.getSourceFile().getName(), compilationUnit.endPositions, compilationUnit.lineMap); AstScanner.addToGraph(compilationUnit, featureGraph); Tokens.addToGraph(compilationUnit.getSourceFile(), context, featureGraph); linkTokensToAstNodes(featureGraph); featureGraph.pruneAstNodes(); JavacProcessingEnvironment processingEnvironment = JavacProcessingEnvironment.instance(context); ImmutableMap<ClassTree, ImmutableMap<MethodTree, DataflowOutputs>> analysisResults = DataflowOutputs.create(compilationUnit, processingEnvironment); DataflowOutputsScanner.addToGraph(compilationUnit, analysisResults, featureGraph); TypeAnalysis typeAnalysis = new TypeAnalysis(compilationUnit, processingEnvironment); TypeScanner.addToGraph(compilationUnit, featureGraph, typeAnalysis); AssignabilityAnalysis.addToGraph(featureGraph, typeAnalysis); ComputedFromScanner.addToGraph(compilationUnit, featureGraph); LastLexicalUseScanner.addToGraph(compilationUnit, featureGraph); ReturnsToScanner.addToGraph(compilationUnit, featureGraph); FormalArgScanner.addToGraph(compilationUnit, featureGraph); GuardedByScanner.addToGraph(compilationUnit, featureGraph); SymbolScanner.addToGraph(compilationUnit, featureGraph); linkCommentsToAstNodes(featureGraph); checkSymbols(featureGraph); return featureGraph; }  }
FeaturePlugin implements Plugin { static FeatureGraph createFeatureGraph( JCTree.JCCompilationUnit compilationUnit, Context context) { FeatureGraph featureGraph = new FeatureGraph( compilationUnit.getSourceFile().getName(), compilationUnit.endPositions, compilationUnit.lineMap); AstScanner.addToGraph(compilationUnit, featureGraph); Tokens.addToGraph(compilationUnit.getSourceFile(), context, featureGraph); linkTokensToAstNodes(featureGraph); featureGraph.pruneAstNodes(); JavacProcessingEnvironment processingEnvironment = JavacProcessingEnvironment.instance(context); ImmutableMap<ClassTree, ImmutableMap<MethodTree, DataflowOutputs>> analysisResults = DataflowOutputs.create(compilationUnit, processingEnvironment); DataflowOutputsScanner.addToGraph(compilationUnit, analysisResults, featureGraph); TypeAnalysis typeAnalysis = new TypeAnalysis(compilationUnit, processingEnvironment); TypeScanner.addToGraph(compilationUnit, featureGraph, typeAnalysis); AssignabilityAnalysis.addToGraph(featureGraph, typeAnalysis); ComputedFromScanner.addToGraph(compilationUnit, featureGraph); LastLexicalUseScanner.addToGraph(compilationUnit, featureGraph); ReturnsToScanner.addToGraph(compilationUnit, featureGraph); FormalArgScanner.addToGraph(compilationUnit, featureGraph); GuardedByScanner.addToGraph(compilationUnit, featureGraph); SymbolScanner.addToGraph(compilationUnit, featureGraph); linkCommentsToAstNodes(featureGraph); checkSymbols(featureGraph); return featureGraph; }  @Override String getName(); @Override void init(JavacTask task, String... args); }
FeaturePlugin implements Plugin { static FeatureGraph createFeatureGraph( JCTree.JCCompilationUnit compilationUnit, Context context) { FeatureGraph featureGraph = new FeatureGraph( compilationUnit.getSourceFile().getName(), compilationUnit.endPositions, compilationUnit.lineMap); AstScanner.addToGraph(compilationUnit, featureGraph); Tokens.addToGraph(compilationUnit.getSourceFile(), context, featureGraph); linkTokensToAstNodes(featureGraph); featureGraph.pruneAstNodes(); JavacProcessingEnvironment processingEnvironment = JavacProcessingEnvironment.instance(context); ImmutableMap<ClassTree, ImmutableMap<MethodTree, DataflowOutputs>> analysisResults = DataflowOutputs.create(compilationUnit, processingEnvironment); DataflowOutputsScanner.addToGraph(compilationUnit, analysisResults, featureGraph); TypeAnalysis typeAnalysis = new TypeAnalysis(compilationUnit, processingEnvironment); TypeScanner.addToGraph(compilationUnit, featureGraph, typeAnalysis); AssignabilityAnalysis.addToGraph(featureGraph, typeAnalysis); ComputedFromScanner.addToGraph(compilationUnit, featureGraph); LastLexicalUseScanner.addToGraph(compilationUnit, featureGraph); ReturnsToScanner.addToGraph(compilationUnit, featureGraph); FormalArgScanner.addToGraph(compilationUnit, featureGraph); GuardedByScanner.addToGraph(compilationUnit, featureGraph); SymbolScanner.addToGraph(compilationUnit, featureGraph); linkCommentsToAstNodes(featureGraph); checkSymbols(featureGraph); return featureGraph; }  @Override String getName(); @Override void init(JavacTask task, String... args);  }