Search in sources :

Example 51 with QualifiedName

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

the class ResourceSetBasedResourceDescriptionsTest method testOneElement_Match.

@Test
public void testOneElement_Match() {
    QualifiedName qualifiedName = QualifiedName.create("SomeName");
    EClass type = EcorePackage.Literals.EPACKAGE;
    Resource resource = createResource();
    ENamedElement element = createNamedElement(qualifiedName, type, resource);
    Iterable<IEObjectDescription> iterable = container.getExportedObjectsByType(EcorePackage.Literals.EPACKAGE);
    assertSame(element, Iterables.getOnlyElement(iterable).getEObjectOrProxy());
    iterable = container.getExportedObjectsByType(EcorePackage.Literals.EOBJECT);
    assertSame(element, Iterables.getOnlyElement(iterable).getEObjectOrProxy());
    iterable = container.getExportedObjects(EcorePackage.Literals.EPACKAGE, qualifiedName, false);
    assertSame(element, Iterables.getOnlyElement(iterable).getEObjectOrProxy());
    iterable = container.getExportedObjects(EcorePackage.Literals.ENAMED_ELEMENT, qualifiedName, false);
    assertSame(element, Iterables.getOnlyElement(iterable).getEObjectOrProxy());
    iterable = container.getExportedObjects(EcorePackage.Literals.EOBJECT, qualifiedName, false);
    assertSame(element, Iterables.getOnlyElement(iterable).getEObjectOrProxy());
}
Also used : EClass(org.eclipse.emf.ecore.EClass) QualifiedName(org.eclipse.xtext.naming.QualifiedName) ENamedElement(org.eclipse.emf.ecore.ENamedElement) Resource(org.eclipse.emf.ecore.resource.Resource) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription) Test(org.junit.Test)

Example 52 with QualifiedName

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

the class ScopeTest method testContentByName_existent.

@Test
public void testContentByName_existent() throws Exception {
    QualifiedName qualifiedName = QualifiedName.create(EcorePackage.eINSTANCE.getEAnnotation().getName());
    assertEquals(qualifiedName, scope.getSingleElement(qualifiedName).getName());
}
Also used : QualifiedName(org.eclipse.xtext.naming.QualifiedName) Test(org.junit.Test)

Example 53 with QualifiedName

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

the class ImportNormalizerTest method testDeresolve.

@Test
public void testDeresolve() throws Exception {
    QualifiedName namespace = QualifiedName.create("org", "eclipse", "xtext");
    QualifiedName xtextFQN = namespace.append("Xtext");
    QualifiedName ytextFQN = namespace.skipLast(1).append("ytext");
    QualifiedName xytextFQN = namespace.append("ytext");
    ImportNormalizer importNormalizer = new ImportNormalizer(xtextFQN, false, false);
    assertEquals(QualifiedName.create("Xtext"), importNormalizer.deresolve(xtextFQN));
    assertEquals(null, importNormalizer.deresolve(ytextFQN));
    assertEquals(null, importNormalizer.deresolve(xytextFQN));
    importNormalizer = new ImportNormalizer(xytextFQN, false, false);
    assertEquals(null, importNormalizer.deresolve(xtextFQN));
    assertEquals(null, importNormalizer.deresolve(ytextFQN));
    assertEquals(QualifiedName.create("ytext"), importNormalizer.deresolve(xytextFQN));
    ImportNormalizer wildCardImportNormalizer = new ImportNormalizer(namespace, true, false);
    assertEquals(QualifiedName.create("Xtext"), wildCardImportNormalizer.deresolve(xtextFQN));
    assertEquals(null, wildCardImportNormalizer.deresolve(ytextFQN));
    assertEquals(QualifiedName.create("ytext"), wildCardImportNormalizer.deresolve(xytextFQN));
}
Also used : QualifiedName(org.eclipse.xtext.naming.QualifiedName) Test(org.junit.Test)

Example 54 with QualifiedName

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

the class ImportNormalizerTest method testResolveIgnoreCase.

