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


Java JavaFileScannerContext类代码示例

本文整理汇总了Java中org.sonar.plugins.java.api.JavaFileScannerContext的典型用法代码示例。如果您正苦于以下问题:Java JavaFileScannerContext类的具体用法?Java JavaFileScannerContext怎么用?Java JavaFileScannerContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


JavaFileScannerContext类属于org.sonar.plugins.java.api包,在下文中一共展示了JavaFileScannerContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: computeEG

import org.sonar.plugins.java.api.JavaFileScannerContext; //导入依赖的package包/类
private void computeEG() {
  JavaFileScannerContext mockContext = mock(JavaFileScannerContext.class);
  when(mockContext.getTree()).thenReturn(cut);
  when(mockContext.getSemanticModel()).thenReturn(semanticModel);
  // explicitly enable X-File analysis
  this.behaviorCache = new BehaviorCache(classLoader, true);
  SymbolicExecutionVisitor sev = new SymbolicExecutionVisitor(Lists.newArrayList(), behaviorCache) {
    @Override
    public void execute(MethodTree methodTree) {
      this.context = mockContext;
      super.execute(methodTree);
    }
  };
  sev.behaviorCache.setFileContext(sev, semanticModel);
  ExplodedGraphWalker.ExplodedGraphWalkerFactory egwFactory = new ExplodedGraphWalker.ExplodedGraphWalkerFactory(Collections.emptyList());
  ExplodedGraphWalker walker = egwFactory.createWalker(sev.behaviorCache, semanticModel);
  walker.visitMethod(methodToAnalyze, new MethodBehavior(((JavaSymbol.MethodJavaSymbol) methodToAnalyze.symbol()).completeSignature()));

  this.explodedGraph = getExplodedGraph(walker);
}
 
开发者ID:SonarSource,项目名称:source-graph-viewer,代码行数:21,代码来源:EGDotGraph.java

示例2: scanFile

import org.sonar.plugins.java.api.JavaFileScannerContext; //导入依赖的package包/类
@Override
public void scanFile(JavaFileScannerContext context) {
  this.context = context;

  // The call to the scan method on the root of the tree triggers the visit of the AST by this visitor
  scan(context.getTree());

  // For debugging purpose, you can print out the entire AST of the analyzed file
  System.out.println(PrinterVisitor.print(context.getTree()));
}
 
开发者ID:SonarSource,项目名称:sonar-custom-rules-examples,代码行数:11,代码来源:AvoidBrandInMethodNamesRule.java

示例3: scanFile

import org.sonar.plugins.java.api.JavaFileScannerContext; //导入依赖的package包/类
/**
 * Implementation of the method of the JavaFileScanner interface.
 * @param context Object used to attach issues to source file.
 */
@Override
public void scanFile(JavaFileScannerContext context) {
  this.context = context;

  // The call to the scan method on the root of the tree triggers the visit of the AST by this visitor
  scan(context.getTree());

  // For debugging purpose, you can print out the entire AST of the analyzed file
  System.out.println(PrinterVisitor.print(context.getTree()));
}
 
开发者ID:SonarSource,项目名称:sonar-custom-rules-examples,代码行数:15,代码来源:AvoidMethodDeclarationRule.java

示例4: scanFile

import org.sonar.plugins.java.api.JavaFileScannerContext; //导入依赖的package包/类
@Override
public void scanFile(JavaFileScannerContext context) {
  this.context = context;

  scan(context.getTree());

  System.out.println(PrinterVisitor.print(context.getTree()));
}
 
开发者ID:SonarSource,项目名称:sonar-custom-rules-examples,代码行数:9,代码来源:AvoidAnnotationRule.java

示例5: scanFile

import org.sonar.plugins.java.api.JavaFileScannerContext; //导入依赖的package包/类
@Override
public void scanFile(JavaFileScannerContext context) {
  this.context = context;

  scan(context.getTree());

  System.out.println(context.getTree());
}
 
开发者ID:startupheroes,项目名称:startupheroes-checkstyle,代码行数:9,代码来源:AvoidAnnotationRule.java

示例6: scanFile

import org.sonar.plugins.java.api.JavaFileScannerContext; //导入依赖的package包/类
@Override
public void scanFile(JavaFileScannerContext context) {
    this.context = context;
    exceptions = new ArrayList<>();
    Iterables.addAll(exceptions, Splitter.on(",").trimResults().split(exceptionsCommaSeparated));
    scan(context.getTree());
}
 
开发者ID:Axway,项目名称:sonar-rules,代码行数:8,代码来源:CaughtExceptionTouchedCheck.java

示例7: ClassVisitor

import org.sonar.plugins.java.api.JavaFileScannerContext; //导入依赖的package包/类
ClassVisitor(JavaFileScannerContext context, JavaFileScanner javaFileScanner) {
	this.context = context;
	this.javaFileScanner = javaFileScanner;
	this.sliceAnnotationPresent = false;
	this.implementedInitializableModel = false;
	this.ignoreAnonymousClass = false;
}
 
