Search in sources :

Example 21 with StringConcatenationClient

use of org.eclipse.xtend2.lib.StringConcatenationClient in project xtext-core by eclipse.

the class IdeaPluginGenerator method compilePluginXml.

public TextFileAccess compilePluginXml(final Grammar grammar) {
    StringConcatenationClient _client = new StringConcatenationClient() {

        @Override
        protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
            _builder.append("<idea-plugin version=\"2\" xmlns:xi=\"http://www.w3.org/2001/XInclude\">");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("<id>");
            String _ideaBasePackage = IdeaPluginGenerator.this._xtextGeneratorNaming.getIdeaBasePackage(grammar);
            _builder.append(_ideaBasePackage, "\t");
            _builder.append("</id>");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.append("<name>");
            String _simpleName = IdeaPluginGenerator.this._ideaPluginExtension.getSimpleName(grammar);
            _builder.append(_simpleName, "\t");
            _builder.append(" Support</name>");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.append("<description>");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("This plugin enables smart editing of ");
            String _simpleName_1 = IdeaPluginGenerator.this._ideaPluginExtension.getSimpleName(grammar);
            _builder.append(_simpleName_1, "\t\t");
            _builder.append(" files.");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.append("</description>");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("<version>1.0.0</version>");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("<vendor>My Company</vendor>");
            _builder.newLine();
            _builder.newLine();
            _builder.append("\t");
            _builder.append("<idea-version since-build=\"145\"/>");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("<depends>org.eclipse.xtext.idea</depends>");
            _builder.newLine();
            _builder.newLine();
            _builder.append("\t");
            _builder.append("<xi:include href=\"plugin_gen.xml\" xpointer=\"xpointer(/idea-plugin/*)\"/>");
            _builder.newLine();
            _builder.append("</idea-plugin>");
            _builder.newLine();
        }
    };
    return this.fileAccessFactory.createTextFile("plugin.xml", _client);
}
Also used : StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient)

Example 22 with StringConcatenationClient

use of org.eclipse.xtend2.lib.StringConcatenationClient in project xtext-core by eclipse.

the class IdeaPluginGenerator method compileFacetType.

public JavaFileAccess compileFacetType(final Grammar grammar) {
    final TypeReference faceTypeId = TypeReference.typeRef("com.intellij.facet.FacetTypeId", TypeReference.typeRef("com.intellij.facet.Facet", this._ideaPluginClassNames.getFacetConfiguration(grammar)));
    TypeReference _facetType = this._ideaPluginClassNames.getFacetType(grammar);
    StringConcatenationClient _client = new StringConcatenationClient() {

        @Override
        protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
            _builder.append("public class ");
            String _simpleName = IdeaPluginGenerator.this._ideaPluginClassNames.getFacetType(grammar).getSimpleName();
            _builder.append(_simpleName);
            _builder.append(" extends ");
            TypeReference _typeRef = TypeReference.typeRef("org.eclipse.xtext.idea.facet.AbstractFacetType", IdeaPluginGenerator.this._ideaPluginClassNames.getFacetConfiguration(grammar));
            _builder.append(_typeRef);
            _builder.append(" {");
            _builder.newLineIfNotEmpty();
            _builder.newLine();
            _builder.append("\t");
            _builder.append("public static final ");
            _builder.append(faceTypeId, "\t");
            _builder.append(" TYPEID = new ");
            _builder.append(faceTypeId, "\t");
            _builder.append("(\"");
            String _name = grammar.getName();
            _builder.append(_name, "\t");
            _builder.append("\");");
            _builder.newLineIfNotEmpty();
            _builder.newLine();
            _builder.append("\t");
            _builder.append("public ");
            String _simpleName_1 = IdeaPluginGenerator.this._ideaPluginClassNames.getFacetType(grammar).getSimpleName();
            _builder.append(_simpleName_1, "\t");
            _builder.append("() {");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("super(TYPEID, \"");
            String _name_1 = grammar.getName();
            _builder.append(_name_1, "\t\t");
            _builder.append("\", \"");
            String _simpleName_2 = IdeaPluginGenerator.this._ideaPluginExtension.getSimpleName(grammar);
            _builder.append(_simpleName_2, "\t\t");
            _builder.append("\");");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            TypeReference _ideaLanguage = IdeaPluginGenerator.this._ideaPluginClassNames.getIdeaLanguage(grammar);
            _builder.append(_ideaLanguage, "\t\t");
            _builder.append(".INSTANCE.injectMembers(this);");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.append("}");
            _builder.newLine();
            _builder.append("}");
            _builder.newLine();
        }
    };
    return this.fileAccessFactory.createJavaFile(_facetType, _client);
}
Also used : StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient) TypeReference(org.eclipse.xtext.xtext.generator.model.TypeReference)

