本文整理汇总了Java中org.sonar.plugins.java.api.tree.CompilationUnitTree类的典型用法代码示例。如果您正苦于以下问题:Java CompilationUnitTree类的具体用法?Java CompilationUnitTree怎么用?Java CompilationUnitTree使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CompilationUnitTree类属于org.sonar.plugins.java.api.tree包,在下文中一共展示了CompilationUnitTree类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: EGDotGraph
import org.sonar.plugins.java.api.tree.CompilationUnitTree; //导入依赖的package包/类
private EGDotGraph(CompilationUnitTree cut, MethodTree method, SemanticModel semanticModel, SquidClassLoader classLoader, int cfgFirstBlockId) {
this.cut = cut;
this.methodToAnalyze = method;
this.semanticModel = semanticModel;
this.cfgFirstBlockId = cfgFirstBlockId;
this.classLoader = classLoader;
computeEG();
}
示例2: Base
import org.sonar.plugins.java.api.tree.CompilationUnitTree; //导入依赖的package包/类
public Base(String source) {
this.cut = (CompilationUnitTree) PARSER.parse(source);
List<File> classpath = getFilesRecursively(new String[] {"jar", "zip"});
this.classLoader = new SquidClassLoader(classpath);
this.semanticModel = SemanticModel.createFor(cut, classLoader);
this.firstMethodOrConstructor = getFirstMethodOrConstructor(cut);
Preconditions.checkNotNull(firstMethodOrConstructor, "Unable to find a method/constructor in first class.");
this.cfgFirstMethodOrConstructor = CFG.build(firstMethodOrConstructor);
}
示例3: getFirstMethodOrConstructor
import org.sonar.plugins.java.api.tree.CompilationUnitTree; //导入依赖的package包/类
@CheckForNull
private static MethodTree getFirstMethodOrConstructor(CompilationUnitTree cut) {
return (MethodTree) cut.types().stream()
.findFirst()
.map(ClassTree.class::cast)
.map(ClassTree::members)
.map(List::stream)
.flatMap(members -> members.filter(m -> m.is(Tree.Kind.METHOD, Tree.Kind.CONSTRUCTOR)).findFirst())
.orElse(null);
}
示例4: visitCompilationUnit
import org.sonar.plugins.java.api.tree.CompilationUnitTree; //导入依赖的package包/类
@Override
public void visitCompilationUnit(CompilationUnitTree tree) {
if (tree.packageDeclaration() != null) {
String packageName = PackageUtils.packageName(tree.packageDeclaration(), ".");
LOGGER.info("PackageName : " + packageName);
}
super.visitCompilationUnit(tree);
}
开发者ID:SonarSource,项目名称:sonar-custom-rules-examples,代码行数:11,代码来源:SecurityAnnotationMandatoryRule.java