Java 类org.eclipse.xtext.generator.AbstractGenerator 实例源码

项目:xtext-core    文件:GeneratorFragment2.java   
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());
}