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


Java AstNodeType类代码示例

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


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

示例1: setMetrics

import com.sonar.sslr.api.AstNodeType; //导入依赖的package包/类
/**
 * Sets the default apex metrics in {@link AstScanner}.
 *
 * @param config apex configuration.
 * @param builder scanner builder.
 */
private static void setMetrics(ApexConfiguration config, AstScanner.Builder<Grammar> builder) {
    builder.withSquidAstVisitor(new LinesVisitor<>(ApexMetric.LINES));
    builder.withSquidAstVisitor(new LinesOfCodeVisitor<>(ApexMetric.LINES_OF_CODE));
    AstNodeType[] complexityAstNodeType = new AstNodeType[]{
        METHOD_DECLARATION,
        WHILE_STATEMENT,
        FOR_STATEMENT,
        IF_STATEMENT,
        RETURN_STATEMENT
    };
    builder.withSquidAstVisitor(ComplexityVisitor.<Grammar>builder()
            .setMetricDef(ApexMetric.COMPLEXITY)
            .subscribeTo(complexityAstNodeType)
            .build());
    builder.withSquidAstVisitor(CommentsVisitor.<Grammar>builder()
            .withCommentMetric(ApexMetric.COMMENT_LINES)
            .withNoSonar(Boolean.TRUE)
            .withIgnoreHeaderComment(config.getIgnoreHeaderComments())
            .build());
    builder.withSquidAstVisitor(CounterVisitor.<Grammar>builder()
            .setMetricDef(ApexMetric.STATEMENTS)
            .subscribeTo(STATEMENT)
            .build());
}
 
开发者ID:fundacionjala,项目名称:enforce-sonarqube-plugin,代码行数:31,代码来源:ApexAstScanner.java

示例2: setMetrics

import com.sonar.sslr.api.AstNodeType; //导入依赖的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

示例3: buildCallback

import com.sonar.sslr.api.AstNodeType; //导入依赖的package包/类
/**
 * Builds and returns a source code builder callback.
 *
 * @param nodeName node type to identify a name.
 * @param isClass define a SourceClass or SourceFunction.
 * @return the builder callback.
 */
private static SourceCodeBuilderCallback buildCallback(AstNodeType nodeName, boolean isClass) {
    return (SourceCode sourceCode, AstNode astNode) -> {
        String key = generateKey(astNode, nodeName);
        sourceCode = isClass ? new SourceClass(key) : new SourceFunction(key);
        sourceCode.setStartAtLine(astNode.getTokenLine());
        return sourceCode;
    };
}
 
开发者ID:fundacionjala,项目名称:enforce-sonarqube-plugin,代码行数:16,代码来源:ApexAstScanner.java

示例4: init

import com.sonar.sslr.api.AstNodeType; //导入依赖的package包/类
@Override
public void init() {
  subscribeTo(BLOCK_TYPES.toArray(new AstNodeType[BLOCK_TYPES.size()]));
}
 
开发者ID:iwarapter,项目名称:sonar-puppet,代码行数:5,代码来源:IndentationCheck.java

示例5: registerHardcodedVariables

import com.sonar.sslr.api.AstNodeType; //导入依赖的package包/类
/**
 * Given the list of hard-coded values, analyzes them if they match with the
 * SFDC ID regular expression and if this value belongs to an ID type
 * variable if so then registers this node into a list of hard-coded
 * variables detected.
 *
 * @param variableInitializers list of hard-coded values found.
 * @param variableDeclarationType the node type of variable declarations,
 * according the situation defines what nodes to look for
 * @param variableValueNodeType the node type of variable values, according
 * the situation defines what nodes to look for
 * @param classOrInterfaceBodyNode a superior node where some nodes are
 * visited from.
 */
void registerHardcodedVariables(AstSelect variableInitializers, AstNodeType variableDeclarationType,
        AstNodeType variableValueNodeType, AstNode classOrInterfaceBodyNode) {
    for (AstNode current : variableInitializers) {
        String variableName = current.getParent()
                .getFirstDescendant(variableValueNodeType).getTokenOriginalValue();
        if (current.getTokenOriginalValue().matches(ID_PATTERN)
                && isIdTypeVariable(variableName, classOrInterfaceBodyNode
                        .getDescendants(variableDeclarationType))) {
            hardcodedVariables.put(variableName, current.getParent());
        }
    }
}
 
开发者ID:fundacionjala,项目名称:enforce-sonarqube-plugin,代码行数:27,代码来源:HardcodingIdsCheckInVariables.java

示例6: generateKey

import com.sonar.sslr.api.AstNodeType; //导入依赖的package包/类
/**
 * Generates and returns the unique key for a node.
 *
 * @param node node type to identify a name
 * @param nodeName current node to be analyzed.
 * @return the key.
 */
private static String generateKey(AstNode node, AstNodeType nodeName) {
    String name = node.getFirstDescendant(nodeName).getTokenValue();
    int line = node.getToken().getLine();
    return String.format(KEY_PATTERN, name, line);
}
 
开发者ID:fundacionjala,项目名称:enforce-sonarqube-plugin,代码行数:13,代码来源:ApexAstScanner.java


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