Example 23 with StringConcatenationClient

use of org.eclipse.xtend2.lib.StringConcatenationClient in project xtext-core by eclipse.

the class IdeaPluginGenerator method compileLanguage.

public JavaFileAccess compileLanguage(final Grammar grammar) {
    TypeReference _ideaLanguage = this._ideaPluginClassNames.getIdeaLanguage(grammar);
    StringConcatenationClient _client = new StringConcatenationClient() {

        @Override
        protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
            _builder.append("public final class ");
            String _simpleName = IdeaPluginGenerator.this._ideaPluginClassNames.getIdeaLanguage(grammar).getSimpleName();
            _builder.append(_simpleName);
            _builder.append(" extends ");
            TypeReference _typeRef = TypeReference.typeRef("org.eclipse.xtext.idea.lang.AbstractXtextLanguage");
            _builder.append(_typeRef);
            _builder.append(" {");
            _builder.newLineIfNotEmpty();
            _builder.newLine();
            _builder.append("\t");
            _builder.append("public static final ");
            String _simpleName_1 = IdeaPluginGenerator.this._ideaPluginClassNames.getIdeaLanguage(grammar).getSimpleName();
            _builder.append(_simpleName_1, "\t");
            _builder.append(" INSTANCE = new ");
            String _simpleName_2 = IdeaPluginGenerator.this._ideaPluginClassNames.getIdeaLanguage(grammar).getSimpleName();
            _builder.append(_simpleName_2, "\t");
            _builder.append("();");
            _builder.newLineIfNotEmpty();
            _builder.newLine();
            _builder.append("\t");
            _builder.append("private ");
            String _simpleName_3 = IdeaPluginGenerator.this._ideaPluginClassNames.getIdeaLanguage(grammar).getSimpleName();
            _builder.append(_simpleName_3, "\t");
            _builder.append("() {");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("super(\"");
            String _languageId = GrammarUtil.getLanguageId(grammar);
            _builder.append(_languageId, "\t\t");
            _builder.append("\");");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.append("}");
            _builder.newLine();
            _builder.newLine();
            _builder.append("}");
            _builder.newLine();
        }
    };
    return this.fileAccessFactory.createJavaFile(_ideaLanguage, _client);
}
Also used : StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient) TypeReference(org.eclipse.xtext.xtext.generator.model.TypeReference)

Example 24 with StringConcatenationClient

use of org.eclipse.xtend2.lib.StringConcatenationClient in project xtext-core by eclipse.

the class IdeaPluginGenerator method compileFileType.

