Search in sources :

Example 11 with TypeReference

use of org.eclipse.xtext.xtext.generator.model.TypeReference 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 12 with TypeReference

use of org.eclipse.xtext.xtext.generator.model.TypeReference 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 13 with TypeReference

use of org.eclipse.xtext.xtext.generator.model.TypeReference 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 14 with TypeReference

use of org.eclipse.xtext.xtext.generator.model.TypeReference 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)

Example 15 with TypeReference

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

the class IdeaPluginGenerator method compileAntlrTokenFileProvider.

public JavaFileAccess compileAntlrTokenFileProvider(final Grammar grammar) {
    TypeReference _antlrTokenFileProvider = this._ideaPluginClassNames.getAntlrTokenFileProvider(grammar);
    StringConcatenationClient _client = new StringConcatenationClient() {

        @Override
        protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
            _builder.append("public class ");
            String _simpleName = IdeaPluginGenerator.this._ideaPluginClassNames.getAntlrTokenFileProvider(grammar).getSimpleName();
            _builder.append(_simpleName);
            _builder.append(" implements ");
            _builder.append(IAntlrTokenFileProvider.class);
            _builder.append(" {");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.append("@");
            _builder.append(Override.class, "\t");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.append("public ");
            _builder.append(InputStream.class, "\t");
            _builder.append(" getAntlrTokenFile() {");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append(ClassLoader.class, "\t\t");
            _builder.append(" classLoader = getClass().getClassLoader();");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("return classLoader.getResourceAsStream(\"");
            String _tokens = IdeaPluginGenerator.this._ideaPluginClassNames.getTokens(grammar);
            _builder.append(_tokens, "\t\t");
            _builder.append("\");");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.append("}");
            _builder.newLine();
            _builder.append("}");
            _builder.newLine();
        }
    };
    return this.fileAccessFactory.createJavaFile(_antlrTokenFileProvider, _client);
}
Also used : StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient) TypeReference(org.eclipse.xtext.xtext.generator.model.TypeReference)

Aggregations

TypeReference (org.eclipse.xtext.xtext.generator.model.TypeReference)154 StringConcatenationClient (org.eclipse.xtend2.lib.StringConcatenationClient)119 GuiceModuleAccess (org.eclipse.xtext.xtext.generator.model.GuiceModuleAccess)27 GeneratedJavaFileAccess (org.eclipse.xtext.xtext.generator.model.GeneratedJavaFileAccess)24 Grammar (org.eclipse.xtext.Grammar)23 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)21 ManifestAccess (org.eclipse.xtext.xtext.generator.model.ManifestAccess)17 List (java.util.List)14 Set (java.util.Set)12 Test (org.junit.Test)12 JavaFileAccess (org.eclipse.xtext.xtext.generator.model.JavaFileAccess)11 PluginXmlAccess (org.eclipse.xtext.xtext.generator.model.PluginXmlAccess)11 IClassAnnotation (org.eclipse.xtext.xtext.generator.model.annotations.IClassAnnotation)10 AbstractRule (org.eclipse.xtext.AbstractRule)9 SuppressWarningsAnnotation (org.eclipse.xtext.xtext.generator.model.annotations.SuppressWarningsAnnotation)8 IBundleProjectConfig (org.eclipse.xtext.xtext.generator.model.project.IBundleProjectConfig)8 ContentAssistGrammarNaming (org.eclipse.xtext.xtext.generator.parser.antlr.ContentAssistGrammarNaming)7 EObject (org.eclipse.emf.ecore.EObject)6 Function1 (org.eclipse.xtext.xbase.lib.Functions.Function1)6 ArrayList (java.util.ArrayList)5