Java Code Examples for org.eclipse.xtext.validation.Issue.IssueImpl#setLineNumber()
The following examples show how to use
org.eclipse.xtext.validation.Issue.IssueImpl#setLineNumber() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DiagnosticConverterImpl.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@Override public void convertResourceDiagnostic(Diagnostic diagnostic, Severity severity, IAcceptor<Issue> acceptor) { IssueImpl issue = new Issue.IssueImpl(); issue.setSyntaxError(diagnostic instanceof XtextSyntaxDiagnostic); issue.setSeverity(severity); issue.setLineNumber(diagnostic.getLine()); issue.setColumn(diagnostic.getColumn()); issue.setMessage(diagnostic.getMessage()); if (diagnostic instanceof org.eclipse.xtext.diagnostics.Diagnostic) { org.eclipse.xtext.diagnostics.Diagnostic xtextDiagnostic = (org.eclipse.xtext.diagnostics.Diagnostic) diagnostic; issue.setOffset(xtextDiagnostic.getOffset()); issue.setLength(xtextDiagnostic.getLength()); } if (diagnostic instanceof AbstractDiagnostic) { AbstractDiagnostic castedDiagnostic = (AbstractDiagnostic)diagnostic; issue.setUriToProblem(castedDiagnostic.getUriToProblem()); issue.setCode(castedDiagnostic.getCode()); issue.setData(castedDiagnostic.getData()); issue.setLineNumberEnd(castedDiagnostic.getLineEnd()); issue.setColumnEnd(castedDiagnostic.getColumnEnd()); } issue.setType(CheckType.FAST); acceptor.accept(issue); }
Example 2
Source File: DiagnosticIssueConverter.java From n4js with Eclipse Public License 1.0 | 5 votes |
/** Convert the given diagnostic to an issue. */ public Issue toIssue(URI uri, Diagnostic diagnostic, Optional<Document> document) { IssueImpl issue = new Issue.IssueImpl(); issue.setSeverity(toSeverity(diagnostic.getSeverity())); Range range = diagnostic.getRange(); Position sPos = range.getStart(); Position ePos = range.getEnd(); int offSetStart = 0; int offSetEnd = 0; if (document.isPresent()) { offSetStart = document.get().getOffSet(new Position(sPos.getLine() + 1, sPos.getCharacter() + 1)); offSetEnd = document.get().getOffSet(new Position(ePos.getLine() + 1, ePos.getCharacter() + 1)); } issue.setLineNumber(sPos.getLine() + 1); issue.setColumn(sPos.getCharacter() + 1); issue.setOffset(offSetStart); issue.setLength(offSetEnd - offSetStart); issue.setUriToProblem(uri); issue.setCode(diagnostic.getCode()); issue.setType(CheckType.FAST); issue.setMessage(diagnostic.getMessage()); return issue; }
Example 3
Source File: DiagnosticConverterImpl.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public void convertValidatorDiagnostic(org.eclipse.emf.common.util.Diagnostic diagnostic, IAcceptor<Issue> acceptor) { Severity severity = getSeverity(diagnostic); if (severity == null) return; IssueImpl issue = new Issue.IssueImpl(); issue.setSeverity(severity); IssueLocation locationData = getLocationData(diagnostic); if (locationData != null) { issue.setLineNumber(locationData.lineNumber); issue.setColumn(locationData.column); issue.setOffset(locationData.offset); issue.setLength(locationData.length); issue.setLineNumberEnd(locationData.lineNumberEnd); issue.setColumnEnd(locationData.columnEnd); } final EObject causer = getCauser(diagnostic); if (causer != null) issue.setUriToProblem(EcoreUtil.getURI(causer)); issue.setCode(getIssueCode(diagnostic)); issue.setType(getIssueType(diagnostic)); issue.setData(getIssueData(diagnostic)); // marker.put(IXtextResourceChecker.DIAGNOSTIC_KEY, diagnostic); issue.setMessage(diagnostic.getMessage()); // marker.put(IMarker.PRIORITY, Integer.valueOf(IMarker.PRIORITY_LOW)); acceptor.accept(issue); }