Search in sources :

Example 1 with ExportModel

use of com.avaloq.tools.ddk.xtext.export.export.ExportModel in project dsl-devkit by dsldevkit.

the class ExportScopingTest method testEStructuralFeatureScope.

@Test
public void testEStructuralFeatureScope() throws IOException {
    ExportModel model = (ExportModel) getTestSource().getModel();
    IScope scope = scopeProvider.scope_EStructuralFeature(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("unorderedX")));
// 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 2 with ExportModel

use of com.avaloq.tools.ddk.xtext.export.export.ExportModel in project dsl-devkit by dsldevkit.

the class ExportJavaValidator method checkFingerprintInterfaceDefined.

/**
 * Checks that the interface referenced by a fingerprint is defined.
 *
 * @param context
 *          export to check
 */
@Check
public void checkFingerprintInterfaceDefined(final Export context) {
    if (context.isFingerprint() || context.isResourceFingerprint()) {
        ExportModel model = EObjectUtil.eContainer(context, ExportModel.class);
        Interface match = null;
        for (Interface iface : model.getInterfaces()) {
            if (iface.getType().isSuperTypeOf(context.getType())) {
                match = iface;
                break;
            }
        }
        if (match == null) {
            error("No matching interface specification declared", context.isFingerprint() ? ExportPackage.Literals.EXPORT__FINGERPRINT : ExportPackage.Literals.EXPORT__RESOURCE_FINGERPRINT);
        }
    }
}
Also used : ExportModel(com.avaloq.tools.ddk.xtext.export.export.ExportModel) Interface(com.avaloq.tools.ddk.xtext.export.export.Interface) Check(org.eclipse.xtext.validation.Check)

Example 3 with ExportModel

use of com.avaloq.tools.ddk.xtext.export.export.ExportModel in project dsl-devkit by dsldevkit.

the class ExportFragment method getGuiceBindingsRt.

/**
 * {@inheritDoc}
 */
@Override
public Set<Binding> getGuiceBindingsRt(final Grammar grammar) {
    final BindFactory bindFactory = new BindFactory();
    // $NON-NLS-1$
    final String namingPrefix = GrammarUtil.getNamespace(grammar) + ".naming." + GrammarUtil.getName(grammar);
    // $NON-NLS-1$
    final String resourcePrefix = GrammarUtil.getNamespace(grammar) + ".resource." + GrammarUtil.getName(grammar);
    ExportModel m = getModel(grammar);
    if (m != null) {
        // $NON-NLS-1$
        bindFactory.addTypeToType(IQualifiedNameProvider.class.getName(), namingPrefix + "ExportedNamesProvider");
        if (!m.getInterfaces().isEmpty()) {
            // $NON-NLS-1$
            bindFactory.addTypeToType(IFingerprintComputer.class.getName(), resourcePrefix + "FingerprintComputer");
        }
        if (!m.getExports().isEmpty()) {
            // $NON-NLS-1$
            bindFactory.addTypeToType(IDefaultResourceDescriptionStrategy.class.getName(), resourcePrefix + "ResourceDescriptionStrategy");
        }
        if (Iterables.any(m.getExports(), new Predicate<Export>() {

            @Override
            public boolean apply(final Export input) {
                return input.isFingerprint() && input.getFragmentAttribute() != null;
            }
        })) {
            // $NON-NLS-1$
            bindFactory.addTypeToType(IFragmentProvider.class.getName(), resourcePrefix + "FragmentProvider");
        }
    }
    // $NON-NLS-1$
    bindFactory.addTypeToType(IResourceDescription.Manager.class.getName(), resourcePrefix + "ResourceDescriptionManager");
    return bindFactory.getBindings();
}
Also used : IQualifiedNameProvider(org.eclipse.xtext.naming.IQualifiedNameProvider) IFingerprintComputer(com.avaloq.tools.ddk.xtext.resource.IFingerprintComputer) IDefaultResourceDescriptionStrategy(org.eclipse.xtext.resource.IDefaultResourceDescriptionStrategy) ExportModel(com.avaloq.tools.ddk.xtext.export.export.ExportModel) Export(com.avaloq.tools.ddk.xtext.export.export.Export) BindFactory(org.eclipse.xtext.generator.BindFactory) IFragmentProvider(org.eclipse.xtext.resource.IFragmentProvider)

Example 4 with ExportModel

use of com.avaloq.tools.ddk.xtext.export.export.ExportModel 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 5 with ExportModel

use of com.avaloq.tools.ddk.xtext.export.export.ExportModel 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)

Aggregations

ExportModel (com.avaloq.tools.ddk.xtext.export.export.ExportModel)8 AbstractScopingTest (com.avaloq.tools.ddk.xtext.test.scoping.AbstractScopingTest)5 IScope (org.eclipse.xtext.scoping.IScope)5 Test (org.junit.Test)5 Check (org.eclipse.xtext.validation.Check)2 Export (com.avaloq.tools.ddk.xtext.export.export.Export)1 Interface (com.avaloq.tools.ddk.xtext.export.export.Interface)1 IFingerprintComputer (com.avaloq.tools.ddk.xtext.resource.IFingerprintComputer)1 EClass (org.eclipse.emf.ecore.EClass)1 BindFactory (org.eclipse.xtext.generator.BindFactory)1 IQualifiedNameProvider (org.eclipse.xtext.naming.IQualifiedNameProvider)1 IDefaultResourceDescriptionStrategy (org.eclipse.xtext.resource.IDefaultResourceDescriptionStrategy)1 IFragmentProvider (org.eclipse.xtext.resource.IFragmentProvider)1