當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。