Search in sources :

Example 76 with TypeReference

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

the class IdeaPluginGenerator method compileParserDefinition.

public JavaFileAccess compileParserDefinition(final Grammar grammar) {
    final Function1<AbstractRule, Boolean> _function = (AbstractRule it) -> {
        return Boolean.valueOf(GrammarUtil.isEObjectRule(it));
    };
    final Iterable<AbstractRule> EObjectRules = IterableExtensions.<AbstractRule>filter(GrammarUtil.allRules(grammar), _function);
    TypeReference _parserDefinition = this._ideaPluginClassNames.getParserDefinition(grammar);
    StringConcatenationClient _client = new StringConcatenationClient() {

        @Override
        protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
            _builder.append("public class ");
            String _simpleName = IdeaPluginGenerator.this._ideaPluginClassNames.getParserDefinition(grammar).getSimpleName();
            _builder.append(_simpleName);
            _builder.append(" extends ");
            TypeReference _superParserDefinition = IdeaPluginGenerator.this._ideaPluginClassNames.getSuperParserDefinition(grammar);
            _builder.append(_superParserDefinition);
            _builder.append(" {");
            _builder.newLineIfNotEmpty();
            {
                boolean _isEmpty = IterableExtensions.isEmpty(EObjectRules);
                boolean _not = (!_isEmpty);
                if (_not) {
                    _builder.newLine();
                    _builder.append("\t");
                    _builder.append("@");
                    _builder.append(Inject.class, "\t");
                    _builder.append(" ");
                    _builder.newLineIfNotEmpty();
                    _builder.append("\t");
                    _builder.append("private ");
                    TypeReference _elementTypeProvider = IdeaPluginGenerator.this._ideaPluginClassNames.getElementTypeProvider(grammar);
                    _builder.append(_elementTypeProvider, "\t");
                    _builder.append(" elementTypeProvider;");
                    _builder.newLineIfNotEmpty();
                }
            }
            _builder.newLine();
            _builder.append("\t");
            _builder.append("@Override");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("public ");
            TypeReference _typeRef = TypeReference.typeRef("com.intellij.psi.PsiFile");
            _builder.append(_typeRef, "\t");
            _builder.append(" createFile(");
            TypeReference _typeRef_1 = TypeReference.typeRef("com.intellij.psi.FileViewProvider");
            _builder.append(_typeRef_1, "\t");
            _builder.append(" viewProvider) {");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("return new ");
            TypeReference _fileImpl = IdeaPluginGenerator.this._ideaPluginClassNames.getFileImpl(grammar);
            _builder.append(_fileImpl, "\t\t");
            _builder.append("(viewProvider);");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.append("}");
            _builder.newLine();
            {
                boolean _isEmpty_1 = IterableExtensions.isEmpty(EObjectRules);
                boolean _not_1 = (!_isEmpty_1);
                if (_not_1) {
                    _builder.append("\t");
                    _builder.newLine();
                    _builder.append("\t");
                    _builder.append("@Override");
                    _builder.newLine();
                    _builder.append("\t");
                    _builder.append("@SuppressWarnings(\"rawtypes\")");
                    _builder.newLine();
                    _builder.append("\t");
                    _builder.append("public ");
                    TypeReference _typeRef_2 = TypeReference.typeRef("com.intellij.psi.PsiElement");
                    _builder.append(_typeRef_2, "\t");
                    _builder.append(" createElement(");
                    TypeReference _typeRef_3 = TypeReference.typeRef("com.intellij.lang.ASTNode");
                    _builder.append(_typeRef_3, "\t");
                    _builder.append(" node) {");
                    _builder.newLineIfNotEmpty();
                    _builder.append("\t");
                    _builder.append("\t");
                    _builder.append("Boolean hasSemanticElement = node.getUserData(");
                    TypeReference _typeRef_4 = TypeReference.typeRef("org.eclipse.xtext.idea.nodemodel.IASTNodeAwareNodeModelBuilder");
                    _builder.append(_typeRef_4, "\t\t");
                    _builder.append(".HAS_SEMANTIC_ELEMENT_KEY);");
                    _builder.newLineIfNotEmpty();
                    _builder.append("\t");
                    _builder.append("\t");
                    _builder.append("if (hasSemanticElement != null && hasSemanticElement) {");
                    _builder.newLine();
                    _builder.append("\t");
                    _builder.append("\t\t");
                    TypeReference _typeRef_5 = TypeReference.typeRef("com.intellij.psi.tree.IElementType");
                    _builder.append(_typeRef_5, "\t\t\t");
                    _builder.append(" elementType = node.getElementType();");
                    _builder.newLineIfNotEmpty();
                    {
                        for (final AbstractRule rule : EObjectRules) {
                            _builder.append("\t");
                            _builder.append("\t\t");
                            _builder.append("if (elementType == elementTypeProvider.get");
                            String _grammarElementIdentifier = IdeaPluginGenerator.this._grammarAccessExtensions.grammarElementIdentifier(rule);
                            _builder.append(_grammarElementIdentifier, "\t\t\t");
                            _builder.append("ElementType()) {");
                            _builder.newLineIfNotEmpty();
                            {
                                boolean _isNamed = IdeaPluginGenerator.this.isNamed(rule);
                                if (_isNamed) {
                                    _builder.append("\t");
                                    _builder.append("\t\t");
                                    _builder.append("\t");
                                    _builder.append("return new ");
                                    TypeReference _typeRef_6 = TypeReference.typeRef("org.eclipse.xtext.psi.impl.PsiNamedEObjectImpl");
                                    _builder.append(_typeRef_6, "\t\t\t\t");
                                    _builder.append("(node) {};");
                                    _builder.newLineIfNotEmpty();
                                } else {
                                    _builder.append("\t");
                                    _builder.append("\t\t");
                                    _builder.append("\t");
                                    _builder.append("return new ");
                                    TypeReference _typeRef_7 = TypeReference.typeRef("org.eclipse.xtext.psi.impl.PsiEObjectImpl");
                                    _builder.append(_typeRef_7, "\t\t\t\t");
                                    _builder.append("(node) {};");
                                    _builder.newLineIfNotEmpty();
                                }
                            }
                            _builder.append("\t");
                            _builder.append("\t\t");
                            _builder.append("}");
                            _builder.newLine();
                            {
                                Iterable<AbstractElement> _eObjectElements = IdeaPluginGenerator.this.getEObjectElements(rule);
                                for (final AbstractElement element : _eObjectElements) {
                                    _builder.append("\t");
                                    _builder.append("\t\t");
                                    _builder.append("if (elementType == elementTypeProvider.get");
                                    String _grammarElementIdentifier_1 = IdeaPluginGenerator.this._grammarAccessExtensions.grammarElementIdentifier(element);
                                    _builder.append(_grammarElementIdentifier_1, "\t\t\t");
                                    _builder.append("ElementType()) {");
                                    _builder.newLineIfNotEmpty();
                                    {
                                        boolean _isNamed_1 = IdeaPluginGenerator.this.isNamed(element);
                                        if (_isNamed_1) {
                                            _builder.append("\t");
                                            _builder.append("\t\t");
                                            _builder.append("\t");
                                            _builder.append("return new ");
                                            TypeReference _typeRef_8 = TypeReference.typeRef("org.eclipse.xtext.psi.impl.PsiNamedEObjectImpl");
                                            _builder.append(_typeRef_8, "\t\t\t\t");
                                            _builder.append("(node) {};");
                                            _builder.newLineIfNotEmpty();
                                        } else {
                                            _builder.append("\t");
                                            _builder.append("\t\t");
                                            _builder.append("\t");
                                            _builder.append("return new ");
                                            TypeReference _typeRef_9 = TypeReference.typeRef("org.eclipse.xtext.psi.impl.PsiEObjectImpl");
                                            _builder.append(_typeRef_9, "\t\t\t\t");
                                            _builder.append("(node) {};");
                                            _builder.newLineIfNotEmpty();
                                        }
                                    }
                                    _builder.append("\t");
                                    _builder.append("\t\t");
                                    _builder.append("}");
                                    _builder.newLine();
                                }
                            }
                        }
                    }
                    _builder.append("\t");
                    _builder.append("\t\t");
                    _builder.append("throw new ");
                    TypeReference _typeRef_10 = TypeReference.typeRef("java.lang.IllegalStateException");
                    _builder.append(_typeRef_10, "\t\t\t");
                    _builder.append("(\"Unexpected element type: \" + elementType);");
                    _builder.newLineIfNotEmpty();
                    _builder.append("\t");
                    _builder.append("\t");
                    _builder.append("}");
                    _builder.newLine();
                    _builder.append("\t");
                    _builder.append("\t");
                    _builder.append("return super.createElement(node);");
                    _builder.newLine();
                    _builder.append("\t");
                    _builder.append("}");
                    _builder.newLine();
                }
            }
            _builder.newLine();
            _builder.append("}");
            _builder.newLine();
        }
    };
    return this.fileAccessFactory.createJavaFile(_parserDefinition, _client);
}
Also used : Inject(com.google.inject.Inject) AbstractElement(org.eclipse.xtext.AbstractElement) StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient) TypeReference(org.eclipse.xtext.xtext.generator.model.TypeReference) AbstractRule(org.eclipse.xtext.AbstractRule)

