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;
}
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;
}
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;
}
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;
}
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();
}
Aggregations