Search in sources :

Example 11 with JavaFileAccess

use of org.eclipse.xtext.xtext.generator.model.JavaFileAccess in project xtext-core by eclipse.

the class IdeaPluginGenerator method compileColorSettingsPage.

public JavaFileAccess compileColorSettingsPage(final Grammar grammar) {
    JavaFileAccess _xifexpression = null;
    boolean _isGenerateXtendStub = this.isGenerateXtendStub();
    if (_isGenerateXtendStub) {
        TypeReference _colorSettingsPage = this._ideaPluginClassNames.colorSettingsPage(grammar);
        StringConcatenationClient _client = new StringConcatenationClient() {

            @Override
            protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
                _builder.append("class ");
                String _simpleName = IdeaPluginGenerator.this._ideaPluginClassNames.colorSettingsPage(grammar).getSimpleName();
                _builder.append(_simpleName);
                _builder.append(" extends ");
                TypeReference _baseColorSettingsPage = IdeaPluginGenerator.this._ideaPluginClassNames.baseColorSettingsPage(grammar);
                _builder.append(_baseColorSettingsPage);
                _builder.append(" {");
                _builder.newLineIfNotEmpty();
                _builder.append("}");
                _builder.newLine();
            }
        };
        _xifexpression = this.fileAccessFactory.createXtendFile(_colorSettingsPage, _client);
    } else {
        TypeReference _colorSettingsPage_1 = this._ideaPluginClassNames.colorSettingsPage(grammar);
        StringConcatenationClient _client_1 = new StringConcatenationClient() {

            @Override
            protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
                _builder.append("public class ");
                String _simpleName = IdeaPluginGenerator.this._ideaPluginClassNames.colorSettingsPage(grammar).getSimpleName();
                _builder.append(_simpleName);
                _builder.append(" extends ");
                TypeReference _baseColorSettingsPage = IdeaPluginGenerator.this._ideaPluginClassNames.baseColorSettingsPage(grammar);
                _builder.append(_baseColorSettingsPage);
                _builder.append(" {");
                _builder.newLineIfNotEmpty();
                _builder.append("}");
                _builder.newLine();
            }
        };
        _xifexpression = this.fileAccessFactory.createJavaFile(_colorSettingsPage_1, _client_1);
    }
    return _xifexpression;
}
Also used : JavaFileAccess(org.eclipse.xtext.xtext.generator.model.JavaFileAccess) StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient) TypeReference(org.eclipse.xtext.xtext.generator.model.TypeReference)

Example 12 with JavaFileAccess

use of org.eclipse.xtext.xtext.generator.model.JavaFileAccess in project xtext-core by eclipse.

the class IdeaPluginGenerator method compileCompletionContributor.

public JavaFileAccess compileCompletionContributor(final Grammar grammar) {
    JavaFileAccess _xifexpression = null;
    boolean _isGenerateXtendStub = this.isGenerateXtendStub();
    if (_isGenerateXtendStub) {
        TypeReference _completionContributor = this._ideaPluginClassNames.getCompletionContributor(grammar);
        StringConcatenationClient _client = new StringConcatenationClient() {

            @Override
            protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
                _builder.append("class ");
                String _simpleName = IdeaPluginGenerator.this._ideaPluginClassNames.getCompletionContributor(grammar).getSimpleName();
                _builder.append(_simpleName);
                _builder.append(" extends ");
                TypeReference _abstractCompletionContributor = IdeaPluginGenerator.this._ideaPluginClassNames.getAbstractCompletionContributor(grammar);
                _builder.append(_abstractCompletionContributor);
                _builder.append(" {");
                _builder.newLineIfNotEmpty();
                _builder.append("\t");
                _builder.append("new() {");
                _builder.newLine();
                _builder.append("\t\t");
                _builder.append("this(");
                TypeReference _ideaLanguage = IdeaPluginGenerator.this._ideaPluginClassNames.getIdeaLanguage(grammar);
                _builder.append(_ideaLanguage, "\t\t");
                _builder.append(".INSTANCE)");
                _builder.newLineIfNotEmpty();
                _builder.append("\t");
                _builder.append("}");
                _builder.newLine();
                _builder.append("\t");
                _builder.newLine();
                _builder.append("\t");
                _builder.append("new(");
                TypeReference _typeRef = TypeReference.typeRef("org.eclipse.xtext.idea.lang.AbstractXtextLanguage");
                _builder.append(_typeRef, "\t");
                _builder.append(" lang) {");
                _builder.newLineIfNotEmpty();
                _builder.append("\t\t");
                _builder.append("super(lang)");
                _builder.newLine();
                _builder.append("\t\t");
                _builder.append("//custom rules here");
                _builder.newLine();
                _builder.append("\t");
                _builder.append("}");
                _builder.newLine();
                _builder.append("}");
                _builder.newLine();
            }
        };
        _xifexpression = this.fileAccessFactory.createXtendFile(_completionContributor, _client);
    } else {
        TypeReference _completionContributor_1 = this._ideaPluginClassNames.getCompletionContributor(grammar);
        StringConcatenationClient _client_1 = new StringConcatenationClient() {

            @Override
            protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
                _builder.append("public class ");
                String _simpleName = IdeaPluginGenerator.this._ideaPluginClassNames.getCompletionContributor(grammar).getSimpleName();
                _builder.append(_simpleName);
                _builder.append(" extends ");
                TypeReference _abstractCompletionContributor = IdeaPluginGenerator.this._ideaPluginClassNames.getAbstractCompletionContributor(grammar);
                _builder.append(_abstractCompletionContributor);
                _builder.append(" {");
                _builder.newLineIfNotEmpty();
                _builder.append("\t");
                _builder.append("public ");
                String _simpleName_1 = IdeaPluginGenerator.this._ideaPluginClassNames.getCompletionContributor(grammar).getSimpleName();
                _builder.append(_simpleName_1, "\t");
                _builder.append("() {");
                _builder.newLineIfNotEmpty();
                _builder.append("\t\t");
                _builder.append("this(");
                TypeReference _ideaLanguage = IdeaPluginGenerator.this._ideaPluginClassNames.getIdeaLanguage(grammar);
                _builder.append(_ideaLanguage, "\t\t");
                _builder.append(".INSTANCE);");
                _builder.newLineIfNotEmpty();
                _builder.append("\t");
                _builder.append("}");
                _builder.newLine();
                _builder.append("\t");
                _builder.newLine();
                _builder.append("\t");
                _builder.append("public ");
                String _simpleName_2 = IdeaPluginGenerator.this._ideaPluginClassNames.getCompletionContributor(grammar).getSimpleName();
                _builder.append(_simpleName_2, "\t");
                _builder.append("(");
                TypeReference _typeRef = TypeReference.typeRef("org.eclipse.xtext.idea.lang.AbstractXtextLanguage");
                _builder.append(_typeRef, "\t");
                _builder.append(" lang) {");
                _builder.newLineIfNotEmpty();
                _builder.append("\t\t");
                _builder.append("super(lang);");
                _builder.newLine();
                _builder.append("\t\t");
                _builder.append("//custom rules here");
                _builder.newLine();
                _builder.append("\t");
                _builder.append("}");
                _builder.newLine();
                _builder.append("}");
                _builder.newLine();
            }
        };
        _xifexpression = this.fileAccessFactory.createJavaFile(_completionContributor_1, _client_1);
    }
    return _xifexpression;
}
Also used : JavaFileAccess(org.eclipse.xtext.xtext.generator.model.JavaFileAccess) StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient) TypeReference(org.eclipse.xtext.xtext.generator.model.TypeReference)