Example 77 with TypeReference

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

the class IdeaPluginGenerator method compileAbstractFileType.

public JavaFileAccess compileAbstractFileType(final Grammar grammar, final String fileExtension) {
    TypeReference _abstractFileType = this._ideaPluginClassNames.getAbstractFileType(grammar);
    StringConcatenationClient _client = new StringConcatenationClient() {

        @Override
        protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
            _builder.append("public class ");
            String _simpleName = IdeaPluginGenerator.this._ideaPluginClassNames.getAbstractFileType(grammar).getSimpleName();
            _builder.append(_simpleName);
            _builder.append(" extends ");
            TypeReference _typeRef = TypeReference.typeRef("com.intellij.openapi.fileTypes.LanguageFileType");
            _builder.append(_typeRef);
            _builder.append(" {");
            _builder.newLineIfNotEmpty();
            _builder.newLine();
            _builder.append("\t");
            _builder.append("@");
            TypeReference _typeRef_1 = TypeReference.typeRef("org.jetbrains.annotations.NonNls");
            _builder.append(_typeRef_1, "\t");
            _builder.append(" ");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.append("public static final String DEFAULT_EXTENSION = \"");
            _builder.append(fileExtension, "\t");
            _builder.append("\";");
            _builder.newLineIfNotEmpty();
            _builder.newLine();
            _builder.append("\t");
            _builder.append("protected ");
            String _simpleName_1 = IdeaPluginGenerator.this._ideaPluginClassNames.getAbstractFileType(grammar).getSimpleName();
            _builder.append(_simpleName_1, "\t");
            _builder.append("(final ");
            TypeReference _typeRef_2 = TypeReference.typeRef("com.intellij.lang.Language");
            _builder.append(_typeRef_2, "\t");
            _builder.append(" language) {");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("super(language);");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("}");
            _builder.newLine();
            _builder.newLine();
            _builder.append("\t");
            _builder.append("@Override");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("public String getDefaultExtension() {");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("return DEFAULT_EXTENSION;");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("}");
            _builder.newLine();
            _builder.newLine();
            _builder.append("\t");
            _builder.append("@Override");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("public String getDescription() {");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("return \"");
            String _simpleName_2 = IdeaPluginGenerator.this._ideaPluginExtension.getSimpleName(grammar);
            _builder.append(_simpleName_2, "\t\t");
            _builder.append(" files\";");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.append("}");
            _builder.newLine();
            _builder.newLine();
            _builder.append("\t");
            _builder.append("@Override");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("public ");
            TypeReference _typeRef_3 = TypeReference.typeRef("javax.swing.Icon");
            _builder.append(_typeRef_3, "\t");
            _builder.append(" getIcon() {");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("return ");
            TypeReference _typeRef_4 = TypeReference.typeRef("org.eclipse.xtext.idea.Icons");
            _builder.append(_typeRef_4, "\t\t");
            _builder.append(".DSL_FILE_TYPE;");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.append("}");
            _builder.newLine();
            _builder.newLine();
            _builder.append("\t");
            _builder.append("@Override");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("public String getName() {");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("return \"");
            String _simpleName_3 = IdeaPluginGenerator.this._ideaPluginExtension.getSimpleName(grammar);
            _builder.append(_simpleName_3, "\t\t");
            _builder.append("\";");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.append("}");
            _builder.newLine();
            _builder.newLine();
            _builder.append("}");
            _builder.newLine();
        }
    };
    return this.fileAccessFactory.createJavaFile(_abstractFileType, _client);
}
Also used : StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient) TypeReference(org.eclipse.xtext.xtext.generator.model.TypeReference)

