Java Code Examples for org.eclipse.xtext.resource.IResourceServiceProvider#canHandle()

The following examples show how to use org.eclipse.xtext.resource.IResourceServiceProvider#canHandle() . 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: UriValidator.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * @since 2.4
 */
public boolean canBuild(URI uri, IStorage storage) {
	if (uri == null)
		return false;
	IResourceServiceProvider resourceServiceProvider = registry.getResourceServiceProvider(uri);
	if (resourceServiceProvider != null) {
		if (resourceServiceProvider instanceof IResourceUIServiceProviderExtension) {
			return ((IResourceUIServiceProviderExtension) resourceServiceProvider).canBuild(uri, storage);
		} else if (resourceServiceProvider instanceof IResourceUIServiceProvider) {
			return ((IResourceUIServiceProvider) resourceServiceProvider).canHandle(uri, storage);
		} else {
			return resourceServiceProvider.canHandle(uri);
		}
	}
	return false;
}
 
Example 2
Source File: XBuildContext.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Return true, if the given can be handled by any available language.
 */
protected boolean canHandle(URI uri) {
	IResourceServiceProvider resourceServiceProvider = getResourceServiceProvider(uri);
	if ((resourceServiceProvider == null)) {
		return false;
	}
	return resourceServiceProvider.canHandle(uri);
}
 
Example 3
Source File: UriValidator.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public boolean isValid(URI uri, IStorage storage) {
	if (uri==null)
		return false;
	IResourceServiceProvider resourceServiceProvider = registry.getResourceServiceProvider(uri);
	if (resourceServiceProvider!=null) {
		if (resourceServiceProvider instanceof IResourceUIServiceProvider) {
			return ((IResourceUIServiceProvider) resourceServiceProvider).canHandle(uri, storage);
		} else {
			return resourceServiceProvider.canHandle(uri);
		}
	}
	return false;
}
 
Example 4
Source File: BuildContext.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Return true, if the given URI can be handled by an available language.
 */
protected boolean canHandle(URI uri) {
	IResourceServiceProvider resourceServiceProvider = getResourceServiceProvider(uri);
	if (resourceServiceProvider == null) {
		return false;
	}
	return resourceServiceProvider.canHandle(uri);
}
 
Example 5
Source File: ConditionalBuilderParticipant.java    From dsl-devkit with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Checks whether a file described by given delta has a correct extension to be handled by concrete BuilderParticipan.
 * 
 * @param delta
 *          structure corresponding to the changed file
 * @param resourceServiceProvider
 *          used to check whether BuilderParticipant containing this {@link IResourceServiceProvider} should be called for given {@link Delta}
 * @return true if file associated with given delta has extension that should be handled by participant owning given {@link IResourceServiceProvider}
 */
public boolean hasCorrectExtension(final Delta delta, final IResourceServiceProvider resourceServiceProvider) {
  return resourceServiceProvider.canHandle(delta.getUri());
}