Search in sources :

Example 1 with IScopeProvider

use of org.eclipse.xtext.scoping.IScopeProvider in project xtext-core by eclipse.

the class URINormalizationTest method testGetElementByClasspathURIEObject.

@Test
public void testGetElementByClasspathURIEObject() throws Exception {
    with(ImportUriTestLanguageStandaloneSetup.class);
    Main main = (Main) getModel("import 'classpath:/org/eclipse/xtext/linking/05.importuritestlanguage'\n" + "type Bar extends Foo");
    Type bar = main.getTypes().get(0);
    Type foo = bar.getExtends();
    assertNotNull(foo);
    assertFalse(foo.eIsProxy());
    // they are partially normalized
    if (Platform.isRunning()) {
        assertEquals("bundleresource", EcoreUtil.getURI(foo).scheme());
    } else {
        assertEquals("file", EcoreUtil.getURI(foo).scheme());
    }
    IScopeProvider scopeProvider = get(IScopeProvider.class);
    IScope scope = scopeProvider.getScope(bar, ImportedURIPackage.Literals.TYPE__EXTENDS);
    Iterable<IEObjectDescription> elements = scope.getElements(foo);
    assertEquals(1, size(elements));
    assertEquals(EcoreUtil2.getPlatformResourceOrNormalizedURI(foo), elements.iterator().next().getEObjectURI());
}
Also used : Type(org.eclipse.xtext.linking.importedURI.Type) IScopeProvider(org.eclipse.xtext.scoping.IScopeProvider) IScope(org.eclipse.xtext.scoping.IScope) Main(org.eclipse.xtext.linking.importedURI.Main) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription) Test(org.junit.Test)

Aggregations

Main (org.eclipse.xtext.linking.importedURI.Main)1 Type (org.eclipse.xtext.linking.importedURI.Type)1 IEObjectDescription (org.eclipse.xtext.resource.IEObjectDescription)1 IScope (org.eclipse.xtext.scoping.IScope)1 IScopeProvider (org.eclipse.xtext.scoping.IScopeProvider)1 Test (org.junit.Test)1