Search in sources :

Example 1 with JavaBeansMetaModel

use of org.eclipse.xtend.type.impl.java.JavaBeansMetaModel in project dsl-devkit by dsldevkit.

the class CodeGenerationXTest method beforeAllTests.

@Override
protected void beforeAllTests() {
    super.beforeAllTests();
    final ExecutionContextImpl executionContext = new ExecutionContextImpl();
    executionContext.registerMetaModel(new JavaBeansMetaModel());
    executionContext.registerMetaModel(new EmfRegistryMetaModel());
    final CompilationContext context = new CompilationContext(executionContext, new GenModelUtilX());
    getTestInformation().putTestObject(CompilerX.class, new CompilerX(context));
}
Also used : GenModelUtilX(com.avaloq.tools.ddk.xtext.expression.generator.GenModelUtilX) CompilerX(com.avaloq.tools.ddk.xtext.expression.generator.CompilerX) ExecutionContextImpl(org.eclipse.xtend.expression.ExecutionContextImpl) EmfRegistryMetaModel(org.eclipse.xtend.typesystem.emf.EmfRegistryMetaModel) CompilationContext(com.avaloq.tools.ddk.xtext.expression.generator.CompilationContext) JavaBeansMetaModel(org.eclipse.xtend.type.impl.java.JavaBeansMetaModel)

Example 2 with JavaBeansMetaModel

use of org.eclipse.xtend.type.impl.java.JavaBeansMetaModel in project dsl-devkit by dsldevkit.

the class CompilationContextTest method analyze.

@Test
public void analyze() {
    ExecutionContextImpl executionContext = new ExecutionContextImpl();
    executionContext.registerMetaModel(new JavaBeansMetaModel());
    final CompilationContext context = new CompilationContext(executionContext, null);
    Type expectedType = executionContext.getTypeForName("Integer");
    assertSame("Cannot analyze Integer", expectedType, context.analyze("1 + 3"));
    expectedType = executionContext.getTypeForName("Real");
    assertSame("Cannot analyze Real", expectedType, context.analyze("1 + 3.33"));
    expectedType = executionContext.getTypeForName("String");
    assertSame("Cannot analyse String 'foo'", expectedType, context.analyze("\'foo\'"));
    assertSame("Cannot analyse String \"foo \" ", expectedType, context.analyze("\"foo\""));
    assertSame("Cannot analyse String \"foo\" + \'bar\'", expectedType, context.analyze("\"foo\" + \'bar\'"));
}
Also used : Type(org.eclipse.xtend.typesystem.Type) ExecutionContextImpl(org.eclipse.xtend.expression.ExecutionContextImpl) CompilationContext(com.avaloq.tools.ddk.xtext.expression.generator.CompilationContext) JavaBeansMetaModel(org.eclipse.xtend.type.impl.java.JavaBeansMetaModel) Test(org.junit.Test)

Example 3 with JavaBeansMetaModel

use of org.eclipse.xtend.type.impl.java.JavaBeansMetaModel in project dsl-devkit by dsldevkit.

the class CompilationContextTest method isExtension.

@Test
public void isExtension() {
    ExecutionContextImpl executionContext = new ExecutionContextImpl();
    executionContext.registerMetaModel(new JavaBeansMetaModel());
    ExtensionFile extensionFile = ParseFacade.file(new InputStreamReader(getClass().getResourceAsStream("/com/avaloq/tools/ddk/xtext/generator/expression/TestExtensions.ext")), "TestExtensions.ext");
    executionContext = (ExecutionContextImpl) executionContext.cloneWithResource(extensionFile);
    final CompilationContext context = new CompilationContext(executionContext, null);
    assertTrue("test extension not identified", context.isExtension("test"));
}
Also used : InputStreamReader(java.io.InputStreamReader) ExecutionContextImpl(org.eclipse.xtend.expression.ExecutionContextImpl) CompilationContext(com.avaloq.tools.ddk.xtext.expression.generator.CompilationContext) JavaBeansMetaModel(org.eclipse.xtend.type.impl.java.JavaBeansMetaModel) ExtensionFile(org.eclipse.internal.xtend.xtend.ast.ExtensionFile) Test(org.junit.Test)