Example 78 with TypeReference

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

the class IdeaPluginGenerator method compileAbstractCompletionContributor.

public JavaFileAccess compileAbstractCompletionContributor(final Grammar grammar) {
    TypeReference _abstractCompletionContributor = this._ideaPluginClassNames.getAbstractCompletionContributor(grammar);
    StringConcatenationClient _client = new StringConcatenationClient() {

        @Override
        protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
            _builder.append("public class ");
            String _simpleName = IdeaPluginGenerator.this._ideaPluginClassNames.getAbstractCompletionContributor(grammar).getSimpleName();
            _builder.append(_simpleName);
            _builder.append(" extends ");
            TypeReference _completionContributorSuperClass = IdeaPluginGenerator.this._ideaPluginClassNames.getCompletionContributorSuperClass(grammar);
            _builder.append(_completionContributorSuperClass);
            _builder.append(" {");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.append("public ");
            String _simpleName_1 = IdeaPluginGenerator.this._ideaPluginClassNames.getAbstractCompletionContributor(grammar).getSimpleName();
            _builder.append(_simpleName_1, "\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");
            _builder.append("}");
            _builder.newLine();
            _builder.append("}");
            _builder.newLine();
        }
    };
    return this.fileAccessFactory.createJavaFile(_abstractCompletionContributor, _client);
}
Also used : StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient) TypeReference(org.eclipse.xtext.xtext.generator.model.TypeReference)

