Search in sources :

Example 41 with IScope

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

the class ImportedNamespaceAwareLocalScopeProviderTest method testRelativePath.

@Test
public void testRelativePath() throws Exception {
    final XtextResource resource = getResource(new StringInputStream("stuff { " + "  import baz.*" + "  baz { " + "    datatype String " + "  } " + "  entity Person {" + "  }" + "}"), URI.createURI("relative.indextestlanguage"));
    Iterable<EObject> allContents = new Iterable<EObject>() {

        @Override
        public Iterator<EObject> iterator() {
            return resource.getAllContents();
        }
    };
    Entity entity = filter(allContents, Entity.class).iterator().next();
    IScope scope = scopeProvider.getScope(entity, IndexTestLanguagePackage.eINSTANCE.getProperty_Type());
    assertNotNull(scope.getSingleElement(nameConverter.toQualifiedName("String")));
    assertNotNull(scope.getSingleElement(nameConverter.toQualifiedName("baz.String")));
    assertNotNull(scope.getSingleElement(nameConverter.toQualifiedName("stuff.baz.String")));
}
Also used : Entity(org.eclipse.xtext.index.indexTestLanguage.Entity) StringInputStream(org.eclipse.xtext.util.StringInputStream) EObject(org.eclipse.emf.ecore.EObject) IScope(org.eclipse.xtext.scoping.IScope) XtextResource(org.eclipse.xtext.resource.XtextResource) Test(org.junit.Test)

Example 42 with IScope

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

the class AbstractScopeTest method testByObjectWithDuplicate_05.

@Test
public void testByObjectWithDuplicate_05() {
    IScope scope = createScope(IScope.NULLSCOPE, ImmutableList.of(descriptionA_aliased, descriptionA, descriptionB_as_A));
    assertEqualElements(ImmutableList.of(descriptionA_aliased, descriptionA), scope.getElements(annotationA));
    assertEqualElements(ImmutableList.of(), scope.getElements(annotationB));
}
Also used : IScope(org.eclipse.xtext.scoping.IScope) Test(org.junit.Test)

Example 43 with IScope

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

the class AbstractScopeTest method testByNameWithDuplicate_01.

@Test
public void testByNameWithDuplicate_01() {
    IScope scope = createScope(IScope.NULLSCOPE, ImmutableList.of(descriptionA, descriptionB_as_A, descriptionB));
    assertEqualElements(ImmutableList.of(descriptionA, descriptionB_as_A), scope.getElements(descriptionA.getName()));
    assertEqualElements(Collections.singleton(descriptionB), scope.getElements(descriptionB.getName()));
}
Also used : IScope(org.eclipse.xtext.scoping.IScope) Test(org.junit.Test)

Example 44 with IScope

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

the class AbstractScopeTest method testSingleByNameWithDuplicate.

@Test
public void testSingleByNameWithDuplicate() {
    IScope scope = createScope(IScope.NULLSCOPE, ImmutableList.of(descriptionA, descriptionB_as_A, descriptionB));
    assertSame(descriptionA, scope.getSingleElement(descriptionA.getName()));
    assertSame(descriptionB, scope.getSingleElement(descriptionB.getName()));
}
Also used : IScope(org.eclipse.xtext.scoping.IScope) Test(org.junit.Test)

Example 45 with IScope

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

the class AbstractScopeTest method testByObject.

@Test
public void testByObject() {
    IScope scope = createScope(IScope.NULLSCOPE, ImmutableList.of(descriptionA, descriptionB));
    assertEqualElements(ImmutableList.of(descriptionA), scope.getElements(annotationA));
    assertEqualElements(ImmutableList.of(descriptionB), scope.getElements(annotationB));
}
Also used : IScope(org.eclipse.xtext.scoping.IScope) Test(org.junit.Test)

Aggregations

IScope (org.eclipse.xtext.scoping.IScope)148 IEObjectDescription (org.eclipse.xtext.resource.IEObjectDescription)57 Test (org.junit.Test)53 EObject (org.eclipse.emf.ecore.EObject)43 QualifiedName (org.eclipse.xtext.naming.QualifiedName)26 XtextResource (org.eclipse.xtext.resource.XtextResource)19 EReference (org.eclipse.emf.ecore.EReference)17 EClass (org.eclipse.emf.ecore.EClass)15 StringInputStream (org.eclipse.xtext.util.StringInputStream)15 URI (org.eclipse.emf.common.util.URI)12 SimpleScope (org.eclipse.xtext.scoping.impl.SimpleScope)12 ArrayList (java.util.ArrayList)10 Entity (org.eclipse.xtext.index.indexTestLanguage.Entity)10 Resource (org.eclipse.emf.ecore.resource.Resource)9 AbstractScopingTest (com.avaloq.tools.ddk.xtext.test.scoping.AbstractScopingTest)8 JvmDeclaredType (org.eclipse.xtext.common.types.JvmDeclaredType)8 FilteringScope (org.eclipse.xtext.scoping.impl.FilteringScope)7 Predicate (com.google.common.base.Predicate)6 EClassifier (org.eclipse.emf.ecore.EClassifier)6 ICompletionProposal (org.eclipse.jface.text.contentassist.ICompletionProposal)6