Search in sources :

Example 1 with IMirror

use of org.eclipse.xtext.common.types.access.IMirror 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 IMirror

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

the class JdtTypeProvider method createResource.

private TypeResource createResource(URI resourceURI, IType type) {
    TypeResource resource = doCreateResource(resourceURI);
    getResourceSet().getResources().add(resource);
    if (type.exists()) {
        IMirror mirror = createMirror(type);
        resource.setMirror(mirror);
    }
    return resource;
}
Also used : IMirror(org.eclipse.xtext.common.types.access.IMirror) TypeResource(org.eclipse.xtext.common.types.access.TypeResource)

Example 3 with IMirror

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

the class JdtTypeProviderTest method testCreateMirror_01.

@Test
public void testCreateMirror_01() {
    URI uri = URI.createURI("java:/Objects/java.util.Map");
    IMirror mirror = typeProvider.createMirror(uri);
    assertNotNull(mirror);
    assertTrue(mirror instanceof JdtTypeMirror);
    assertEquals("java.util.Map", ((JdtTypeMirror) mirror).getMirroredType().getFullyQualifiedName());
}
Also used : IMirror(org.eclipse.xtext.common.types.access.IMirror) URI(org.eclipse.emf.common.util.URI) Test(org.junit.Test)

Example 4 with IMirror

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

the class JdtTypeProviderTest method testCreateMirror_02.

@Test
public void testCreateMirror_02() {
    URI uri = URI.createURI("java:/Primitives");
    IMirror mirror = typeProvider.createMirror(uri);
    assertNotNull(mirror);
    assertTrue(mirror instanceof PrimitiveMirror);
}
Also used : IMirror(org.eclipse.xtext.common.types.access.IMirror) PrimitiveMirror(org.eclipse.xtext.common.types.access.impl.PrimitiveMirror) URI(org.eclipse.emf.common.util.URI) Test(org.junit.Test)

Aggregations

IMirror (org.eclipse.xtext.common.types.access.IMirror)4 URI (org.eclipse.emf.common.util.URI)3 TypeResource (org.eclipse.xtext.common.types.access.TypeResource)2 Test (org.junit.Test)2 IResource (org.eclipse.core.resources.IResource)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 JavaModelException (org.eclipse.jdt.core.JavaModelException)1 IndexedJvmTypeAccess (org.eclipse.xtext.common.types.access.impl.IndexedJvmTypeAccess)1 PrimitiveMirror (org.eclipse.xtext.common.types.access.impl.PrimitiveMirror)1