Example 4 with JavaBeansMetaModel

use of org.eclipse.xtend.type.impl.java.JavaBeansMetaModel in project xtext-core by eclipse.

the class XtendXtext2EcorePostProcessor method getExecutionContext.

/**
 * @param metamodel
 *            the metamodel to augment
 * @return the executionContext used to perform the xtend processing
 */
protected ExecutionContext getExecutionContext(GeneratedMetamodel metamodel) {
    if (executionContext == null) {
        ExecutionContextImpl executionContext = new ExecutionContextImpl();
        executionContext.registerMetaModel(new EmfRegistryMetaModel());
        executionContext.registerMetaModel(new JavaBeansMetaModel());
        this.executionContext = executionContext;
    }
    return executionContext;
}
Also used : ExecutionContextImpl(org.eclipse.xtend.expression.ExecutionContextImpl) EmfRegistryMetaModel(org.eclipse.xtend.typesystem.emf.EmfRegistryMetaModel) JavaBeansMetaModel(org.eclipse.xtend.type.impl.java.JavaBeansMetaModel)

Example 5 with JavaBeansMetaModel

use of org.eclipse.xtend.type.impl.java.JavaBeansMetaModel in project applause by applause.

the class ApplauseDslProjectCreator method enhanceProject.

protected void enhanceProject(final IProject project, final IProgressMonitor monitor) throws CoreException {
    OutputImpl output = new OutputImpl();
    output.addOutlet(new Outlet(false, getEncoding(), null, true, project.getLocation().makeAbsolute().toOSString()));
    XpandExecutionContextImpl execCtx = new XpandExecutionContextImpl(output, null);
    execCtx.getResourceManager().setFileEncoding("ISO-8859-1");
    execCtx.registerMetaModel(new JavaBeansMetaModel());
    XpandFacade facade = XpandFacade.create(execCtx);
    facade.evaluate("org::applause::lang::ui::wizard::ApplauseDslNewProject::main", getProjectInfo());
    project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
}
Also used : Outlet(org.eclipse.xpand2.output.Outlet) XpandExecutionContextImpl(org.eclipse.xpand2.XpandExecutionContextImpl) JavaBeansMetaModel(org.eclipse.xtend.type.impl.java.JavaBeansMetaModel) OutputImpl(org.eclipse.xpand2.output.OutputImpl) XpandFacade(org.eclipse.xpand2.XpandFacade)

Aggregations

JavaBeansMetaModel (org.eclipse.xtend.type.impl.java.JavaBeansMetaModel)6 ExecutionContextImpl (org.eclipse.xtend.expression.ExecutionContextImpl)4 CompilationContext (com.avaloq.tools.ddk.xtext.expression.generator.CompilationContext)3 XpandExecutionContextImpl (org.eclipse.xpand2.XpandExecutionContextImpl)2 EmfRegistryMetaModel (org.eclipse.xtend.typesystem.emf.EmfRegistryMetaModel)2 Test (org.junit.Test)2 CompilerX (com.avaloq.tools.ddk.xtext.expression.generator.CompilerX)1 GenModelUtilX (com.avaloq.tools.ddk.xtext.expression.generator.GenModelUtilX)1 InputStreamReader (java.io.InputStreamReader)1 CoreException (org.eclipse.core.runtime.CoreException)1 ExtensionFile (org.eclipse.internal.xtend.xtend.ast.ExtensionFile)1 XpandFacade (org.eclipse.xpand2.XpandFacade)1 Outlet (org.eclipse.xpand2.output.Outlet)1 OutputImpl (org.eclipse.xpand2.output.OutputImpl)1 VetoException (org.eclipse.xpand2.output.VetoException)1 Type (org.eclipse.xtend.typesystem.Type)1