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")));
}
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));
}
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()));
}
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()));
}
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));
}
Aggregations