org.eclipse.xtend.type.impl.java.JavaBeansMetaModel Java Examples

The following examples show how to use org.eclipse.xtend.type.impl.java.JavaBeansMetaModel. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CompilationContextTest.java    From dsl-devkit with Eclipse Public License 1.0 6 votes vote down vote up
@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\'"));
}
 
Example #2
Source File: CodeGenerationXTest.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
@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));
}
 
Example #3
Source File: CompilationContextTest.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
@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"));
}
 
Example #4
Source File: Generator.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
private XpandExecutionContext createExecutionContext() {
	// configure outlets
	OutputImpl output = new OutputImpl();

	output.addOutlet(createOutlet(false, getEncoding(), PLUGIN_RT, false, getPathRtProject()));
	output.addOutlet(createOutlet(false, getEncoding(), SRC, false, getPathRtProject() + getSrcPath()));
	output.addOutlet(createOutlet(false, getEncoding(), SRC_GEN, true, getPathRtProject() + getSrcGenPath()));
	output.addOutlet(createOutlet(false, getEncoding(), MODEL, false, getPathRtProject() + "/model"));
	if (getPathUiProject() != null) {
		output.addOutlet(createOutlet(false, getEncoding(), PLUGIN_UI, false, getPathUiProject()));
		output.addOutlet(createOutlet(false, getEncoding(), SRC_UI, false, getPathUiProject() + getSrcPath()));
		output.addOutlet(createOutlet(false, getEncoding(), SRC_GEN_UI, true, getPathUiProject() + getSrcGenPath()));
	} else {
		output.addOutlet(createOutlet(false, getEncoding(), PLUGIN_UI, false, getPathRtProject()));
		output.addOutlet(createOutlet(false, getEncoding(), SRC_UI, false, getPathRtProject() + getSrcPath()));
		output.addOutlet(createOutlet(false, getEncoding(), SRC_GEN_UI, true, getPathRtProject() + getSrcGenPath()));
	}
	if (getPathIdeProject() != null) {
		output.addOutlet(createOutlet(false, getEncoding(), PLUGIN_IDE, false, getPathIdeProject()));
		output.addOutlet(createOutlet(false, getEncoding(), SRC_IDE, false, getPathIdeProject() + getSrcPath()));
		output.addOutlet(createOutlet(false, getEncoding(), SRC_GEN_IDE, true, getPathIdeProject() + getSrcGenPath()));
	} else if (getPathUiProject() != null) {
		output.addOutlet(createOutlet(false, getEncoding(), PLUGIN_IDE, false, getPathUiProject()));
		output.addOutlet(createOutlet(false, getEncoding(), SRC_IDE, false, getPathUiProject() + getSrcPath()));
		output.addOutlet(createOutlet(false, getEncoding(), SRC_GEN_IDE, true, getPathUiProject() + getSrcGenPath()));
	} else {
		output.addOutlet(createOutlet(false, getEncoding(), PLUGIN_IDE, false, getPathRtProject()));
		output.addOutlet(createOutlet(false, getEncoding(), SRC_IDE, false, getPathRtProject() + getSrcPath()));
		output.addOutlet(createOutlet(false, getEncoding(), SRC_GEN_IDE, true, getPathRtProject() + getSrcGenPath()));
	}
	if (!Strings.isEmpty(getPathTestProject())) {
		output.addOutlet(createOutlet(false, getEncoding(), PLUGIN_TEST, false, getPathTestProject()));
		output.addOutlet(createOutlet(false, getEncoding(), SRC_TEST, false, getPathTestProject() + getSrcPath()));
		output.addOutlet(createOutlet(false, getEncoding(), SRC_GEN_TEST, true, getPathTestProject()
				+ getSrcGenPath()));
	} else {
		output.addOutlet(createOutlet(false, getEncoding(), PLUGIN_TEST, false, getPathRtProject()));
		output.addOutlet(createOutlet(false, getEncoding(), SRC_TEST, false, getPathRtProject() + getSrcPath()));
		output.addOutlet(createOutlet(false, getEncoding(), SRC_GEN_TEST, true, getPathRtProject()
				+ getSrcGenPath()));
	}
	// initialize global vars
	Map<String, Variable> globalVars = Maps.newHashMap();
	globalVars.put(Naming.GLOBAL_VAR_NAME, new Variable(Naming.GLOBAL_VAR_NAME, naming));

	// create execution context
	XpandExecutionContextImpl execCtx = new XpandExecutionContextImpl(output, null, globalVars, null, null);
	//since our templates are all encoded in ISO-8859-1, we have to fix it here.
	execCtx.getResourceManager().setFileEncoding("ISO-8859-1");

	execCtx.registerMetaModel(new JavaBeansMetaModel());
	// add default value for 'modelPluginID' for generated GenModel required
	// for further .edit/.editor generation
	execCtx = (XpandExecutionContextImpl) execCtx.cloneWithVariable(new Variable("modelPluginID",
			getProjectNameRt()));
	return execCtx;
}