Search in sources :

Example 31 with IEObjectDescription

use of org.eclipse.xtext.resource.IEObjectDescription in project xtext-eclipse by eclipse.

the class AbstractConstructorScopeTest method testGetElementsByInstance_04.

@Test
public void testGetElementsByInstance_04() {
    QualifiedName qualifiedName = QualifiedName.create("java", "util", "Hashtable", "Entry");
    IEObjectDescription hashMapEntry = getConstructorScope().getSingleElement(qualifiedName);
    JvmConstructor constructor = (JvmConstructor) hashMapEntry.getEObjectOrProxy();
    Iterable<IEObjectDescription> descriptions = getConstructorScope().getElements(constructor);
    List<IEObjectDescription> list = Lists.newArrayList(descriptions);
    assertEquals(2, list.size());
    assertEquals(qualifiedName, list.get(0).getName());
    QualifiedName qualifiedNameWithDollar = QualifiedName.create("java", "util", "Hashtable$Entry");
    assertEquals(qualifiedNameWithDollar, list.get(1).getName());
}
Also used : QualifiedName(org.eclipse.xtext.naming.QualifiedName) JvmConstructor(org.eclipse.xtext.common.types.JvmConstructor) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription) Test(org.junit.Test)

Example 32 with IEObjectDescription

use of org.eclipse.xtext.resource.IEObjectDescription in project xtext-eclipse by eclipse.

the class AbstractConstructorScopeTest method testGetElementByInstance_04.

@Test
public void testGetElementByInstance_04() {
    QualifiedName qualifiedName = QualifiedName.create("java", "util", "Hashtable", "Entry");
    IEObjectDescription hashMapEntry = getConstructorScope().getSingleElement(qualifiedName);
    JvmConstructor constructor = (JvmConstructor) hashMapEntry.getEObjectOrProxy();
    IEObjectDescription element = getConstructorScope().getSingleElement(constructor);
    assertNotNull(element);
    assertEquals(qualifiedName, element.getName());
}
Also used : QualifiedName(org.eclipse.xtext.naming.QualifiedName) JvmConstructor(org.eclipse.xtext.common.types.JvmConstructor) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription) Test(org.junit.Test)

Example 33 with IEObjectDescription

use of org.eclipse.xtext.resource.IEObjectDescription in project xtext-eclipse by eclipse.

the class AbstractTypeScopeTest method testGetElementsByInstance_01.

@Test
public void testGetElementsByInstance_01() {
    IEObjectDescription mapEntryDescription = getTypeScope().getSingleElement(QualifiedName.create("java", "util", "Map$Entry"));
    EObject mapEntry = mapEntryDescription.getEObjectOrProxy();
    Iterable<IEObjectDescription> lookupDescriptions = getTypeScope().getElements(mapEntry);
    List<IEObjectDescription> list = Lists.newArrayList(lookupDescriptions);
    assertEquals(2, list.size());
    assertEquals(QualifiedName.create("java", "util", "Map", "Entry"), list.get(0).getName());
    assertEquals(QualifiedName.create("java", "util", "Map$Entry"), list.get(1).getName());
}
Also used : EObject(org.eclipse.emf.ecore.EObject) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription) Test(org.junit.Test)

Example 34 with IEObjectDescription

use of org.eclipse.xtext.resource.IEObjectDescription in project xtext-eclipse by eclipse.

the class AbstractTypeScopeTest method testGetElementByInstance_02.

@Test
public void testGetElementByInstance_02() {
    JvmAnnotationReference annotationReference = TypesFactory.eINSTANCE.createJvmAnnotationReference();
    IEObjectDescription element = getTypeScope().getSingleElement(annotationReference);
    assertNull(element);
}
Also used : JvmAnnotationReference(org.eclipse.xtext.common.types.JvmAnnotationReference) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription) Test(org.junit.Test)

Example 35 with IEObjectDescription

use of org.eclipse.xtext.resource.IEObjectDescription in project xtext-eclipse by eclipse.

the class AbstractTypeScopeTest method testGetElementByInstance_03.

@Test
public void testGetElementByInstance_03() {
    IEObjectDescription mapEntryDescription = getTypeScope().getSingleElement(QualifiedName.create("java", "util", "Map$Entry"));
    EObject mapEntry = mapEntryDescription.getEObjectOrProxy();
    IEObjectDescription lookupDescription = getTypeScope().getSingleElement(mapEntry);
    assertNotNull(lookupDescription);
    assertEquals(QualifiedName.create("java", "util", "Map", "Entry"), lookupDescription.getName());
}
Also used : EObject(org.eclipse.emf.ecore.EObject) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription) Test(org.junit.Test)

Aggregations

IEObjectDescription (org.eclipse.xtext.resource.IEObjectDescription)324 Test (org.junit.Test)95 EObject (org.eclipse.emf.ecore.EObject)82 QualifiedName (org.eclipse.xtext.naming.QualifiedName)79 IScope (org.eclipse.xtext.scoping.IScope)56 URI (org.eclipse.emf.common.util.URI)41 IResourceDescription (org.eclipse.xtext.resource.IResourceDescription)33 EClass (org.eclipse.emf.ecore.EClass)30 Resource (org.eclipse.emf.ecore.resource.Resource)28 EObjectDescription (org.eclipse.xtext.resource.EObjectDescription)22 AliasedEObjectDescription (org.eclipse.xtext.resource.impl.AliasedEObjectDescription)22 ArrayList (java.util.ArrayList)19 IResourceDescriptions (org.eclipse.xtext.resource.IResourceDescriptions)14 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)12 ICompletionProposal (org.eclipse.jface.text.contentassist.ICompletionProposal)12 StyledString (org.eclipse.jface.viewers.StyledString)12 XtextResource (org.eclipse.xtext.resource.XtextResource)11 StringInputStream (org.eclipse.xtext.util.StringInputStream)11 EReference (org.eclipse.emf.ecore.EReference)10 List (java.util.List)9