Search in sources :

Example 11 with StringConcatenation

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

the class IdeaPluginGenerator method compileFileTypeFactory.

public CharSequence compileFileTypeFactory(final Grammar grammar) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package ");
    String _packageName = this._ideaPluginClassNames.toPackageName(this._ideaPluginClassNames.getFileTypeFactoryName(grammar));
    _builder.append(_packageName);
    _builder.append(";");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("import com.intellij.openapi.fileTypes.FileTypeConsumer;");
    _builder.newLine();
    _builder.append("import com.intellij.openapi.fileTypes.FileTypeFactory;");
    _builder.newLine();
    _builder.append("import org.jetbrains.annotations.NotNull;");
    _builder.newLine();
    _builder.newLine();
    _builder.append("public class ");
    String _simpleName = this._ideaPluginClassNames.toSimpleName(this._ideaPluginClassNames.getFileTypeFactoryName(grammar));
    _builder.append(_simpleName);
    _builder.append(" extends FileTypeFactory {");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("\t");
    _builder.append("@Override");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("public void createFileTypes(@NotNull FileTypeConsumer consumer) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("consumer.consume(");
    String _fileTypeName = this._ideaPluginClassNames.getFileTypeName(grammar);
    _builder.append(_fileTypeName, "\t\t");
    _builder.append(".INSTANCE, ");
    String _abstractFileTypeName = this._ideaPluginClassNames.getAbstractFileTypeName(grammar);
    _builder.append(_abstractFileTypeName, "\t\t");
    _builder.append(".DEFAULT_EXTENSION);");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    return _builder;
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation)

Example 12 with StringConcatenation

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

the class IdeaPluginGenerator method compileBaseColorSettingsPage.

public CharSequence compileBaseColorSettingsPage(final Grammar grammar) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package ");
    String _packageName = this._ideaPluginClassNames.toPackageName(this._ideaPluginClassNames.baseColorSettingsPage(grammar));
    _builder.append(_packageName);
    _builder.append(";");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("import ");
    String _languageName = this._ideaPluginClassNames.getLanguageName(grammar);
    _builder.append(_languageName);
    _builder.append(";");
    _builder.newLineIfNotEmpty();
    _builder.append("import org.eclipse.xtext.idea.highlighting.AbstractColorSettingsPage;");
    _builder.newLine();
    _builder.newLine();
    _builder.newLine();
    _builder.append("public class ");
    String _simpleName = this._ideaPluginClassNames.toSimpleName(this._ideaPluginClassNames.baseColorSettingsPage(grammar));
    _builder.append(_simpleName);
    _builder.append(" extends AbstractColorSettingsPage {");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("public ");
    String _simpleName_1 = this._ideaPluginClassNames.toSimpleName(this._ideaPluginClassNames.baseColorSettingsPage(grammar));
    _builder.append(_simpleName_1, "\t");
    _builder.append("() {");
    _builder.newLineIfNotEmpty();
    _builder.append("\t\t");
    String _simpleName_2 = this._ideaPluginClassNames.toSimpleName(this._ideaPluginClassNames.getLanguageName(grammar));
    _builder.append(_simpleName_2, "\t\t");
    _builder.append(".INSTANCE.injectMembers(this);");
    _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 getDisplayName() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("return ");
    String _simpleName_3 = this._ideaPluginClassNames.toSimpleName(this._ideaPluginClassNames.getLanguageName(grammar));
    _builder.append(_simpleName_3, "\t\t");
    _builder.append(".INSTANCE.getDisplayName();");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    return _builder;
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation)

Example 13 with StringConcatenation

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

the class AbstractAntlrGrammarWithActionsGenerator method _compileInitUnorderedGroups.

