org.eclipse.xtext.common.types.access.impl.IndexedJvmTypeAccess Java Examples

The following examples show how to use org.eclipse.xtext.common.types.access.impl.IndexedJvmTypeAccess. 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: JdtTypeProvider.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * @since 2.9
 */
protected boolean canLink(IType type) throws JavaModelException {
	IndexedJvmTypeAccess indexedJvmTypeAccess = this.getIndexedJvmTypeAccess();
	if (indexedJvmTypeAccess != null && indexedJvmTypeAccess.isIndexingPhase(getResourceSet())) {
		IResource underlyingResource = type.getUnderlyingResource();
		if (underlyingResource == null) {
			return true;
		}
		for (IPackageFragmentRoot root : javaProject.getPackageFragmentRoots()) {
			if (root.getKind() == IPackageFragmentRoot.K_SOURCE) {
				IResource srcUnderlyingResource = root.getUnderlyingResource();
				if (srcUnderlyingResource != null && srcUnderlyingResource.contains(underlyingResource)) {
					return false;
				}
			}
		}
		return true;
	}
	return true;
}
 
Example #2
Source File: JdtTypeProvider.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
private boolean canLink(JvmType type) {
	Resource resource = type.eResource();
	if (resource instanceof TypeResource) {
		IMirror mirror = ((TypeResource) resource).getMirror();
		if (mirror instanceof JdtTypeMirror) {
			try {
				return canLink(((JdtTypeMirror) mirror).getMirroredType());
			} catch (JavaModelException e) {
				return false;
			}
		} else {
			return true;
		}
	}
	URI resourceURI = resource.getURI();
	if (resourceURI.isPlatformResource() && resourceURI.segment(1).equals(javaProject.getProject().getName())) {
		IndexedJvmTypeAccess indexedJvmTypeAccess = this.getIndexedJvmTypeAccess();
		if (indexedJvmTypeAccess != null && indexedJvmTypeAccess.isIndexingPhase(getResourceSet())) {
			return false;
		}
	}
	return true;
}
 
Example #3
Source File: JavaResource.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
public IndexedJvmTypeAccess getIndexJvmTypeAccess() {
	if (indexedJvmTypeAccess == null) {
		Object provider = resourceSet.getResourceFactoryRegistry().getProtocolToFactoryMap()
				.get(URIHelperConstants.PROTOCOL);
		if (provider instanceof AbstractJvmTypeProvider) {
			indexedJvmTypeAccess = ((AbstractJvmTypeProvider) provider).getIndexedJvmTypeAccess();
		}
	}
	return indexedJvmTypeAccess;
}
 
Example #4
Source File: JdtTypeProvider.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
private JvmType findObjectTypeInIndex(/* @NonNull */ String signature, /* @NonNull */ URI resourceURI) throws UnknownNestedTypeException {
	IndexedJvmTypeAccess indexedJvmTypeAccess = getIndexedJvmTypeAccess();
	if (indexedJvmTypeAccess != null) {
		URI proxyURI = resourceURI.appendFragment(typeUriHelper.getFragment(signature));
		EObject candidate = indexedJvmTypeAccess.getIndexedJvmType(proxyURI, getResourceSet(), true);
		if (candidate instanceof JvmType) {
			return (JvmType) candidate;
		}
	}
	return null;
}
 
Example #5
Source File: JdtTypeProvider.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @since 2.8
 * @noreference This constructor is not intended to be referenced by clients.
 */
public JdtTypeProvider(IJavaProject javaProject, ResourceSet resourceSet,
		IndexedJvmTypeAccess indexedJvmTypeAccess, WorkingCopyOwner workingCopyOwner, TypeResourceServices services) {
	super(resourceSet, indexedJvmTypeAccess, services);
	if (javaProject == null)
		throw new IllegalArgumentException("javaProject may not be null");
	this.javaProject = javaProject;
	this.typeUriHelper = createTypeURIHelper();
	this.workingCopyOwner = workingCopyOwner;
	this.typeFactory = createTypeFactory();
}
 
Example #6
Source File: ReflectionTypeProvider.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
private JvmType findTypeByClass(Class<?> clazz) throws UnknownNestedTypeException {
	IndexedJvmTypeAccess indexedJvmTypeAccess = getIndexedJvmTypeAccess();
	URI resourceURI = uriHelper.createResourceURI(clazz);
	if (indexedJvmTypeAccess != null) {
		URI proxyURI = resourceURI.appendFragment(uriHelper.getFragment(clazz));
		EObject candidate = indexedJvmTypeAccess.getIndexedJvmType(proxyURI, getResourceSet());
		if (candidate instanceof JvmType)
			return (JvmType) candidate;
	}
	TypeResource result = (TypeResource) getResourceSet().getResource(resourceURI, true);
	return findTypeByClass(clazz, result);
}
 
Example #7
Source File: AbstractTypeProviderFactory.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
protected IndexedJvmTypeAccess getIndexedJvmTypeAccess() {
	return indexedJvmTypeAccess;
}
 
Example #8
Source File: JdtTypeProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * @since 2.4
 * @noreference This constructor is not intended to be referenced by clients.
 */
