Search in sources :

Example 1 with IssueSeveritiesProvider

use of org.eclipse.xtext.validation.IssueSeveritiesProvider in project xtext-eclipse by eclipse.

the class DerivedResourceMarkerCopier method getMaxSeverity.

private int getMaxSeverity(IFile srcFile) {
    URI resourceURI = URI.createPlatformResourceURI(srcFile.getFullPath().toString(), true);
    IResourceServiceProvider serviceProvider = serviceProviderRegistry.getResourceServiceProvider(resourceURI);
    if (serviceProvider == null)
        return Integer.MAX_VALUE;
    IssueSeveritiesProvider severitiesProvider = serviceProvider.get(IssueSeveritiesProvider.class);
    Severity severity = severitiesProvider.getIssueSeverities(new ResourceImpl(resourceURI)).getSeverity(COPY_JAVA_PROBLEMS_ISSUECODE);
    switch(severity) {
        case WARNING:
            return IMarker.SEVERITY_WARNING;
        case ERROR:
            return IMarker.SEVERITY_ERROR;
        case INFO:
        case IGNORE:
            return Integer.MAX_VALUE;
        default:
            break;
    }
    return Integer.MAX_VALUE;
}
Also used : IResourceServiceProvider(org.eclipse.xtext.resource.IResourceServiceProvider) ResourceImpl(org.eclipse.emf.ecore.resource.impl.ResourceImpl) IssueSeveritiesProvider(org.eclipse.xtext.validation.IssueSeveritiesProvider) Severity(org.eclipse.xtext.diagnostics.Severity) URI(org.eclipse.emf.common.util.URI) SourceRelativeURI(org.eclipse.xtext.generator.trace.SourceRelativeURI)

Aggregations

URI (org.eclipse.emf.common.util.URI)1 ResourceImpl (org.eclipse.emf.ecore.resource.impl.ResourceImpl)1 Severity (org.eclipse.xtext.diagnostics.Severity)1 SourceRelativeURI (org.eclipse.xtext.generator.trace.SourceRelativeURI)1 IResourceServiceProvider (org.eclipse.xtext.resource.IResourceServiceProvider)1 IssueSeveritiesProvider (org.eclipse.xtext.validation.IssueSeveritiesProvider)1