Search in sources :

Example 1 with IMarkerContributor

use of org.eclipse.xtext.ui.markers.IMarkerContributor in project xtext-eclipse by eclipse.

the class MarkerUpdaterImpl method processDelta.

private void processDelta(Delta delta, /* @Nullable */
ResourceSet resourceSet, IProgressMonitor monitor) throws OperationCanceledException {
    URI uri = delta.getUri();
    IResourceUIValidatorExtension validatorExtension = getResourceUIValidatorExtension(uri);
    IMarkerContributor markerContributor = getMarkerContributor(uri);
    CheckMode normalAndFastMode = CheckMode.NORMAL_AND_FAST;
    for (Pair<IStorage, IProject> pair : mapper.getStorages(uri)) {
        if (monitor.isCanceled()) {
            throw new OperationCanceledException();
        }
        if (pair.getFirst() instanceof IFile) {
            IFile file = (IFile) pair.getFirst();
            if (EXTERNAL_PROJECT_NAME.equals(file.getProject().getName())) {
                // skip the marker processing of that file, as the user can't react on any markers anyway.
                continue;
            }
            if (delta.getNew() != null) {
                if (resourceSet == null)
                    throw new IllegalArgumentException("resourceSet may not be null for changed resources.");
                Resource resource = resourceSet.getResource(uri, true);
                if (validatorExtension != null) {
                    validatorExtension.updateValidationMarkers(file, resource, normalAndFastMode, monitor);
                }
                if (markerContributor != null) {
                    markerContributor.updateMarkers(file, resource, monitor);
                }
            } else {
                if (validatorExtension != null) {
                    validatorExtension.deleteValidationMarkers(file, normalAndFastMode, monitor);
                } else {
                    deleteAllValidationMarker(file, normalAndFastMode, monitor);
                }
                if (markerContributor != null) {
                    markerContributor.deleteMarkers(file, monitor);
                } else {
                    deleteAllContributedMarkers(file, monitor);
                }
            }
        }
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) IMarkerContributor(org.eclipse.xtext.ui.markers.IMarkerContributor) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) IResource(org.eclipse.core.resources.IResource) Resource(org.eclipse.emf.ecore.resource.Resource) CheckMode(org.eclipse.xtext.validation.CheckMode) IResourceUIValidatorExtension(org.eclipse.xtext.ui.validation.IResourceUIValidatorExtension) IStorage(org.eclipse.core.resources.IStorage) URI(org.eclipse.emf.common.util.URI) IProject(org.eclipse.core.resources.IProject)

Aggregations

IFile (org.eclipse.core.resources.IFile)1 IProject (org.eclipse.core.resources.IProject)1 IResource (org.eclipse.core.resources.IResource)1 IStorage (org.eclipse.core.resources.IStorage)1 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)1 URI (org.eclipse.emf.common.util.URI)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 IMarkerContributor (org.eclipse.xtext.ui.markers.IMarkerContributor)1 IResourceUIValidatorExtension (org.eclipse.xtext.ui.validation.IResourceUIValidatorExtension)1 CheckMode (org.eclipse.xtext.validation.CheckMode)1