@Deprecated
public JdtTypeProvider(IJavaProject javaProject, ResourceSet resourceSet,
		IndexedJvmTypeAccess indexedJvmTypeAccess, WorkingCopyOwner workingCopyOwner) {
	this(javaProject, resourceSet, indexedJvmTypeAccess, workingCopyOwner, null);
}
 
Example #9
Source File: SharedStateModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected void configure() {
	bind(ResourceDescriptionsProvider.class).to(ProjectAwareResourceDescriptionsProvider.class).in(Scopes.SINGLETON);
	bind(IndexedJvmTypeAccess.class).to(JdtIndexedJvmTypeAccess.class);
}
 
Example #10
Source File: StandaloneBuilder.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
protected void installTypeProvider(Iterable<String> classPathRoots, XtextResourceSet resSet,
		IndexedJvmTypeAccess typeAccess) {
	URLClassLoader classLoader = createURLClassLoader(classPathRoots);
	new ClasspathTypeProvider(classLoader, resSet, typeAccess, null);
	resSet.setClasspathURIContext(classLoader);
}
 
Example #11
Source File: TypeResource.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
public void setIndexedJvmTypeAccess(IndexedJvmTypeAccess indexedJvmTypeAccess) {
	this.indexedJvmTypeAccess = indexedJvmTypeAccess;
}
 
Example #12
Source File: TypeResource.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
public IndexedJvmTypeAccess getIndexedJvmTypeAccess() {
	return indexedJvmTypeAccess;
}
 
Example #13
Source File: ReflectionTypeProvider.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
public ReflectionTypeProvider(ClassLoader classLoader, ResourceSet resourceSet, IndexedJvmTypeAccess indexedJvmTypeAccess, TypeResourceServices services) {
	super(resourceSet, indexedJvmTypeAccess, services);
	classFinder = createClassFinder(classLoader);
	uriHelper = createClassURIHelper();
	reflectionTypeFactory = createDeclaredTypeFactory();
}
 
Example #14
Source File: ReflectionTypeProvider.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Deprecated
public ReflectionTypeProvider(ClassLoader classLoader, ResourceSet resourceSet, IndexedJvmTypeAccess indexedJvmTypeAccess) {
	this(classLoader, resourceSet, indexedJvmTypeAccess, null);
}
 
Example #15
Source File: CachingReflectionTypeProvider.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
public CachingReflectionTypeProvider(ClassLoader classLoader, ResourceSet resourceSet,
		IndexedJvmTypeAccess indexedJvmTypeAccess, ReflectionTypeFactory reusedFactory, TypeResourceServices services) {
	super(classLoader, resourceSet, indexedJvmTypeAccess, services);
	this.reusedFactory = reusedFactory;
}
 
Example #16
Source File: CachingReflectionTypeProvider.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Deprecated
public CachingReflectionTypeProvider(ClassLoader classLoader, ResourceSet resourceSet,
		IndexedJvmTypeAccess indexedJvmTypeAccess, ReflectionTypeFactory reusedFactory) {
	this(classLoader, resourceSet, indexedJvmTypeAccess, reusedFactory, null);
}
 
Example #17
Source File: JdtFallbackTypeProviderFactory.java    From dsl-devkit with Eclipse Public License 1.0 3 votes vote down vote up
/**
 * Creates a new instance of {@link JdtFallbackTypeProviderFactory}.
 * 
 * @param javaProjectProvider
 *          the {@link IJavaProjectProvider}, may be {@code null}
 * @param classLoader
 *          the {@link ClassLoader}, must not be {@code null}
 * @param indexedJvmTypeAccess
 *          the {@link IndexedJvmTypeAccess}, may be {@code null}
 */
@Inject
public JdtFallbackTypeProviderFactory(final IJavaProjectProvider javaProjectProvider, final ClassLoader classLoader, final IndexedJvmTypeAccess indexedJvmTypeAccess, final TypeResourceServices typeResourceServices) {
  super(javaProjectProvider);
  this.classLoader = classLoader;
  this.indexedJvmTypeAccess = indexedJvmTypeAccess;
  this.typeResourceServices = typeResourceServices;
}
 
Example #18
Source File: JdtTypeProvider.java    From xtext-eclipse with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * @since 2.1
 * @noreference This constructor is not intended to be referenced by clients.
 */
public JdtTypeProvider(IJavaProject javaProject, ResourceSet resourceSet, IndexedJvmTypeAccess indexedJvmTypeAccess) {
	this(javaProject, resourceSet, indexedJvmTypeAccess, null);
}
 
Example #19
Source File: BundleAwareTypeProvider.java    From dsl-devkit with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Creates a new instance of {@link BundleAwareTypeProvider}.
 * 
 * @param classLoader
 *          the {@link ClassLoader}, may be {@code null}
 * @param resourceSet
 *          the {@link ResourceSet}, must not be {@code null}
 * @param indexedJvmTypeAccess
 *          the {@link IndexedJvmTypeAccess}, may be {@code null}
 */
public BundleAwareTypeProvider(final ClassLoader classLoader, final ResourceSet resourceSet, final IndexedJvmTypeAccess indexedJvmTypeAccess, final TypeResourceServices typeResourceServices) {
  super(classLoader, resourceSet, indexedJvmTypeAccess, typeResourceServices);
}