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


Java CounterVisitor类代码示例

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


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

示例1: setMetrics

import org.sonar.squidbridge.metrics.CounterVisitor; //导入依赖的package包/类
private static void setMetrics(FlowConfiguration conf, AstScanner.Builder<Grammar> builder) {
  builder.withMetrics(FlowMetric.values());
  builder.setFilesMetric(FlowMetric.FILES);
	builder.withSquidAstVisitor(new LinesVisitor<Grammar>(FlowMetric.LINES));
  builder.withSquidAstVisitor(new FlowLinesOfCodeVisitor<Grammar>(FlowMetric.LINES_OF_CODE));
  builder.withSquidAstVisitor(new DependencyVisitor<Grammar>());
  AstNodeType[] complexityAstNodeType = new AstNodeType[]{
    FlowGrammar.LOOP,
    FlowGrammar.BRANCH,
    FlowGrammar.SEQUENCE,
    FlowGrammar.RETRY
  };
  builder.withSquidAstVisitor(ComplexityVisitor.<Grammar>builder()
    .setMetricDef(FlowMetric.COMPLEXITY)
    .subscribeTo(complexityAstNodeType)
    .build());

  builder.withSquidAstVisitor(CommentsVisitor.<Grammar>builder().withCommentMetric(FlowMetric.COMMENT_LINES)
    .withNoSonar(true)
    .build());
  builder.withSquidAstVisitor(CounterVisitor.<Grammar>builder()
    .setMetricDef(FlowMetric.MAPS)
    .subscribeTo(FlowGrammar.MAP)
    .build());
}
 
开发者ID:I8C,项目名称:sonar-flow-plugin,代码行数:26,代码来源:FlowAstScanner.java

示例2: create

import org.sonar.squidbridge.metrics.CounterVisitor; //导入依赖的package包/类
public static AstScanner<Grammar> create(PuppetConfiguration conf, SquidAstVisitor<Grammar>... visitors) {
  final SquidAstVisitorContextImpl<Grammar> context = new SquidAstVisitorContextImpl<>(new SourceProject("Puppet Project"));
  final Parser<Grammar> parser = PuppetParser.create(conf);

  AstScanner.Builder<Grammar> builder = AstScanner.<Grammar>builder(context).setBaseParser(parser);

  builder.withMetrics(PuppetMetric.values());
  builder.setFilesMetric(PuppetMetric.FILES);
  builder.setCommentAnalyser(new PuppetCommentAnalyser());

  builder.withSquidAstVisitor(new LinesVisitor<Grammar>(PuppetMetric.LINES));
  builder.withSquidAstVisitor(new PuppetLinesOfCodeVisitor<Grammar>(PuppetMetric.LINES_OF_CODE));
  builder.withSquidAstVisitor(new FunctionVisitor());
  builder.withSquidAstVisitor(new ComplexityVisitor());

  builder.withSquidAstVisitor(CommentsVisitor.<Grammar>builder().withCommentMetric(PuppetMetric.COMMENT_LINES)
    .withNoSonar(true)
    .withIgnoreHeaderComment(conf.getIgnoreHeaderComments())
    .build());

  builder.withSquidAstVisitor(new SourceCodeBuilderVisitor<Grammar>(
    new ClassSourceCodeBuilderCallback(),
    PuppetGrammar.CLASSDEF,
    PuppetGrammar.DEFINITION));

  builder.withSquidAstVisitor(CounterVisitor.<Grammar>builder()
    .setMetricDef(PuppetMetric.CLASSES)
    .subscribeTo(PuppetGrammar.CLASSDEF, PuppetGrammar.DEFINITION)
    .build());

  // TODO: To be discussed with the mapping of FUNCTIONS
  builder.withSquidAstVisitor(CounterVisitor.<Grammar>builder()
    .setMetricDef(PuppetMetric.RESOURCES)
    .subscribeTo(PuppetGrammar.RESOURCE)
    .build());

  builder.withSquidAstVisitor(CounterVisitor.<Grammar>builder()
    .setMetricDef(PuppetMetric.STATEMENTS)
    .subscribeTo(PuppetGrammar.STATEMENT)
    .build());

  for (SquidAstVisitor<Grammar> visitor : visitors) {
    if (visitor instanceof CharsetAwareVisitor) {
      ((CharsetAwareVisitor) visitor).setCharset(conf.getCharset());
    }
    builder.withSquidAstVisitor(visitor);
  }

  return builder.build();
}
 
开发者ID:iwarapter,项目名称:sonar-puppet,代码行数:51,代码来源:PuppetAstScanner.java


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