org.eclipse.xtext.ui.validation.IResourceUIValidatorExtension Java Examples

The following examples show how to use org.eclipse.xtext.ui.validation.IResourceUIValidatorExtension. 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: N4JSUiModule.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Bind the {@link IResourceUIValidatorExtension}.
 */
public Class<? extends IResourceUIValidatorExtension> bindIResourceUIValidatorExtension() {
	return ResourceUIValidatorExtension.class;
}
 
Example #2
Source File: MarkerUpdaterImpl.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
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())) {
				// if the file is found via the source attachment of a classpath entry, which happens
				//  in case of running a test IDE with bundles from the workspace of the development IDE
				//  (the workspace bundles' bin folder is linked to the classpath of bundles in the test IDE),
				// 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);
				}
			}
		}
	}
}
 
Example #3
Source File: GamlMarkerUpdater.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void updateMarkers(final Delta delta, final ResourceSet resourceSet, final IProgressMonitor monitor)
		throws OperationCanceledException {

	final URI uri = delta.getUri();
	final IResourceUIValidatorExtension validatorExtension = getResourceUIValidatorExtension(uri);
	final IMarkerContributor markerContributor = getMarkerContributor(uri);
	final CheckMode normalAndFastMode = CheckMode.NORMAL_AND_FAST;

	for (final Pair<IStorage, IProject> pair : mapper.getStorages(uri)) {
		if (monitor.isCanceled()) { throw new OperationCanceledException(); }
		if (pair.getFirst() instanceof IFile) {
			final IFile file = (IFile) pair.getFirst();

			if (delta.getNew() != null) {
				if (resourceSet == null) { throw new IllegalArgumentException(
						"resourceSet may not be null for changed resources."); }

				final Resource resource = resourceSet.getResource(uri, true);

				if (validatorExtension != null) {
					validatorExtension.updateValidationMarkers(file, resource, normalAndFastMode, monitor);
				}
				if (markerContributor != null) {
					markerContributor.updateMarkers(file, resource, monitor);
				}
				// GAMA.getGui().getMetaDataProvider().storeMetadata(file,
				// info.getInfo(resource, file.getModificationStamp()),
				// true);
			} 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);
				}
			}
		}
	}

}
 
Example #4
Source File: MarkerUpdaterImpl.java    From xtext-eclipse with Eclipse Public License 2.0 3 votes vote down vote up
/**
 * Searches for a {@link IResourceUIValidatorExtension} implementation in
 * {@link org.eclipse.xtext.resource.IResourceServiceProvider.Registry}<br>
 * 
 * @return {@link IResourceUIValidatorExtension} for the given {@link URI} or <code>null</code> if not found.
 * @see org.eclipse.xtext.resource.IResourceServiceProvider.Registry#getResourceServiceProvider(URI)
 * @see IResourceServiceProvider#get(Class)
 */
protected IResourceUIValidatorExtension getResourceUIValidatorExtension(URI uri) {
	IResourceServiceProvider provider = resourceServiceProviderRegistry.getResourceServiceProvider(uri);
	if (provider != null) {
		return provider.get(IResourceUIValidatorExtension.class);
	}
	return null;
}