org.eclipse.xtext.xbase.compiler.JvmModelGenerator Java Examples
The following examples show how to use
org.eclipse.xtext.xbase.compiler.JvmModelGenerator.
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: TestCaseCompiler.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
public void compile(String qualifiedName) throws IOException { ResourceSet set = injector.getInstance(ResourceSet.class); final String from = "src/" + qualifiedName.replace('.', '/') + ".xtend"; final String to = "src-gen/" + qualifiedName.replace('.', '/') + ".java"; Resource res = set.getResource(org.eclipse.emf.common.util.URI.createFileURI(from), true); EcoreUtil.resolveAll(res); if (!res.getErrors().isEmpty()) throw new RuntimeException(res.getErrors().toString()); final File file = new File(to); createFolders(file); FileWriter writer = new FileWriter(file); IXtendJvmAssociations associations = injector.getInstance(IXtendJvmAssociations.class); JvmModelGenerator generator = injector.getInstance(JvmModelGenerator.class); XtendFile xtendFile = (XtendFile)res.getContents().get(0); JvmGenericType inferredType = associations.getInferredType((XtendClass) xtendFile.getXtendTypes().get(0)); GeneratorConfig config = injector.getInstance(IGeneratorConfigProvider.class).get(inferredType); CharSequence javaCode = generator.generateType(inferredType, config); writer.append(javaCode); writer.close(); System.out.println("compiled " + from + " to " + to); }
Example #2
Source File: DefaultXbaseRuntimeModule.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
public Class<? extends IGenerator> bindIGenerator() { return JvmModelGenerator.class; }
Example #3
Source File: XtendRuntimeModule.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
public Class<? extends JvmModelGenerator> bindJvmModelGenerator() { return XtendGenerator.class; }
Example #4
Source File: AbstractSARLRuntimeModule.java From sarl with Apache License 2.0 | 4 votes |
public Class<? extends JvmModelGenerator> bindJvmModelGenerator() { return SARLJvmGenerator.class; }