Example 13 with JavaFileAccess

use of org.eclipse.xtext.xtext.generator.model.JavaFileAccess in project xtext-core by eclipse.

the class SimpleProjectWizardFragment2 method generateProjectInfo.

public void generateProjectInfo() {
    final TypeReference projectInfoClass = TypeReference.typeRef(this.getProjectInfoClassName());
    final JavaFileAccess file = this.fileAccessFactory.createJavaFile(projectInfoClass);
    StringConcatenationClient _client = new StringConcatenationClient() {

        @Override
        protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
            _builder.append("public class ");
            String _simpleName = projectInfoClass.getSimpleName();
            _builder.append(_simpleName);
            _builder.append(" extends ");
            TypeReference _typeRef = TypeReference.typeRef("org.eclipse.xtext.ui.wizard.DefaultProjectInfo");
            _builder.append(_typeRef);
            _builder.append(" {");
            _builder.newLineIfNotEmpty();
            _builder.newLine();
            _builder.append("}");
            _builder.newLine();
        }
    };
    file.setContent(_client);
    file.writeTo(this.getProjectConfig().getEclipsePlugin().getSrc());
}
Also used : JavaFileAccess(org.eclipse.xtext.xtext.generator.model.JavaFileAccess) GeneratedJavaFileAccess(org.eclipse.xtext.xtext.generator.model.GeneratedJavaFileAccess) StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient) TypeReference(org.eclipse.xtext.xtext.generator.model.TypeReference)

Aggregations

JavaFileAccess (org.eclipse.xtext.xtext.generator.model.JavaFileAccess)13 StringConcatenationClient (org.eclipse.xtend2.lib.StringConcatenationClient)12 TypeReference (org.eclipse.xtext.xtext.generator.model.TypeReference)11 GeneratedJavaFileAccess (org.eclipse.xtext.xtext.generator.model.GeneratedJavaFileAccess)5 Token (org.antlr.runtime.Token)2 TokenSource (org.antlr.runtime.TokenSource)2 TerminalRule (org.eclipse.xtext.TerminalRule)2 AbstractIndentationTokenSource (org.eclipse.xtext.parser.antlr.AbstractIndentationTokenSource)2 Function1 (org.eclipse.xtext.xbase.lib.Functions.Function1)2 ContentAssistGrammarNaming (org.eclipse.xtext.xtext.generator.parser.antlr.ContentAssistGrammarNaming)2 AbstractElement (org.eclipse.xtext.AbstractElement)1 AbstractRule (org.eclipse.xtext.AbstractRule)1 Grammar (org.eclipse.xtext.Grammar)1 GuiceModuleAccess (org.eclipse.xtext.xtext.generator.model.GuiceModuleAccess)1 TextFileAccess (org.eclipse.xtext.xtext.generator.model.TextFileAccess)1 GrammarNaming (org.eclipse.xtext.xtext.generator.parser.antlr.GrammarNaming)1