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