本文整理汇总了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();
}
}
示例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() + "\"");
}
}
示例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;
}
示例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);
}
示例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();
}
}
示例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");
}
示例7: processRecognitionException
import com.sonar.sslr.api.RecognitionException; //导入依赖的package包/类
@Override
public void processRecognitionException(RecognitionException e) {
addIssue(e.getLine(), this, e.getMessage());
}
示例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");
}
示例9: processRecognitionException
import com.sonar.sslr.api.RecognitionException; //导入依赖的package包/类
public void processRecognitionException(RecognitionException e) {
getContext().createLineViolation(this, e.getMessage(), e.getLine());
}