Search in sources :

Example 91 with StringConcatenationClient

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

the class MutableJvmFieldDeclarationImpl method setConstantValueAsBoolean.

@Override
public void setConstantValueAsBoolean(final boolean value) {
    this.internalGenericSetConstantValue(Boolean.valueOf(value));
    StringConcatenationClient _client = new StringConcatenationClient() {

        @Override
        protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
            _builder.append(value);
        }
    };
    this.getCompilationUnit().setCompilationTemplate(this.getDelegate(), _client);
}
Also used : StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient)

Example 92 with StringConcatenationClient

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

the class MutableJvmFieldDeclarationImpl method setConstantValueAsShort.

@Override
public void setConstantValueAsShort(final short value) {
    this.internalGenericSetConstantValue(Short.valueOf(value));
    StringConcatenationClient _client = new StringConcatenationClient() {

        @Override
        protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
            _builder.append(value);
        }
    };
    this.getCompilationUnit().setCompilationTemplate(this.getDelegate(), _client);
}
Also used : StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient)

Example 93 with StringConcatenationClient

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

the class MutableJvmFieldDeclarationImpl method setConstantValueAsInt.

@Override
public void setConstantValueAsInt(final int value) {
    this.internalGenericSetConstantValue(Integer.valueOf(value));
    StringConcatenationClient _client = new StringConcatenationClient() {

        @Override
        protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
            _builder.append(value);
        }
    };
    this.getCompilationUnit().setCompilationTemplate(this.getDelegate(), _client);
}
Also used : StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient)

Example 94 with StringConcatenationClient

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

the class MutableJvmFieldDeclarationImpl method setConstantValueAsByte.

@Override
public void setConstantValueAsByte(final byte value) {
    this.internalGenericSetConstantValue(Byte.valueOf(value));
    StringConcatenationClient _client = new StringConcatenationClient() {

        @Override
        protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
            _builder.append(value);
        }
    };
    this.getCompilationUnit().setCompilationTemplate(this.getDelegate(), _client);
}
Also used : StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient)

Example 95 with StringConcatenationClient

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

the class IdeaPluginGenerator method compileElementTypeProvider.

