Search in sources :

Example 81 with IScope

use of org.eclipse.xtext.scoping.IScope in project dsl-devkit by dsldevkit.

the class ExportScopingTest method testEclassScope.

@Test
public void testEclassScope() throws IOException {
    ExportModel model = (ExportModel) getTestSource().getModel();
    IScope scope = scopeProvider.scope_EClass(model, null);
    assertNotNull("Could not locate EClass.", scope.getSingleElement(QualifiedName.create("InterfaceExpression")));
    assertNull("Located non-existent EClass.", scope.getSingleElement(QualifiedName.create("InterfaceExpressionX")));
}
Also used : ExportModel(com.avaloq.tools.ddk.xtext.export.export.ExportModel) IScope(org.eclipse.xtext.scoping.IScope) AbstractScopingTest(com.avaloq.tools.ddk.xtext.test.scoping.AbstractScopingTest) Test(org.junit.Test)

Example 82 with IScope

use of org.eclipse.xtext.scoping.IScope in project dsl-devkit by dsldevkit.

the class ExportScopingTest method testImportPackageScope.

@Test
public void testImportPackageScope() throws IOException {
    ExportModel model = (ExportModel) getTestSource().getModel();
    IScope scope = scopeProvider.scope_Import_package(model.getImports().get(0), ExportPackage.Literals.IMPORT__PACKAGE);
    assertNotNull("Could not locate Import.", scope.getSingleElement(QualifiedName.create("http://www.avaloq.com/tools/ddk/xtext/export/Export")));
    assertNull("Located non-existent Import.", scope.getSingleElement(QualifiedName.create("http://www.avaloq.com/tools/ddk/xtext/export/ExportX")));
}
Also used : ExportModel(com.avaloq.tools.ddk.xtext.export.export.ExportModel) IScope(org.eclipse.xtext.scoping.IScope) AbstractScopingTest(com.avaloq.tools.ddk.xtext.test.scoping.AbstractScopingTest) Test(org.junit.Test)

Example 83 with IScope

use of org.eclipse.xtext.scoping.IScope in project dsl-devkit by dsldevkit.

the class ExportScopingTest method testEAttributeScope.

@Test
public void testEAttributeScope() throws IOException {
    ExportModel model = (ExportModel) getTestSource().getModel();
    IScope scope = scopeProvider.scope_EAttribute(model.getInterfaces().get(0), null);
    // CHECKSTYLE:OFF (DuplicateString)
    assertNotNull("Could not locate EStructuralFeature.", scope.getSingleElement(QualifiedName.create("unordered")));
    assertNull("Located non-existent EStructuralFeature.", scope.getSingleElement(QualifiedName.create("expr")));
// CHECKSTYLE:ON
}
Also used : ExportModel(com.avaloq.tools.ddk.xtext.export.export.ExportModel) IScope(org.eclipse.xtext.scoping.IScope) AbstractScopingTest(com.avaloq.tools.ddk.xtext.test.scoping.AbstractScopingTest) Test(org.junit.Test)

Example 84 with IScope

use of org.eclipse.xtext.scoping.IScope in project dsl-devkit by dsldevkit.

the class ExportScopingTest method testInterfaceNavigationRefScope.

@Test
public void testInterfaceNavigationRefScope() throws IOException {
    ExportModel model = (ExportModel) getTestSource().getModel();
    IScope scope = scopeProvider.scope_InterfaceNavigation_ref(model.getInterfaces().get(0), null);
    // CHECKSTYLE:OFF (DuplicateString)
    assertNotNull("Could not locate InterfaceNavigationRef.", scope.getSingleElement(QualifiedName.create("expr")));
    assertNull("Located non-existent InterfaceNavigationRef.", scope.getSingleElement(QualifiedName.create("unordered")));
// CHECKSTYLE:ON
}
Also used : ExportModel(com.avaloq.tools.ddk.xtext.export.export.ExportModel) IScope(org.eclipse.xtext.scoping.IScope) AbstractScopingTest(com.avaloq.tools.ddk.xtext.test.scoping.AbstractScopingTest) Test(org.junit.Test)

Example 85 with IScope

use of org.eclipse.xtext.scoping.IScope in project dsl-devkit by dsldevkit.

the class ValidScopingTest method testEPackageScope.

/**
 * Tests that EPackage instances can be imported by means of their NS URI. If an NS URI to a non-existing EPackage is provided,
 * the scope provider will return <code>null</code> for such an import, i.e. will not locate it.
 */
@Test
public void testEPackageScope() throws IOException {
    final ValidModel model = (ValidModel) getTestSource().getModel();
    IScope scope = scopeProvider.getScope(model, ValidPackage.Literals.IMPORT__PACKAGE);
    final EPackage validScopingTestPackage = model.getImports().get(0).getPackage();
    assertEquals("NS URI of first import is valid", ValidscopingtestPackage.eNS_URI, validScopingTestPackage.getNsURI());
    final EPackage nonExistingPackage = model.getImports().get(1).getPackage();
    assertNull("Non-existing EPackage has no NS URI", nonExistingPackage.getNsURI());
    assertNotNull("Import of existing EPackage is valid", scope.getSingleElement(QualifiedName.create(ValidscopingtestPackage.eNS_URI)));
    assertNull("Non-existing EPackage cannot be imported", scope.getSingleElement(QualifiedName.create("http://www.avaloq.com/tools/ddk/acf/nonexistingnsuri")));
}
Also used : ValidModel(com.avaloq.tools.ddk.xtext.valid.valid.ValidModel) IScope(org.eclipse.xtext.scoping.IScope) EPackage(org.eclipse.emf.ecore.EPackage) AbstractScopingTest(com.avaloq.tools.ddk.xtext.test.scoping.AbstractScopingTest) 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