@Override public void doGenerate(final Resource input, final IFileSystemAccess2 fsa, final IGeneratorContext context) { final TreeIterator<EObject> iter = input.getAllContents(); while (iter.hasNext()) { EObject _next = iter.next(); final EObject e = _next; boolean _matched = false; if (e instanceof Entity) { _matched=true; String _name = ((Entity)e).getName(); String _plus = (_name + ".txt"); StringConcatenation _builder = new StringConcatenation(); _builder.append("Hello "); String _name_1 = ((Entity)e).getName(); _builder.append(_name_1); _builder.append("!"); _builder.newLineIfNotEmpty(); fsa.generateFile(_plus, _builder); } } }
@Override public void doGenerate(final Resource resource, final IFileSystemAccess2 fsa, final IGeneratorContext context) { GeneradorTexto generatorTexto = new GeneradorTexto(resource, fsa); generatorTexto.compilar(); GeneradorWeb generatorWeb = new GeneradorWeb(resource, fsa); generatorWeb.compilar(); }
@Override public void doGenerate(Resource resource, IFileSystemAccess2 fsa, IGeneratorContext context) { // Iterator<Greeting> filtered = Iterators.filter(resource.getAllContents(), Greeting.class); // Iterator<String> names = Iterators.transform(filtered, new Function<Greeting, String>() { // // @Override // public String apply(Greeting greeting) { // return greeting.getName(); // } // }); // fsa.generateFile("greetings.txt", "People to greet: " + IteratorExtensions.join(names, ", ")); }
@Override public void doGenerate(Resource resource, IFileSystemAccess2 fsa, IGeneratorContext context) { Iterator<Greeting> filtered = Iterators.filter(resource.getAllContents(), Greeting.class); Iterator<String> names = Iterators.transform(filtered, new Function<Greeting, String>() { @Override public String apply(Greeting greeting) { return greeting.getName(); } }); String fileName = resource.getURI().lastSegment(); if(fileName == null) fileName = "greetings"; fsa.generateFile(fileName+".txt", "People to greet: " + IteratorExtensions.join(names, ", ")); }
@Override public void doGenerate(final Resource resource, final IFileSystemAccess2 fsa, final IGeneratorContext context) { }
@Override public void doGenerate(Resource resource, IFileSystemAccess2 fsa, IGeneratorContext context) { }
protected void doGenerateXtendStubFile() { TypeReference _generatorStub = this.getGeneratorStub(this.getGrammar()); StringConcatenationClient _client = new StringConcatenationClient() { @Override protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { _builder.append("/**"); _builder.newLine(); _builder.append(" "); _builder.append("* Generates code from your model files on save."); _builder.newLine(); _builder.append(" "); _builder.append("* "); _builder.newLine(); _builder.append(" "); _builder.append("* See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#code-generation"); _builder.newLine(); _builder.append(" "); _builder.append("*/"); _builder.newLine(); _builder.append("class "); String _simpleName = GeneratorFragment2.this.getGeneratorStub(GeneratorFragment2.this.getLanguage().getGrammar()).getSimpleName(); _builder.append(_simpleName); _builder.append(" extends "); _builder.append(AbstractGenerator.class); _builder.append(" {"); _builder.newLineIfNotEmpty(); _builder.newLine(); _builder.append("\t"); _builder.append("override void doGenerate("); _builder.append(Resource.class, "\t"); _builder.append(" resource, "); _builder.append(IFileSystemAccess2.class, "\t"); _builder.append(" fsa, "); _builder.append(IGeneratorContext.class, "\t"); _builder.append(" context) {"); _builder.newLineIfNotEmpty(); _builder.append("//\t\tfsa.generateFile(\'greetings.txt\', \'People to greet: \' + "); _builder.newLine(); _builder.append("//\t\t\tresource.allContents"); _builder.newLine(); _builder.append("//\t\t\t\t.filter(Greeting)"); _builder.newLine(); _builder.append("//\t\t\t\t.map[name]"); _builder.newLine(); _builder.append("//\t\t\t\t.join(\', \'))"); _builder.newLine(); _builder.append("\t"); _builder.append("}"); _builder.newLine(); _builder.append("}"); _builder.newLine(); } }; this.fileAccessFactory.createXtendFile(_generatorStub, _client).writeTo(this.getProjectConfig().getRuntime().getSrc()); }