Search in sources :

Example 1 with IndexedJvmTypeAccess

use of org.eclipse.xtext.common.types.access.impl.IndexedJvmTypeAccess in project xtext-eclipse by eclipse.

the class JdtTypeProvider method canLink.

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;
}
Also used : IMirror(org.eclipse.xtext.common.types.access.IMirror) TypeResource(org.eclipse.xtext.common.types.access.TypeResource) JavaModelException(org.eclipse.jdt.core.JavaModelException) IndexedJvmTypeAccess(org.eclipse.xtext.common.types.access.impl.IndexedJvmTypeAccess) Resource(org.eclipse.emf.ecore.resource.Resource) IResource(org.eclipse.core.resources.IResource) TypeResource(org.eclipse.xtext.common.types.access.TypeResource) URI(org.eclipse.emf.common.util.URI)

Example 2 with IndexedJvmTypeAccess

use of org.eclipse.xtext.common.types.access.impl.IndexedJvmTypeAccess in project xtext-eclipse by eclipse.

the class JdtTypeProvider method findObjectTypeInIndex.

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;
}
Also used : IndexedJvmTypeAccess(org.eclipse.xtext.common.types.access.impl.IndexedJvmTypeAccess) EObject(org.eclipse.emf.ecore.EObject) JvmType(org.eclipse.xtext.common.types.JvmType) URI(org.eclipse.emf.common.util.URI)

Aggregations

URI (org.eclipse.emf.common.util.URI)2 IndexedJvmTypeAccess (org.eclipse.xtext.common.types.access.impl.IndexedJvmTypeAccess)2 IResource (org.eclipse.core.resources.IResource)1 EObject (org.eclipse.emf.ecore.EObject)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 JavaModelException (org.eclipse.jdt.core.JavaModelException)1 JvmType (org.eclipse.xtext.common.types.JvmType)1 IMirror (org.eclipse.xtext.common.types.access.IMirror)1 TypeResource (org.eclipse.xtext.common.types.access.TypeResource)1