public JavaFileAccess compileElementTypeProvider(final Grammar grammar) {
    final JavaFileAccess file = this.fileAccessFactory.createJavaFile(this._ideaPluginClassNames.getElementTypeProvider(grammar));
    file.importType(TypeReference.typeRef("org.eclipse.xtext.idea.lang.IElementTypeProvider"));
    file.importType(TypeReference.typeRef("org.eclipse.xtext.psi.stubs.XtextFileElementType"));
    file.importType(TypeReference.typeRef("org.eclipse.xtext.psi.stubs.XtextFileStub"));
    file.importType(TypeReference.typeRef("org.eclipse.xtext.psi.tree.IGrammarAwareElementType"));
    file.importType(TypeReference.typeRef("com.intellij.psi.tree.IFileElementType"));
    StringConcatenationClient _client = new StringConcatenationClient() {

        @Override
        protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
            _builder.append("public class ");
            String _simpleName = IdeaPluginGenerator.this._ideaPluginClassNames.getElementTypeProvider(grammar).getSimpleName();
            _builder.append(_simpleName);
            _builder.append(" implements IElementTypeProvider {");
            _builder.newLineIfNotEmpty();
            _builder.newLine();
            _builder.append("\t");
            _builder.append("public static final IFileElementType FILE_TYPE = new XtextFileElementType<XtextFileStub<");
            TypeReference _fileImpl = IdeaPluginGenerator.this._ideaPluginClassNames.getFileImpl(grammar);
            _builder.append(_fileImpl, "\t");
            _builder.append(">>(");
            TypeReference _ideaLanguage = IdeaPluginGenerator.this._ideaPluginClassNames.getIdeaLanguage(grammar);
            _builder.append(_ideaLanguage, "\t");
            _builder.append(".INSTANCE);");
            _builder.newLineIfNotEmpty();
            _builder.newLine();
            _builder.append("\t");
            _builder.append("private static final ");
            _builder.append(Map.class, "\t");
            _builder.append("<");
            _builder.append(EObject.class, "\t");
            _builder.append(", IGrammarAwareElementType> GRAMMAR_ELEMENT_TYPE = new ");
            _builder.append(HashMap.class, "\t");
            _builder.append("<");
            _builder.append(EObject.class, "\t");
            _builder.append(", IGrammarAwareElementType>();");
            _builder.newLineIfNotEmpty();
            _builder.newLine();
            _builder.append("\t");
            _builder.append("private static IGrammarAwareElementType associate(IGrammarAwareElementType grammarAwareElementType) {");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("GRAMMAR_ELEMENT_TYPE.put(grammarAwareElementType.getGrammarElement(), grammarAwareElementType);");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("return grammarAwareElementType;");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("}");
            _builder.newLine();
            _builder.newLine();
            _builder.append("\t");
            _builder.append("private static final ");
            TypeReference _grammarAccess = IdeaPluginGenerator.this._grammarAccessExtensions.getGrammarAccess(grammar);
            _builder.append(_grammarAccess, "\t");
            _builder.append(" GRAMMAR_ACCESS = ");
            TypeReference _ideaLanguage_1 = IdeaPluginGenerator.this._ideaPluginClassNames.getIdeaLanguage(grammar);
            _builder.append(_ideaLanguage_1, "\t");
            _builder.append(".INSTANCE.getInstance(");
            TypeReference _grammarAccess_1 = IdeaPluginGenerator.this._grammarAccessExtensions.getGrammarAccess(grammar);
            _builder.append(_grammarAccess_1, "\t");
            _builder.append(".class);");
            _builder.newLineIfNotEmpty();
            {
                Iterable<AbstractRule> _allNonTerminalRules = IdeaPluginGenerator.this._ideaPluginExtension.getAllNonTerminalRules(grammar);
                for (final AbstractRule rule : _allNonTerminalRules) {
                    _builder.newLine();
                    _builder.append("\t");
                    _builder.append("private static class ");
                    String _grammarElementIdentifier = IdeaPluginGenerator.this._grammarAccessExtensions.grammarElementIdentifier(rule);
                    _builder.append(_grammarElementIdentifier, "\t");
                    _builder.append("Factory {");
                    _builder.newLineIfNotEmpty();
                    _builder.append("\t");
                    _builder.append("\t");
                    _builder.append("public static IGrammarAwareElementType create");
                    String _grammarElementIdentifier_1 = IdeaPluginGenerator.this._grammarAccessExtensions.grammarElementIdentifier(rule);
                    _builder.append(_grammarElementIdentifier_1, "\t\t");
                    _builder.append("ElementType() {");
                    _builder.newLineIfNotEmpty();
                    _builder.append("\t");
                    _builder.append("\t\t");
                    _builder.append("return new IGrammarAwareElementType(\"");
                    String _grammarElementIdentifier_2 = IdeaPluginGenerator.this._grammarAccessExtensions.grammarElementIdentifier(rule);
                    _builder.append(_grammarElementIdentifier_2, "\t\t\t");
                    _builder.append("_ELEMENT_TYPE\", ");
                    TypeReference _ideaLanguage_2 = IdeaPluginGenerator.this._ideaPluginClassNames.getIdeaLanguage(grammar);
                    _builder.append(_ideaLanguage_2, "\t\t\t");
                    _builder.append(".INSTANCE, GRAMMAR_ACCESS.");
                    String _gaRuleAccessor = IdeaPluginGenerator.this._grammarAccessExtensions.gaRuleAccessor(rule);
                    _builder.append(_gaRuleAccessor, "\t\t\t");
                    _builder.append(");");
                    _builder.newLineIfNotEmpty();
                    _builder.append("\t");
                    _builder.append("\t");
                    _builder.append("}");
                    _builder.newLine();
                    {
                        Iterable<AbstractElement> _iterable = IteratorExtensions.<AbstractElement>toIterable(Iterators.<AbstractElement>filter(rule.eAllContents(), AbstractElement.class));
                        for (final AbstractElement element : _iterable) {
                            _builder.append("\t");
                            _builder.append("\t");
                            _builder.append("public static IGrammarAwareElementType create");
                            String _grammarElementIdentifier_3 = IdeaPluginGenerator.this._grammarAccessExtensions.grammarElementIdentifier(element);
                            _builder.append(_grammarElementIdentifier_3, "\t\t");
                            _builder.append("ElementType() {");
                            _builder.newLineIfNotEmpty();
                            _builder.append("\t");
                            _builder.append("\t");
                            _builder.append("\t");
                            _builder.append("return new IGrammarAwareElementType(\"");
                            String _grammarElementIdentifier_4 = IdeaPluginGenerator.this._grammarAccessExtensions.grammarElementIdentifier(element);
                            _builder.append(_grammarElementIdentifier_4, "\t\t\t");
                            _builder.append("_ELEMENT_TYPE\", ");
                            TypeReference _ideaLanguage_3 = IdeaPluginGenerator.this._ideaPluginClassNames.getIdeaLanguage(grammar);
                            _builder.append(_ideaLanguage_3, "\t\t\t");
                            _builder.append(".INSTANCE, GRAMMAR_ACCESS.");
                            String _gaElementsAccessor = IdeaPluginGenerator.this._grammarAccessExtensions.gaElementsAccessor(rule);
                            _builder.append(_gaElementsAccessor, "\t\t\t");
                            _builder.append(".");
                            String _gaElementAccessor = IdeaPluginGenerator.this._grammarAccessExtensions.gaElementAccessor(element);
                            _builder.append(_gaElementAccessor, "\t\t\t");
                            _builder.append(");");
                            _builder.newLineIfNotEmpty();
                            _builder.append("\t");
                            _builder.append("\t");
                            _builder.append("}");
                            _builder.newLine();
                        }
                    }
                    _builder.append("\t");
                    _builder.append("}");
                    _builder.newLine();
                    _builder.newLine();
                    _builder.append("\t");
                    _builder.append("public static final IGrammarAwareElementType ");
                    String _grammarElementIdentifier_5 = IdeaPluginGenerator.this._grammarAccessExtensions.grammarElementIdentifier(rule);
                    _builder.append(_grammarElementIdentifier_5, "\t");
                    _builder.append("_ELEMENT_TYPE = associate(");
                    String _grammarElementIdentifier_6 = IdeaPluginGenerator.this._grammarAccessExtensions.grammarElementIdentifier(rule);
                    _builder.append(_grammarElementIdentifier_6, "\t");
                    _builder.append("Factory.create");
                    String _grammarElementIdentifier_7 = IdeaPluginGenerator.this._grammarAccessExtensions.grammarElementIdentifier(rule);
                    _builder.append(_grammarElementIdentifier_7, "\t");
                    _builder.append("ElementType());");
                    _builder.newLineIfNotEmpty();
                    {
                        Iterable<AbstractElement> _iterable_1 = IteratorExtensions.<AbstractElement>toIterable(Iterators.<AbstractElement>filter(rule.eAllContents(), AbstractElement.class));
                        for (final AbstractElement element_1 : _iterable_1) {
                            _builder.newLine();
                            _builder.append("\t");
                            _builder.append("public static final IGrammarAwareElementType ");
                            String _grammarElementIdentifier_8 = IdeaPluginGenerator.this._grammarAccessExtensions.grammarElementIdentifier(element_1);
                            _builder.append(_grammarElementIdentifier_8, "\t");
                            _builder.append("_ELEMENT_TYPE = associate(");
                            String _grammarElementIdentifier_9 = IdeaPluginGenerator.this._grammarAccessExtensions.grammarElementIdentifier(rule);
                            _builder.append(_grammarElementIdentifier_9, "\t");
                            _builder.append("Factory.create");
                            String _grammarElementIdentifier_10 = IdeaPluginGenerator.this._grammarAccessExtensions.grammarElementIdentifier(element_1);
                            _builder.append(_grammarElementIdentifier_10, "\t");
                            _builder.append("ElementType());");
                            _builder.newLineIfNotEmpty();
                        }
                    }
                }
            }
            _builder.newLine();
            _builder.append("\t");
            _builder.append("@Override");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("public IFileElementType getFileType() {");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("return FILE_TYPE;");
            _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 IGrammarAwareElementType findElementType(");
            _builder.append(EObject.class, "\t");
            _builder.append(" grammarElement) {");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("return GRAMMAR_ELEMENT_TYPE.get(grammarElement);");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("}");
            _builder.newLine();
            {
                Iterable<AbstractRule> _allNonTerminalRules_1 = IdeaPluginGenerator.this._ideaPluginExtension.getAllNonTerminalRules(grammar);
                for (final AbstractRule rule_1 : _allNonTerminalRules_1) {
                    _builder.append("\t");
                    _builder.newLine();
                    _builder.append("\t");
                    _builder.append("public IGrammarAwareElementType get");
                    String _grammarElementIdentifier_11 = IdeaPluginGenerator.this._grammarAccessExtensions.grammarElementIdentifier(rule_1);
                    _builder.append(_grammarElementIdentifier_11, "\t");
                    _builder.append("ElementType() {");
                    _builder.newLineIfNotEmpty();
                    _builder.append("\t");
                    _builder.append("\t");
                    _builder.append("return ");
                    String _grammarElementIdentifier_12 = IdeaPluginGenerator.this._grammarAccessExtensions.grammarElementIdentifier(rule_1);
                    _builder.append(_grammarElementIdentifier_12, "\t\t");
                    _builder.append("_ELEMENT_TYPE;");
                    _builder.newLineIfNotEmpty();
                    _builder.append("\t");
                    _builder.append("}");
                    _builder.newLine();
                    {
                        Iterable<AbstractElement> _iterable_2 = IteratorExtensions.<AbstractElement>toIterable(Iterators.<AbstractElement>filter(rule_1.eAllContents(), AbstractElement.class));
                        for (final AbstractElement element_2 : _iterable_2) {
                            _builder.append("\t");
                            _builder.newLine();
                            _builder.append("\t");
                            _builder.append("public IGrammarAwareElementType get");
                            String _grammarElementIdentifier_13 = IdeaPluginGenerator.this._grammarAccessExtensions.grammarElementIdentifier(element_2);
                            _builder.append(_grammarElementIdentifier_13, "\t");
                            _builder.append("ElementType() {");
                            _builder.newLineIfNotEmpty();
                            _builder.append("\t");
                            _builder.append("\t");
                            _builder.append("return ");
                            String _grammarElementIdentifier_14 = IdeaPluginGenerator.this._grammarAccessExtensions.grammarElementIdentifier(element_2);
                            _builder.append(_grammarElementIdentifier_14, "\t\t");
                            _builder.append("_ELEMENT_TYPE;");
                            _builder.newLineIfNotEmpty();
                            _builder.append("\t");
                            _builder.append("}");
                            _builder.newLine();
                        }
                    }
                }
            }
            _builder.newLine();
            _builder.append("}");
            _builder.newLine();
        }
    };
    file.setContent(_client);
    return file;
}
Also used : JavaFileAccess(org.eclipse.xtext.xtext.generator.model.JavaFileAccess) AbstractElement(org.eclipse.xtext.AbstractElement) StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient) TypeReference(org.eclipse.xtext.xtext.generator.model.TypeReference) AbstractRule(org.eclipse.xtext.AbstractRule)

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