public JavaFileAccess compileFileType(final Grammar grammar) {
    JavaFileAccess _xifexpression = null;
    boolean _isGenerateXtendStub = this.isGenerateXtendStub();
    if (_isGenerateXtendStub) {
        TypeReference _fileType = this._ideaPluginClassNames.getFileType(grammar);
        StringConcatenationClient _client = new StringConcatenationClient() {

            @Override
            protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
                _builder.append("class ");
                String _simpleName = IdeaPluginGenerator.this._ideaPluginClassNames.getFileType(grammar).getSimpleName();
                _builder.append(_simpleName);
                _builder.append(" extends ");
                TypeReference _abstractFileType = IdeaPluginGenerator.this._ideaPluginClassNames.getAbstractFileType(grammar);
                _builder.append(_abstractFileType);
                _builder.append(" {");
                _builder.newLineIfNotEmpty();
                _builder.append("\t");
                _builder.append("public static final ");
                String _simpleName_1 = IdeaPluginGenerator.this._ideaPluginClassNames.getFileType(grammar).getSimpleName();
                _builder.append(_simpleName_1, "\t");
                _builder.append(" INSTANCE = new ");
                String _simpleName_2 = IdeaPluginGenerator.this._ideaPluginClassNames.getFileType(grammar).getSimpleName();
                _builder.append(_simpleName_2, "\t");
                _builder.append("()");
                _builder.newLineIfNotEmpty();
                _builder.append("\t");
                _builder.newLine();
                _builder.append("\t");
                _builder.append("new() {");
                _builder.newLine();
                _builder.append("\t\t");
                _builder.append("super(");
                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("}");
                _builder.newLine();
            }
        };
        _xifexpression = this.fileAccessFactory.createXtendFile(_fileType, _client);
    } else {
        TypeReference _fileType_1 = this._ideaPluginClassNames.getFileType(grammar);
        StringConcatenationClient _client_1 = new StringConcatenationClient() {

            @Override
            protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
                _builder.append("public class ");
                String _simpleName = IdeaPluginGenerator.this._ideaPluginClassNames.getFileType(grammar).getSimpleName();
                _builder.append(_simpleName);
                _builder.append(" extends ");
                TypeReference _abstractFileType = IdeaPluginGenerator.this._ideaPluginClassNames.getAbstractFileType(grammar);
                _builder.append(_abstractFileType);
                _builder.append(" {");
                _builder.newLineIfNotEmpty();
                _builder.append("\t");
                _builder.append("public static final ");
                String _simpleName_1 = IdeaPluginGenerator.this._ideaPluginClassNames.getFileType(grammar).getSimpleName();
                _builder.append(_simpleName_1, "\t");
                _builder.append(" INSTANCE = new ");
                String _simpleName_2 = IdeaPluginGenerator.this._ideaPluginClassNames.getFileType(grammar).getSimpleName();
                _builder.append(_simpleName_2, "\t");
                _builder.append("();");
                _builder.newLineIfNotEmpty();
                _builder.append("\t");
                _builder.newLine();
                _builder.append("\t");
                _builder.append("public ");
                String _simpleName_3 = IdeaPluginGenerator.this._ideaPluginClassNames.getFileType(grammar).getSimpleName();
                _builder.append(_simpleName_3, "\t");
                _builder.append("() {");
                _builder.newLineIfNotEmpty();
                _builder.append("\t\t");
                _builder.append("super(");
                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("}");
                _builder.newLine();
            }
        };
        _xifexpression = this.fileAccessFactory.createJavaFile(_fileType_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 25 with StringConcatenationClient

use of org.eclipse.xtend2.lib.StringConcatenationClient in project xtext-core by eclipse.

the class IdeaPluginGenerator method compileIdeaSetup.

public JavaFileAccess compileIdeaSetup(final Grammar grammar) {
    JavaFileAccess _xifexpression = null;
    boolean _isGenerateXtendStub = this.isGenerateXtendStub();
    if (_isGenerateXtendStub) {
        TypeReference _ideaSetup = this._ideaPluginClassNames.getIdeaSetup(grammar);
        StringConcatenationClient _client = new StringConcatenationClient() {

            @Override
            protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
                _builder.append("class ");
                String _simpleName = IdeaPluginGenerator.this._ideaPluginClassNames.getIdeaSetup(grammar).getSimpleName();
                _builder.append(_simpleName);
                _builder.append(" implements ");
                _builder.append(ISetup.class);
                _builder.append(" {");
                _builder.newLineIfNotEmpty();
                _builder.newLine();
                _builder.append("\t");
                _builder.append("override createInjectorAndDoEMFRegistration() {");
                _builder.newLine();
                _builder.append("\t\t");
                TypeReference _typeRef = TypeReference.typeRef("org.eclipse.xtext.idea.extensions.EcoreGlobalRegistries");
                _builder.append(_typeRef, "\t\t");
                _builder.append(".ensureInitialized");
                _builder.newLineIfNotEmpty();
                _builder.append("\t\t");
                _builder.append("new ");
                TypeReference _ideaStandaloneSetup = IdeaPluginGenerator.this._xtextGeneratorNaming.getIdeaStandaloneSetup(grammar);
                _builder.append(_ideaStandaloneSetup, "\t\t");
                _builder.append("().createInjector");
                _builder.newLineIfNotEmpty();
                _builder.append("\t");
                _builder.append("}");
                _builder.newLine();
                _builder.newLine();
                _builder.append("}");
                _builder.newLine();
            }
        };
        _xifexpression = this.fileAccessFactory.createXtendFile(_ideaSetup, _client);
    } else {
        TypeReference _ideaSetup_1 = this._ideaPluginClassNames.getIdeaSetup(grammar);
        StringConcatenationClient _client_1 = new StringConcatenationClient() {

            @Override
            protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
                _builder.append("public class ");
                String _simpleName = IdeaPluginGenerator.this._ideaPluginClassNames.getIdeaSetup(grammar).getSimpleName();
                _builder.append(_simpleName);
                _builder.append(" implements ");
                _builder.append(ISetup.class);
                _builder.append(" {");
                _builder.newLineIfNotEmpty();
                _builder.newLine();
                _builder.append("\t");
                _builder.append("@Override");
                _builder.newLine();
                _builder.append("\t");
                _builder.append("public ");
                _builder.append(Injector.class, "\t");
                _builder.append(" createInjectorAndDoEMFRegistration() {");
                _builder.newLineIfNotEmpty();
                _builder.append("\t\t");
                TypeReference _typeRef = TypeReference.typeRef("org.eclipse.xtext.idea.extensions.EcoreGlobalRegistries");
                _builder.append(_typeRef, "\t\t");
                _builder.append(".ensureInitialized();");
                _builder.newLineIfNotEmpty();
                _builder.append("\t\t");
                _builder.append("return new ");
                TypeReference _ideaStandaloneSetup = IdeaPluginGenerator.this._xtextGeneratorNaming.getIdeaStandaloneSetup(grammar);
                _builder.append(_ideaStandaloneSetup, "\t\t");
                _builder.append("().createInjector();");
                _builder.newLineIfNotEmpty();
                _builder.append("\t");
                _builder.append("}");
                _builder.newLine();
                _builder.newLine();
                _builder.append("}");
                _builder.newLine();
            }
        };
        _xifexpression = this.fileAccessFactory.createJavaFile(_ideaSetup_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)

Aggregations

StringConcatenationClient (org.eclipse.xtend2.lib.StringConcatenationClient)194 TypeReference (org.eclipse.xtext.xtext.generator.model.TypeReference)119 GeneratedJavaFileAccess (org.eclipse.xtext.xtext.generator.model.GeneratedJavaFileAccess)24 GuiceModuleAccess (org.eclipse.xtext.xtext.generator.model.GuiceModuleAccess)24 Grammar (org.eclipse.xtext.Grammar)23 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)19 List (java.util.List)18 Test (org.junit.Test)18 Set (java.util.Set)14 JavaFileAccess (org.eclipse.xtext.xtext.generator.model.JavaFileAccess)12 ManifestAccess (org.eclipse.xtext.xtext.generator.model.ManifestAccess)12 EClass (org.eclipse.emf.ecore.EClass)11 EList (org.eclipse.emf.common.util.EList)10 AbstractRule (org.eclipse.xtext.AbstractRule)10 IGeneratorNode (org.eclipse.xtext.generator.trace.node.IGeneratorNode)10 EObject (org.eclipse.emf.ecore.EObject)9 IClassAnnotation (org.eclipse.xtext.xtext.generator.model.annotations.IClassAnnotation)9 Function1 (org.eclipse.xtext.xbase.lib.Functions.Function1)8 SuppressWarningsAnnotation (org.eclipse.xtext.xtext.generator.model.annotations.SuppressWarningsAnnotation)8 ArrayList (java.util.ArrayList)7