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

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

本文整理了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

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

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

  1. protected void setRootRule(GrammarRuleKey ruleKey) {
  2. p.setRootRule(p.getGrammar().rule(ruleKey));
  3. }
  4. }

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

  1. /**
  2. * Re-parses a query that was retrieved as a String.
  3. *
  4. * @param astNode The String's node.
  5. * @return The query as a new QUERY_EXPRESSION node.
  6. */
  7. public static AstNode parseQuery(AstNode astNode) {
  8. AstNode parsedQuery = null;
  9. try {
  10. String string = astNode.getTokenOriginalValue();
  11. String queryAsString = StringUtils.substringBetween(string, "'", "'");
  12. Parser<Grammar> queryParser = ApexParser.create(new ApexConfiguration(Charsets.UTF_8));
  13. queryParser.setRootRule(queryParser.getGrammar().rule(ApexGrammarRuleKey.QUERY_EXPRESSION));
  14. parsedQuery = queryParser.parse(queryAsString);
  15. } catch (Exception e) {
  16. ChecksLogger.logCheckError(CLASS_TO_LOG, METHOD_TO_LOG, e.toString());
  17. }
  18. return parsedQuery;
  19. }
  20. }

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

  1. private Parser createParserWithEofMatcher() {
  2. RuleDefinition rule = actual.getRootRule();
  3. RuleDefinition endOfInput = new RuleDefinition(new EndOfInput())
  4. .is(new FirstOfExpression(EndOfInputExpression.INSTANCE, new TokenTypeExpression(GenericTokenType.EOF)));
  5. RuleDefinition withEndOfInput = new RuleDefinition(new WithEndOfInput(actual.getRootRule().getRuleKey()))
  6. .is(rule, endOfInput);
  7. Parser parser = Parser.builder(actual).build();
  8. parser.setRootRule(withEndOfInput);
  9. return parser;
  10. }

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

  1. private Parser createParserWithEofMatcher() {
  2. RuleDefinition rule = actual.getRootRule();
  3. RuleDefinition endOfInput = new RuleDefinition(new EndOfInput())
  4. .is(new FirstOfExpression(EndOfInputExpression.INSTANCE, new TokenTypeExpression(GenericTokenType.EOF)));
  5. RuleDefinition withEndOfInput = new RuleDefinition(new WithEndOfInput(actual.getRootRule().getRuleKey()))
  6. .is(rule, endOfInput);
  7. Parser parser = Parser.builder(actual).build();
  8. parser.setRootRule(withEndOfInput);
  9. return parser;
  10. }

相关文章