use of org.eclipse.xtext.nodemodel.SyntaxErrorMessage in project xtext-core by eclipse.
the class AbstractInternalAntlrParser method createLeafNode.
private ILeafNode createLeafNode(Token token, EObject grammarElement) {
boolean isHidden = token.getChannel() == HIDDEN;
SyntaxErrorMessage error = null;
if (!isHidden) {
if (currentError != null) {
error = currentError;
currentError = null;
}
}
if (token.getType() == Token.INVALID_TOKEN_TYPE) {
if (error == null) {
String lexerErrorMessage = ((XtextTokenStream) input).getLexerErrorMessage(token);
LexerErrorContext errorContext = new LexerErrorContext(lexerErrorMessage);
error = syntaxErrorProvider.getSyntaxErrorMessage(errorContext);
}
}
if (grammarElement == null) {
String ruleName = antlrTypeToLexerName.get(token.getType());
grammarElement = allRules.get(ruleName);
}
CommonToken commonToken = (CommonToken) token;
if (error != null)
hadErrors = true;
return nodeBuilder.newLeafNode(commonToken.getStartIndex(), commonToken.getStopIndex() - commonToken.getStartIndex() + 1, grammarElement, isHidden, error, currentNode);
}
use of org.eclipse.xtext.nodemodel.SyntaxErrorMessage in project xtext-core by eclipse.
the class XtextResource method addSyntaxDiagnostic.
/**
* @since 2.7
*/
protected void addSyntaxDiagnostic(List<Diagnostic> diagnostics, INode error) {
SyntaxErrorMessage syntaxErrorMessage = error.getSyntaxErrorMessage();
if (org.eclipse.xtext.diagnostics.Diagnostic.SYNTAX_DIAGNOSTIC_WITH_RANGE.equals(syntaxErrorMessage.getIssueCode())) {
String[] issueData = syntaxErrorMessage.getIssueData();
if (issueData.length == 1) {
String data = issueData[0];
int colon = data.indexOf(':');
diagnostics.add(new XtextSyntaxDiagnosticWithRange(error, Integer.valueOf(data.substring(0, colon)), Integer.valueOf(data.substring(colon + 1)), null));
return;
}
}
diagnostics.add(new XtextSyntaxDiagnostic(error));
}
Aggregations