@Test
public void testResolveIgnoreCase() throws Exception {
    QualifiedName xtextRelativeName = QualifiedName.create("xtext");
    QualifiedName ytextRelativeName = QualifiedName.create("ytext");
    QualifiedName xytextRelativeName = QualifiedName.create("xtext", "ytext");
    QualifiedName namespace = QualifiedName.create("ORG", "ECLIPSE", "XTEXT");
    ImportNormalizer importNormalizer = new ImportNormalizer(namespace, false, true);
    assertEquals("ORG.ECLIPSE.xtext", importNormalizer.resolve(xtextRelativeName).toString());
    assertEquals(null, importNormalizer.resolve(ytextRelativeName));
    assertEquals(null, importNormalizer.resolve(xytextRelativeName));
    ImportNormalizer wildCardImportNormalizer = new ImportNormalizer(namespace, true, true);
    assertEquals(namespace.append(xtextRelativeName), wildCardImportNormalizer.resolve(xtextRelativeName));
    assertEquals(namespace.append(ytextRelativeName), wildCardImportNormalizer.resolve(ytextRelativeName));
    assertEquals(namespace.append(xytextRelativeName), wildCardImportNormalizer.resolve(xytextRelativeName));
    ImportNormalizer xtextImportNormalizer = new ImportNormalizer(QualifiedName.create("XTEXT"), false, true);
    assertEquals(xtextRelativeName, xtextImportNormalizer.resolve(xtextRelativeName));
}
Also used : QualifiedName(org.eclipse.xtext.naming.QualifiedName) Test(org.junit.Test)

Example 55 with QualifiedName

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

the class ImportNormalizerTest method testResolve.

@Test
public void testResolve() throws Exception {
    QualifiedName xtextRelativeName = QualifiedName.create("xtext");
    QualifiedName ytextRelativeName = QualifiedName.create("ytext");
    QualifiedName xytextRelativeName = QualifiedName.create("xtext", "ytext");
    QualifiedName namespace = QualifiedName.create("org", "eclipse", "xtext");
    ImportNormalizer importNormalizer = new ImportNormalizer(namespace, false, false);
    assertEquals(namespace, importNormalizer.resolve(xtextRelativeName));
    assertEquals(null, importNormalizer.resolve(ytextRelativeName));
    assertEquals(null, importNormalizer.resolve(xytextRelativeName));
    ImportNormalizer wildCardImportNormalizer = new ImportNormalizer(namespace, true, false);
    assertEquals(namespace.append(xtextRelativeName), wildCardImportNormalizer.resolve(xtextRelativeName));
    assertEquals(namespace.append(ytextRelativeName), wildCardImportNormalizer.resolve(ytextRelativeName));
    assertEquals(namespace.append(xytextRelativeName), wildCardImportNormalizer.resolve(xytextRelativeName));
    ImportNormalizer xtextImportNormalizer = new ImportNormalizer(xtextRelativeName, false, false);
    assertEquals(xtextRelativeName, xtextImportNormalizer.resolve(xtextRelativeName));
}
Also used : QualifiedName(org.eclipse.xtext.naming.QualifiedName) Test(org.junit.Test)

Aggregations

QualifiedName (org.eclipse.xtext.naming.QualifiedName)97 IEObjectDescription (org.eclipse.xtext.resource.IEObjectDescription)32 Test (org.junit.Test)31 EObject (org.eclipse.emf.ecore.EObject)27 IResourceDescription (org.eclipse.xtext.resource.IResourceDescription)16 EClass (org.eclipse.emf.ecore.EClass)12 Resource (org.eclipse.emf.ecore.resource.Resource)12 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)12 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)12 IScope (org.eclipse.xtext.scoping.IScope)10 Set (java.util.Set)9 URI (org.eclipse.emf.common.util.URI)7 XtextResource (org.eclipse.xtext.resource.XtextResource)7 StringInputStream (org.eclipse.xtext.util.StringInputStream)7 JvmType (org.eclipse.xtext.common.types.JvmType)6 Function (com.google.common.base.Function)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4 InternalEObject (org.eclipse.emf.ecore.InternalEObject)4 JvmDeclaredType (org.eclipse.xtext.common.types.JvmDeclaredType)4