protected CharSequence _compileInitUnorderedGroups(final ParserRule it, final AntlrOptions options) {
    StringConcatenation _builder = new StringConcatenation();
    {
        boolean _definesUnorderedGroups = this._grammarAccessExtensions.definesUnorderedGroups(it, options);
        if (_definesUnorderedGroups) {
            _builder.newLineIfNotEmpty();
            _builder.append("UnorderedGroupState myUnorderedGroupState = getUnorderedGroupHelper().snapShot(");
            _builder.newLine();
            {
                Iterable<UnorderedGroup> _filter = Iterables.<UnorderedGroup>filter(EcoreUtil2.eAllContentsAsList(it), UnorderedGroup.class);
                boolean _hasElements = false;
                for (final UnorderedGroup group : _filter) {
                    if (!_hasElements) {
                        _hasElements = true;
                    } else {
                        _builder.appendImmediate(", ", "");
                    }
                    _builder.append("grammarAccess.");
                    String _gaRuleElementAccessor = this._grammarAccess.gaRuleElementAccessor(AntlrGrammarGenUtil.<UnorderedGroup>getOriginalElement(group));
                    _builder.append(_gaRuleElementAccessor);
                    _builder.newLineIfNotEmpty();
                }
            }
            _builder.append(");");
        }
    }
    return _builder;
}
Also used : UnorderedGroup(org.eclipse.xtext.UnorderedGroup) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation)

Example 14 with StringConcatenation

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

the class AbstractAntlrGrammarWithActionsGenerator method _compileInitHiddenTokens.

protected CharSequence _compileInitHiddenTokens(final ParserRule it, final AntlrOptions options) {
    StringConcatenation _builder = new StringConcatenation();
    {
        boolean _isDefinesHiddenTokens = it.isDefinesHiddenTokens();
        if (_isDefinesHiddenTokens) {
            _builder.append("HiddenTokens myHiddenTokenState = ((XtextTokenStream)input).setHiddenTokens(");
            {
                EList<AbstractRule> _hiddenTokens = it.getHiddenTokens();
                boolean _hasElements = false;
                for (final AbstractRule hidden : _hiddenTokens) {
                    if (!_hasElements) {
                        _hasElements = true;
                    } else {
                        _builder.appendImmediate(", ", "");
                    }
                    _builder.append("\"");
                    String _ruleName = this._grammarAccessExtensions.ruleName(hidden);
                    _builder.append(_ruleName);
                    _builder.append("\"");
                }
            }
            _builder.append(");");
        }
    }
    return _builder;
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) AbstractRule(org.eclipse.xtext.AbstractRule)

Example 15 with StringConcatenation

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

the class AntlrGrammarGenerator method compileRule.

@Override
protected String compileRule(final ParserRule it, final Grammar grammar, final AntlrOptions options) {
    StringConcatenation _builder = new StringConcatenation();
    {
        boolean _isFragment = it.isFragment();
        boolean _not = (!_isFragment);
        if (_not) {
            String _compileEntryRule = this.compileEntryRule(it, grammar, options);
            _builder.append(_compileEntryRule);
            _builder.newLineIfNotEmpty();
        }
    }
    _builder.newLine();
    String _compileEBNF = this.compileEBNF(it, options);
    _builder.append(_compileEBNF);
    _builder.newLineIfNotEmpty();
    return _builder.toString();
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation)

Aggregations

StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)5377 Test (org.junit.Test)4633 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)384 ContentAssistProcessorTestBuilder (org.eclipse.xtext.ui.testing.ContentAssistProcessorTestBuilder)202 XtendClass (org.eclipse.xtend.core.xtend.XtendClass)135 CompilationUnitImpl (org.eclipse.xtend.core.macro.declaration.CompilationUnitImpl)132 XtendMember (org.eclipse.xtend.core.xtend.XtendMember)131 IFile (org.eclipse.core.resources.IFile)123 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)117 AbstractXtendCompilerTest (org.eclipse.xtend.core.tests.compiler.AbstractXtendCompilerTest)103 MutableClassDeclaration (org.eclipse.xtend.lib.macro.declaration.MutableClassDeclaration)101 MapBasedPreferenceValues (org.eclipse.xtext.preferences.MapBasedPreferenceValues)99 Function1 (org.eclipse.xtext.xbase.lib.Functions.Function1)89 XExpression (org.eclipse.xtext.xbase.XExpression)82 CompilationTestHelper (org.eclipse.xtext.xbase.testing.CompilationTestHelper)80 XtendTypeDeclaration (org.eclipse.xtend.core.xtend.XtendTypeDeclaration)76 Procedure1 (org.eclipse.xtext.xbase.lib.Procedures.Procedure1)73 EList (org.eclipse.emf.common.util.EList)67 List (java.util.List)66 Ignore (org.junit.Ignore)60