Example 79 with TypeReference

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

the class IdeaPluginGenerator method compileSyntaxHighlighterFactory.

public JavaFileAccess compileSyntaxHighlighterFactory(final Grammar grammar) {
    final TypeReference syntaxHighlighter = TypeReference.typeRef("com.intellij.openapi.fileTypes.SyntaxHighlighter");
    final TypeReference lazySyntaxHighlighter = TypeReference.typeRef("com.intellij.openapi.fileTypes.SingleLazyInstanceSyntaxHighlighterFactory");
    TypeReference _syntaxHighlighterFactory = this._ideaPluginClassNames.getSyntaxHighlighterFactory(grammar);
    StringConcatenationClient _client = new StringConcatenationClient() {

        @Override
        protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
            _builder.append("public class ");
            String _simpleName = IdeaPluginGenerator.this._ideaPluginClassNames.getSyntaxHighlighterFactory(grammar).getSimpleName();
            _builder.append(_simpleName);
            _builder.append(" extends ");
            _builder.append(lazySyntaxHighlighter);
            _builder.append(" {");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("@Override");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("@");
            TypeReference _typeRef = TypeReference.typeRef("org.jetbrains.annotations.NotNull");
            _builder.append(_typeRef, "\t");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.append("protected ");
            _builder.append(syntaxHighlighter, "\t");
            _builder.append(" createHighlighter() {");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("return ");
            TypeReference _ideaLanguage = IdeaPluginGenerator.this._ideaPluginClassNames.getIdeaLanguage(grammar);
            _builder.append(_ideaLanguage, "\t\t");
            _builder.append(".INSTANCE.getInstance(");
            _builder.append(syntaxHighlighter, "\t\t");
            _builder.append(".class);");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.append("}");
            _builder.newLine();
            _builder.append("}");
            _builder.newLine();
        }
    };
    return this.fileAccessFactory.createJavaFile(_syntaxHighlighterFactory, _client);
}
Also used : StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient) TypeReference(org.eclipse.xtext.xtext.generator.model.TypeReference)

