当前位置: 首页>>代码示例>>Java>>正文


Java CompilationUnitTree类代码示例

本文整理汇总了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();
}
 
开发者ID:SonarSource,项目名称:source-graph-viewer,代码行数:9,代码来源:EGDotGraph.java

示例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);
}
 
开发者ID:SonarSource,项目名称:source-graph-viewer,代码行数:12,代码来源:Viewer.java

示例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);
}
 
开发者ID:SonarSource,项目名称:source-graph-viewer,代码行数:11,代码来源:Viewer.java

示例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


注:本文中的org.sonar.plugins.java.api.tree.CompilationUnitTree类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。