Search in sources :

Example 11 with QualifiedName

use of org.eclipse.xtext.naming.QualifiedName in project xtext-eclipse by eclipse.

the class AbstractConstructorScopeTest method testGetElementsByName_03.

@Test
public void testGetElementsByName_03() {
    List<String> segments = Strings.split("org.eclipse.xtext.common.types.testSetups.NestedParameterizedTypes.WrappedCollection.WrappedIterator", '.');
    QualifiedName qualifiedName = QualifiedName.create(segments);
    Iterable<IEObjectDescription> descriptions = getConstructorScope().getElements(qualifiedName);
    for (IEObjectDescription description : descriptions) {
        assertEquals(qualifiedName, description.getName());
    }
    assertEquals(3, Iterables.size(descriptions));
}
Also used : QualifiedName(org.eclipse.xtext.naming.QualifiedName) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription) Test(org.junit.Test)

Example 12 with QualifiedName

use of org.eclipse.xtext.naming.QualifiedName 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 13 with QualifiedName

use of org.eclipse.xtext.naming.QualifiedName 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 14 with QualifiedName

use of org.eclipse.xtext.naming.QualifiedName in project xtext-eclipse by eclipse.

the class EObjectDescriptionBasedStubGeneratorTest method testNested.

@Test
public void testNested() {
    final EObjectDescription _top = new EObjectDescription(QualifiedName.create("foo", "Bar"), TypesFactory.eINSTANCE.createJvmGenericType(), Collections.<String, String>emptyMap());
    final EObjectDescription _nested0 = new EObjectDescription(QualifiedName.create("foo", "Bar$Baz0"), TypesFactory.eINSTANCE.createJvmGenericType(), Collections.singletonMap(JvmTypesResourceDescriptionStrategy.IS_NESTED_TYPE, Boolean.TRUE.toString()));
    final EObjectDescription _nested1 = new EObjectDescription(QualifiedName.create("foo", "Bar$Baz1"), TypesFactory.eINSTANCE.createJvmGenericType(), Collections.singletonMap(JvmTypesResourceDescriptionStrategy.IS_NESTED_TYPE, Boolean.TRUE.toString()));
    final EObjectDescription _nested10 = new EObjectDescription(QualifiedName.create("foo", "Bar$Baz1$FooBar0"), TypesFactory.eINSTANCE.createJvmGenericType(), Collections.singletonMap(JvmTypesResourceDescriptionStrategy.IS_NESTED_TYPE, Boolean.TRUE.toString()));
    final EObjectDescription _nested11 = new EObjectDescription(QualifiedName.create("foo", "Bar$Baz1$FooBar0"), TypesFactory.eINSTANCE.createJvmGenericType(), Collections.singletonMap(JvmTypesResourceDescriptionStrategy.IS_NESTED_TYPE, Boolean.TRUE.toString()));
    IResourceDescription resourceDescription = new AbstractResourceDescription() {

        @Override
        public URI getURI() {
            return null;
        }

        @Override
        public Iterable<IReferenceDescription> getReferenceDescriptions() {
            return Collections.emptyList();
        }

        @Override
        public Iterable<QualifiedName> getImportedNames() {
            return Collections.emptyList();
        }

        @Override
        protected List<IEObjectDescription> computeExportedObjects() {
            return Arrays.asList(new IEObjectDescription[] { _top, _nested0, _nested1, _nested10, _nested11 });
        }
    };
    assertEquals("package foo;\n" + "public class Bar{\n" + "public static class Baz0{\n" + "}\n" + "public static class Baz1{\n" + "public static class FooBar0{\n" + "}\n" + "public static class FooBar0{\n" + "}\n" + "}\n" + "}", gen.getJavaStubSource(_top, resourceDescription));
}
Also used : EObjectDescription(org.eclipse.xtext.resource.EObjectDescription) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription) IResourceDescription(org.eclipse.xtext.resource.IResourceDescription) AbstractResourceDescription(org.eclipse.xtext.resource.impl.AbstractResourceDescription) QualifiedName(org.eclipse.xtext.naming.QualifiedName) IReferenceDescription(org.eclipse.xtext.resource.IReferenceDescription) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription) Test(org.junit.Test)

Example 15 with QualifiedName

use of org.eclipse.xtext.naming.QualifiedName in project xtext-eclipse by eclipse.

the class BuilderStateFactoryImpl method convertQualifiedNameToString.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated NOT
 */
public String convertQualifiedNameToString(EDataType eDataType, Object instanceValue) {
    QualifiedName qn = (QualifiedName) instanceValue;
    String[] array = qn.getSegments().toArray(new String[qn.getSegmentCount()]);
    String packed = Strings.pack(array);
    if (packed == null)
        return "";
    return packed;
}
Also used : QualifiedName(org.eclipse.xtext.naming.QualifiedName)

Aggregations

QualifiedName (org.eclipse.xtext.naming.QualifiedName)215 IEObjectDescription (org.eclipse.xtext.resource.IEObjectDescription)78 EObject (org.eclipse.emf.ecore.EObject)46 Test (org.junit.Test)46 URI (org.eclipse.emf.common.util.URI)24 IResourceDescription (org.eclipse.xtext.resource.IResourceDescription)21 IScope (org.eclipse.xtext.scoping.IScope)21 EClass (org.eclipse.emf.ecore.EClass)18 Resource (org.eclipse.emf.ecore.resource.Resource)16 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)13 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)12 Set (java.util.Set)10 StyledString (org.eclipse.jface.viewers.StyledString)8 JvmType (org.eclipse.xtext.common.types.JvmType)8 XtextResource (org.eclipse.xtext.resource.XtextResource)8 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)7 Grammar (org.eclipse.xtext.Grammar)6 JvmDeclaredType (org.eclipse.xtext.common.types.JvmDeclaredType)6 HashMap (java.util.HashMap)5 InternalEObject (org.eclipse.emf.ecore.InternalEObject)5