开发者ID:Cognifide,项目名称:AEM-Rules-for-SonarQube,代码行数:8,代码来源:ClassVisitor.java

示例8: handleSmellAnnotation

import org.sonar.plugins.java.api.JavaFileScannerContext; //导入依赖的package包/类
private void handleSmellAnnotation(final AnnotationTree annotationTree) {
    String message = "";
    Integer minutes = 0;
    SmellType type = null;
    final Arguments arguments = annotationTree.arguments();
    for (final ExpressionTree expressionTree : arguments) {
        if (expressionTree.is(Tree.Kind.ASSIGNMENT)) {
            final AssignmentExpressionTree aet = (AssignmentExpressionTree) expressionTree;
            final String variable = ((IdentifierTree) aet.variable()).name();
            switch (variable) {
                case "minutes":
                    minutes += Integer.valueOf(((LiteralTree) aet.expression()).value());
                    LOGGER.debug("{} = {}", variable, minutes);
                    break;
                case "reason":
                    message = extractMessage(aet.expression());
                    LOGGER.debug("{} = {}", variable, message);
                    break;
                case "type":
                    type = SmellType.valueOf(((MemberSelectExpressionTree) aet.expression()).identifier()
                        .name());
                    break;
                default:
                    break;
            }
        }
    }
    if (smellType().equals(type)) {
        final Matcher matcher = PATTERN.matcher(message);
        if (matcher.matches()) {
            message = matcher.group(1);
        }
        reportIssue(annotationTree, message, new ArrayList<JavaFileScannerContext.Location>(), minutes);
    }
}
 
开发者ID:QualInsight,项目名称:qualinsight-plugins-sonarqube-smell,代码行数:36,代码来源:AbstractSmellCheck.java

示例9: scanFile

import org.sonar.plugins.java.api.JavaFileScannerContext; //导入依赖的package包/类
@Override
public void scanFile(JavaFileScannerContext context) {
  this.context = context;

  scan(context.getTree());
}
 
开发者ID:SonarSource,项目名称:sonar-custom-rules-examples,代码行数:7,代码来源:SpringControllerRequestMappingEntityRule.java

示例10: scanFile

import org.sonar.plugins.java.api.JavaFileScannerContext; //导入依赖的package包/类
@Override
public void scanFile(JavaFileScannerContext context) {
  this.context = context;
  scan(context.getTree());
}
 
开发者ID:SonarSource,项目名称:sonar-custom-rules-examples,代码行数:6,代码来源:SecurityAnnotationMandatoryRule.java

示例11: scanFile

import org.sonar.plugins.java.api.JavaFileScannerContext; //导入依赖的package包/类
@Override
public void scanFile(JavaFileScannerContext context) {
    this.context = context;
    scan(context.getTree());
}
 
开发者ID:Axway,项目名称:sonar-rules,代码行数:6,代码来源:UnusedNotAnnotatedPrivateFieldCheck.java

示例12: scanFile

import org.sonar.plugins.java.api.JavaFileScannerContext; //导入依赖的package包/类
@Override
public void scanFile(@Nonnull JavaFileScannerContext context) {
	this.context = context;
	scan(context.getTree());
}
 
开发者ID:Cognifide,项目名称:AEM-Rules-for-SonarQube,代码行数:6,代码来源:ModelsShouldNotUseSessionCheck.java

示例13: MethodInvocationVisitor

import org.sonar.plugins.java.api.JavaFileScannerContext; //导入依赖的package包/类
MethodInvocationVisitor(JavaFileScanner javaFileScanner, JavaFileScannerContext context) {
	this.javaFileScanner = javaFileScanner;
	this.context = context;
}
 
开发者ID:Cognifide,项目名称:AEM-Rules-for-SonarQube,代码行数:5,代码来源:MethodInvocationVisitor.java

示例14: SessionUsageVisitor

import org.sonar.plugins.java.api.JavaFileScannerContext; //导入依赖的package包/类
SessionUsageVisitor(JavaFileScanner javaFileScanner, JavaFileScannerContext context) {
	this.javaFileScanner = javaFileScanner;
	this.context = context;
}
 
开发者ID:Cognifide,项目名称:AEM-Rules-for-SonarQube,代码行数:5,代码来源:SessionUsageVisitor.java

示例15: scanFile

import org.sonar.plugins.java.api.JavaFileScannerContext; //导入依赖的package包/类
@Override
public void scanFile(JavaFileScannerContext context) {
	this.context = context;
	scan(context.getTree());
}
 
开发者ID:Cognifide,项目名称:AEM-Rules-for-SonarQube,代码行数:6,代码来源:JcrPropertyFieldsInConstructorCheck.java


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