Search in sources :

Example 1 with IssueImpl

use of org.eclipse.xtext.validation.Issue.IssueImpl in project xtext-core by eclipse.

the class DiagnosticConverterImpl method convertResourceDiagnostic.

@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);
}
Also used : XtextSyntaxDiagnostic(org.eclipse.xtext.resource.XtextSyntaxDiagnostic) IssueImpl(org.eclipse.xtext.validation.Issue.IssueImpl) XtextSyntaxDiagnostic(org.eclipse.xtext.resource.XtextSyntaxDiagnostic) Diagnostic(org.eclipse.emf.ecore.resource.Resource.Diagnostic) AbstractDiagnostic(org.eclipse.xtext.diagnostics.AbstractDiagnostic) AbstractDiagnostic(org.eclipse.xtext.diagnostics.AbstractDiagnostic)

Example 2 with IssueImpl

use of org.eclipse.xtext.validation.Issue.IssueImpl in project xtext-core by eclipse.

the class DiagnosticConverterImpl method convertValidatorDiagnostic.

@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);
}
Also used : EObject(org.eclipse.emf.ecore.EObject) IssueImpl(org.eclipse.xtext.validation.Issue.IssueImpl) Severity(org.eclipse.xtext.diagnostics.Severity)

Aggregations

IssueImpl (org.eclipse.xtext.validation.Issue.IssueImpl)2 EObject (org.eclipse.emf.ecore.EObject)1 Diagnostic (org.eclipse.emf.ecore.resource.Resource.Diagnostic)1 AbstractDiagnostic (org.eclipse.xtext.diagnostics.AbstractDiagnostic)1 Severity (org.eclipse.xtext.diagnostics.Severity)1 XtextSyntaxDiagnostic (org.eclipse.xtext.resource.XtextSyntaxDiagnostic)1