Example 80 with TypeReference

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

the class IdeaPluginGenerator method compilePluginGenXml.

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

        @Override
        protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
            _builder.append("<idea-plugin version=\"2\">");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("<extensions defaultExtensionNs=\"org.eclipse.xtext.idea\">");
            _builder.newLine();
            {
                Iterable<GeneratedMetamodel> _filter = Iterables.<GeneratedMetamodel>filter(grammar.getMetamodelDeclarations(), GeneratedMetamodel.class);
                for (final GeneratedMetamodel generatedMetamodel : _filter) {
                    _builder.append("\t\t");
                    _builder.append("<package");
                    _builder.newLine();
                    _builder.append("\t\t");
                    _builder.append("\t");
                    _builder.append("uri=\"");
                    String _nsURI = generatedMetamodel.getEPackage().getNsURI();
                    _builder.append(_nsURI, "\t\t\t");
                    _builder.append("\"");
                    _builder.newLineIfNotEmpty();
                    _builder.append("\t\t");
                    _builder.append("\t");
                    _builder.append("class=\"");
                    String _namespace = GrammarUtil.getNamespace(grammar);
                    _builder.append(_namespace, "\t\t\t");
                    _builder.append(".");
                    String _name = generatedMetamodel.getName();
                    _builder.append(_name, "\t\t\t");
                    _builder.append(".");
                    String _firstUpper = StringExtensions.toFirstUpper(generatedMetamodel.getName());
                    _builder.append(_firstUpper, "\t\t\t");
                    _builder.append("Package\"");
                    _builder.newLineIfNotEmpty();
                    _builder.append("\t\t");
                    _builder.append("/>");
                    _builder.newLine();
                }
            }
            _builder.append("\t\t");
            _builder.append("<resourceFactory ");
            _builder.newLine();
            _builder.append("\t\t\t");
            _builder.append("type=\"");
            String _head = IterableExtensions.<String>head(IdeaPluginGenerator.this.getLanguage().getFileExtensions());
            _builder.append(_head, "\t\t\t");
            _builder.append("\"");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t\t");
            _builder.append("class=\"org.eclipse.xtext.resource.IResourceFactory\"");
            _builder.newLine();
            _builder.append("\t\t\t");
            _builder.append("factoryClass=\"");
            TypeReference _extensionFactory = IdeaPluginGenerator.this._ideaPluginClassNames.getExtensionFactory(grammar);
            _builder.append(_extensionFactory, "\t\t\t");
            _builder.append("\"");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("/>");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("<resourceServiceProvider");
            _builder.newLine();
            _builder.append("\t\t\t");
            _builder.append("uriExtension=\"");
            String _head_1 = IterableExtensions.<String>head(IdeaPluginGenerator.this.getLanguage().getFileExtensions());
            _builder.append(_head_1, "\t\t\t");
            _builder.append("\"");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t\t");
            _builder.append("class=\"org.eclipse.xtext.idea.resource.IResourceIdeaServiceProvider\"");
            _builder.newLine();
            _builder.append("\t\t\t");
            _builder.append("factoryClass=\"");
            TypeReference _extensionFactory_1 = IdeaPluginGenerator.this._ideaPluginClassNames.getExtensionFactory(grammar);
            _builder.append(_extensionFactory_1, "\t\t\t");
            _builder.append("\"");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("/>");
            _builder.newLine();
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("<lang.setup");
            _builder.newLine();
            _builder.append("\t\t\t");
            _builder.append("language=\"");
            String _languageID = IdeaPluginGenerator.this._ideaPluginExtension.getLanguageID(grammar);
            _builder.append(_languageID, "\t\t\t");
            _builder.append("\"");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t\t");
            _builder.append("implementationClass=\"");
            TypeReference _ideaSetup = IdeaPluginGenerator.this._ideaPluginClassNames.getIdeaSetup(grammar);
            _builder.append(_ideaSetup, "\t\t\t");
            _builder.append("\"");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("/>");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("</extensions>");
            _builder.newLine();
            _builder.newLine();
            _builder.append("\t");
            _builder.append("<extensions defaultExtensionNs=\"com.intellij\">");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("<psi.treeChangePreprocessor implementation=\"");
            TypeReference _codeBlockModificationListener = IdeaPluginGenerator.this._ideaPluginClassNames.getCodeBlockModificationListener(grammar);
            _builder.append(_codeBlockModificationListener, "\t\t");
            _builder.append("\"/>");
            _builder.newLineIfNotEmpty();
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("<fileTypeFactory implementation=\"");
            TypeReference _fileTypeFactory = IdeaPluginGenerator.this._ideaPluginClassNames.getFileTypeFactory(grammar);
            _builder.append(_fileTypeFactory, "\t\t");
            _builder.append("\"/>");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("<stubElementTypeHolder class=\"");
            TypeReference _elementTypeProvider = IdeaPluginGenerator.this._ideaPluginClassNames.getElementTypeProvider(grammar);
            _builder.append(_elementTypeProvider, "\t\t");
            _builder.append("\"/>");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            CharSequence _compileExtension = IdeaPluginGenerator.this.compileExtension(grammar, "lang.ast.factory", TypeReference.typeRef("org.eclipse.xtext.idea.lang.BaseXtextASTFactory"));
            _builder.append(_compileExtension, "\t\t");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            CharSequence _compileExtension_1 = IdeaPluginGenerator.this.compileExtension(grammar, "lang.parserDefinition", IdeaPluginGenerator.this._ideaPluginClassNames.getParserDefinition(grammar));
            _builder.append(_compileExtension_1, "\t\t");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            CharSequence _compileExtension_2 = IdeaPluginGenerator.this.compileExtension(grammar, "lang.findUsagesProvider", TypeReference.typeRef("org.eclipse.xtext.idea.findusages.BaseXtextFindUsageProvider"));
            _builder.append(_compileExtension_2, "\t\t");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            CharSequence _compileExtension_3 = IdeaPluginGenerator.this.compileExtension(grammar, "lang.refactoringSupport", TypeReference.typeRef("org.eclipse.xtext.idea.refactoring.BaseXtextRefactoringSupportProvider"));
            _builder.append(_compileExtension_3, "\t\t");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            CharSequence _compileExtension_4 = IdeaPluginGenerator.this.compileExtension(grammar, "lang.namesValidator", TypeReference.typeRef("com.intellij.lang.refactoring.NamesValidator"));
            _builder.append(_compileExtension_4, "\t\t");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("<lang.syntaxHighlighterFactory key=\"");
            String _languageID_1 = IdeaPluginGenerator.this._ideaPluginExtension.getLanguageID(grammar);
            _builder.append(_languageID_1, "\t\t");
            _builder.append("\" implementationClass=\"");
            TypeReference _syntaxHighlighterFactory = IdeaPluginGenerator.this._ideaPluginClassNames.getSyntaxHighlighterFactory(grammar);
            _builder.append(_syntaxHighlighterFactory, "\t\t");
            _builder.append("\" />");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            CharSequence _compileExtension_5 = IdeaPluginGenerator.this.compileExtension(grammar, "lang.braceMatcher", TypeReference.typeRef("com.intellij.lang.PairedBraceMatcher"));
            _builder.append(_compileExtension_5, "\t\t");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            CharSequence _compileExtension_6 = IdeaPluginGenerator.this.compileExtension(grammar, "annotator", TypeReference.typeRef("org.eclipse.xtext.idea.annotation.IssueAnnotator"));
            _builder.append(_compileExtension_6, "\t\t");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("<completion.contributor language=\"");
            String _languageID_2 = IdeaPluginGenerator.this._ideaPluginExtension.getLanguageID(grammar);
            _builder.append(_languageID_2, "\t\t");
            _builder.append("\" implementationClass=\"");
            TypeReference _completionContributor = IdeaPluginGenerator.this._ideaPluginClassNames.getCompletionContributor(grammar);
            _builder.append(_completionContributor, "\t\t");
            _builder.append("\"/>");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("<pom.declarationSearcher implementation=\"");
            TypeReference _pomDeclarationSearcher = IdeaPluginGenerator.this._ideaPluginClassNames.getPomDeclarationSearcher(grammar);
            _builder.append(_pomDeclarationSearcher, "\t\t");
            _builder.append("\"/>");
            _builder.newLineIfNotEmpty();
            _builder.newLine();
            _builder.append("\t\t");
            CharSequence _compileExtension_7 = IdeaPluginGenerator.this.compileExtension(grammar, "lang.psiStructureViewFactory", TypeReference.typeRef("com.intellij.lang.PsiStructureViewFactory"));
            _builder.append(_compileExtension_7, "\t\t");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("<facetType implementation=\"");
            TypeReference _facetType = IdeaPluginGenerator.this._ideaPluginClassNames.getFacetType(grammar);
            _builder.append(_facetType, "\t\t");
            _builder.append("\"/>");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            CharSequence _compileExtension_8 = IdeaPluginGenerator.this.compileExtension(grammar, "lang.documentationProvider", TypeReference.typeRef("org.eclipse.xtext.idea.documentation.IdeaDocumentationProvider"));
            _builder.append(_compileExtension_8, "\t\t");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("<colorSettingsPage implementation=\"");
            TypeReference _colorSettingsPage = IdeaPluginGenerator.this._ideaPluginClassNames.colorSettingsPage(grammar);
            _builder.append(_colorSettingsPage, "\t\t");
            _builder.append("\"/>");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("<highlightVisitor implementation=\"");
            TypeReference _semanticHighlightVisitor = IdeaPluginGenerator.this._ideaPluginClassNames.getSemanticHighlightVisitor(grammar);
            _builder.append(_semanticHighlightVisitor, "\t\t");
            _builder.append("\"/>");
            _builder.newLineIfNotEmpty();
            _builder.newLine();
            _builder.append("\t\t");
            CharSequence _compileExtension_9 = IdeaPluginGenerator.this.compileExtension(grammar, "lang.formatter", TypeReference.typeRef("com.intellij.formatting.FormattingModelBuilder"));
            _builder.append(_compileExtension_9, "\t\t");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            CharSequence _compileExtension_10 = IdeaPluginGenerator.this.compileExtension(grammar, "lang.commenter", TypeReference.typeRef("com.intellij.lang.CodeDocumentationAwareCommenter"));
            _builder.append(_compileExtension_10, "\t\t");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.append("</extensions>");
            _builder.newLine();
            _builder.append("</idea-plugin>");
            _builder.newLine();
        }
    };
    return this.fileAccessFactory.createTextFile("plugin_gen.xml", _client);
}
Also used : GeneratedMetamodel(org.eclipse.xtext.GeneratedMetamodel) 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