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


Java RecognitionException类代码示例

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


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

示例1: processRecognitionException

import com.sonar.sslr.api.RecognitionException; //导入依赖的package包/类
private void processRecognitionException(RecognitionException e, SensorContext sensorContext, InputFile inputFile) {
    if (parsingErrorRuleKey != null) {
        NewIssue newIssue = sensorContext.newIssue();

        NewIssueLocation primaryLocation = newIssue.newLocation()
                .message(e.getMessage())
                .on(inputFile)
                .at(inputFile.selectLine(e.getLine()));

        newIssue
                .forRule(parsingErrorRuleKey)
                .at(primaryLocation)
                .save();
    }
}
 
开发者ID:antowski,项目名称:sonar-onec,代码行数:16,代码来源:OneCSensor.java

示例2: parseTillEof

import com.sonar.sslr.api.RecognitionException; //导入依赖的package包/类
private void parseTillEof(String input) {
    OneCTree tree = (OneCTree) actual.parse(input);
    InternalSyntaxToken lastToken = (InternalSyntaxToken) tree.lastToken();

    if (lastToken == null)  {
        throw new RecognitionException(0, "Did not match till EOF : Last syntax token cannot be found");
    }

    if (!lastToken.isEOF() && (lastToken.column()+lastToken.text().length() != input.length())) {
        throw new RecognitionException(
                0, "Did not match till EOF, but till line " + lastToken.line() + ": token \"" + lastToken.text() + "\"");
    }
}
 
开发者ID:antowski,项目名称:sonar-onec,代码行数:14,代码来源:Assertions.java

示例3: matches

import com.sonar.sslr.api.RecognitionException; //导入依赖的package包/类
public ParserAssert matches(String input) {
    isNotNull();
    Preconditions.checkArgument(!hasTrailingWhitespaces(input), "Trailing whitespaces in input are not supported");
    String expected = "Rule '" + getRuleName() + "' should match:\n" + input;
    try {
        parseTillEof(input);
    } catch (RecognitionException e) {  //NOSONAR
        String actual = e.getMessage();
        throw new ParsingResultComparisonFailure(expected, actual);
    }
    return this;
}
 
开发者ID:antowski,项目名称:sonar-onec,代码行数:13,代码来源:Assertions.java

示例4: notMatches

import com.sonar.sslr.api.RecognitionException; //导入依赖的package包/类
public ParserAssert notMatches(String input) {
    isNotNull();
    try {
        parseTillEof(input);
    } catch (RecognitionException e) {  //NOSONAR
        // expected
        return this;
    }
    throw new AssertionError("Rule '" + getRuleName() + "' should not match:\n" + input);
}
 
开发者ID:antowski,项目名称:sonar-onec,代码行数:11,代码来源:Assertions.java

示例5: processRecognitionException

import com.sonar.sslr.api.RecognitionException; //导入依赖的package包/类
private void processRecognitionException(RecognitionException e, SensorContext sensorContext, InputFile inputFile) {
  if (parsingErrorRuleKey != null) {
    NewIssue newIssue = sensorContext.newIssue();

    NewIssueLocation primaryLocation = newIssue.newLocation()
      .message(e.getMessage())
      .on(inputFile)
      .at(inputFile.selectLine(e.getLine()));

    newIssue
      .forRule(parsingErrorRuleKey)
      .at(primaryLocation)
      .save();
  }
}
 
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:16,代码来源:AbstractLanguageAnalyzerSensor.java

示例6: parse_error

import com.sonar.sslr.api.RecognitionException; //导入依赖的package包/类
@Test(expected = RecognitionException.class)
public void parse_error() throws Exception {
  GherkinParserBuilder
    .createTestParser(Charsets.UTF_8)
    .parse("blabla");
}
 
开发者ID:racodond,项目名称:sonar-gherkin-plugin,代码行数:7,代码来源:GherkinGrammarTest.java

示例7: processRecognitionException

import com.sonar.sslr.api.RecognitionException; //导入依赖的package包/类
@Override
public void processRecognitionException(RecognitionException e) {
  addIssue(e.getLine(), this, e.getMessage());
}
 
开发者ID:iwarapter,项目名称:sonar-puppet,代码行数:5,代码来源:ParsingErrorCheck.java

示例8: parse_error

import com.sonar.sslr.api.RecognitionException; //导入依赖的package包/类
@Test(expected = RecognitionException.class)
public void parse_error() throws Exception {
  JavaPropertiesParserBuilder
    .createTestParser(Charsets.ISO_8859_1, JavaPropertiesLexicalGrammar.PROPERTIES)
    .parse("blabla");
}
 
开发者ID:racodond,项目名称:sonar-jproperties-plugin,代码行数:7,代码来源:JavaPropertiesGrammarTest.java

示例9: processRecognitionException

import com.sonar.sslr.api.RecognitionException; //导入依赖的package包/类
public void processRecognitionException(RecognitionException e) {
  getContext().createLineViolation(this, e.getMessage(), e.getLine());
}
 
开发者ID:Ne0s,项目名称:sonar-plsql,代码行数:4,代码来源:ParsingErrorCheck.java


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