com.sonar.sslr.impl.Parser.setRootRule()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(2.4k)|赞(0)|评价(0)|浏览(75)

本文整理了Java中com.sonar.sslr.impl.Parser.setRootRule()方法的一些代码示例,展示了Parser.setRootRule()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Parser.setRootRule()方法的具体详情如下:
包路径:com.sonar.sslr.impl.Parser
类名称:Parser
方法名:setRootRule

Parser.setRootRule介绍

暂无

代码示例

代码示例来源:origin: org.codehaus.sonar-plugins.dotnet.csharp/sonar-csharp-squid-plugin

public IgnoreUsingDirectivePreprocessor(CSharpConfiguration conf) {
 this.parser = CSharpParser.create(conf);
 this.parser.setRootRule(this.parser.getGrammar().usingDirective);
}

代码示例来源:origin: sonar-perl/sonar-perl

protected void setRootRule(GrammarRuleKey ruleKey) {
    p.setRootRule(p.getGrammar().rule(ruleKey));
  }
}

代码示例来源:origin: fundacionjala/enforce-sonarqube-plugin

/**
   * Re-parses a query that was retrieved as a String.
   *
   * @param astNode The String's node.
   * @return The query as a new QUERY_EXPRESSION node.
   */
  public static AstNode parseQuery(AstNode astNode) {
    AstNode parsedQuery = null;
    try {
      String string = astNode.getTokenOriginalValue();
      String queryAsString = StringUtils.substringBetween(string, "'", "'");
      Parser<Grammar> queryParser = ApexParser.create(new ApexConfiguration(Charsets.UTF_8));
      queryParser.setRootRule(queryParser.getGrammar().rule(ApexGrammarRuleKey.QUERY_EXPRESSION));
      parsedQuery = queryParser.parse(queryAsString);
    } catch (Exception e) {
      ChecksLogger.logCheckError(CLASS_TO_LOG, METHOD_TO_LOG, e.toString());
    }
    return parsedQuery;
  }
}

代码示例来源:origin: org.sonarsource.sslr/sslr-testing-harness

private Parser createParserWithEofMatcher() {
 RuleDefinition rule = actual.getRootRule();
 RuleDefinition endOfInput = new RuleDefinition(new EndOfInput())
   .is(new FirstOfExpression(EndOfInputExpression.INSTANCE, new TokenTypeExpression(GenericTokenType.EOF)));
 RuleDefinition withEndOfInput = new RuleDefinition(new WithEndOfInput(actual.getRootRule().getRuleKey()))
   .is(rule, endOfInput);
 Parser parser = Parser.builder(actual).build();
 parser.setRootRule(withEndOfInput);
 return parser;
}

代码示例来源:origin: SonarSource/sslr

private Parser createParserWithEofMatcher() {
 RuleDefinition rule = actual.getRootRule();
 RuleDefinition endOfInput = new RuleDefinition(new EndOfInput())
   .is(new FirstOfExpression(EndOfInputExpression.INSTANCE, new TokenTypeExpression(GenericTokenType.EOF)));
 RuleDefinition withEndOfInput = new RuleDefinition(new WithEndOfInput(actual.getRootRule().getRuleKey()))
   .is(rule, endOfInput);
 Parser parser = Parser.builder(actual).build();
 parser.setRootRule(withEndOfInput);
 return parser;
}

相关文章

微信公众号

最新文章

更多