use of org.eclipse.xtend2.lib.StringConcatenationClient 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);
}
use of org.eclipse.xtend2.lib.StringConcatenationClient in project xtext-core by eclipse.
the class IdeaPluginGenerator method compilePsiParser.
public JavaFileAccess compilePsiParser(final Grammar grammar) {
TypeReference _psiParser = this._ideaPluginClassNames.getPsiParser(grammar);
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("public class ");
String _simpleName = IdeaPluginGenerator.this._ideaPluginClassNames.getPsiParser(grammar).getSimpleName();
_builder.append(_simpleName);
_builder.append(" extends ");
TypeReference _typeRef = TypeReference.typeRef("org.eclipse.xtext.idea.parser.AbstractXtextPsiParser");
_builder.append(_typeRef);
_builder.append(" {");
_builder.newLineIfNotEmpty();
_builder.newLine();
{
boolean _isEmpty = IdeaPluginGenerator.this._grammarAccessExtensions.initialHiddenTokens(grammar).isEmpty();
boolean _not = (!_isEmpty);
if (_not) {
_builder.append("\t");
_builder.append("private static final ");
_builder.append(Set.class, "\t");
_builder.append("<");
_builder.append(String.class, "\t");
_builder.append("> INITIAL_HIDDEN_TOKENS = new ");
_builder.append(HashSet.class, "\t");
_builder.append("<");
_builder.append(String.class, "\t");
_builder.append(">(");
_builder.append(Arrays.class, "\t");
_builder.append(".asList(");
{
List<String> _initialHiddenTokens = IdeaPluginGenerator.this._grammarAccessExtensions.initialHiddenTokens(grammar);
boolean _hasElements = false;
for (final String hidden : _initialHiddenTokens) {
if (!_hasElements) {
_hasElements = true;
} else {
_builder.appendImmediate(", ", "\t");
}
_builder.append("\"");
_builder.append(hidden, "\t");
_builder.append("\"");
}
}
_builder.append("));");
_builder.newLineIfNotEmpty();
} else {
_builder.append("\t");
_builder.append("private static final ");
_builder.append(Set.class, "\t");
_builder.append("<");
_builder.append(String.class, "\t");
_builder.append("> INITIAL_HIDDEN_TOKENS = ");
_builder.append(Collections.class, "\t");
_builder.append(".emptySet();");
_builder.newLineIfNotEmpty();
}
}
_builder.newLine();
_builder.append("\t");
_builder.append("@");
_builder.append(Inject.class, "\t");
_builder.append(" ");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("private ");
TypeReference _grammarAccess = IdeaPluginGenerator.this._grammarAccessExtensions.getGrammarAccess(grammar);
_builder.append(_grammarAccess, "\t");
_builder.append(" grammarAccess;");
_builder.newLineIfNotEmpty();
_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("@");
_builder.append(Override.class, "\t");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("protected ");
TypeReference _typeRef_1 = TypeReference.typeRef("org.eclipse.xtext.idea.parser.AbstractPsiAntlrParser");
_builder.append(_typeRef_1, "\t");
_builder.append(" createParser(");
TypeReference _typeRef_2 = TypeReference.typeRef("com.intellij.lang.PsiBuilder");
_builder.append(_typeRef_2, "\t");
_builder.append(" builder, ");
TypeReference _typeRef_3 = TypeReference.typeRef("org.antlr.runtime.TokenStream");
_builder.append(_typeRef_3, "\t");
_builder.append(" tokenStream) {");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("return new ");
TypeReference _psiInternalParser = IdeaPluginGenerator.this._ideaPluginClassNames.getPsiInternalParser(grammar);
_builder.append(_psiInternalParser, "\t\t");
_builder.append("(builder, tokenStream, elementTypeProvider, grammarAccess);");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("\t");
_builder.append("@");
_builder.append(Override.class, "\t");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("protected ");
_builder.append(Set.class, "\t");
_builder.append("<");
_builder.append(String.class, "\t");
_builder.append("> getInitialHiddenTokens() {");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("return INITIAL_HIDDEN_TOKENS;");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
}
};
return this.fileAccessFactory.createJavaFile(_psiParser, _client);
}
use of org.eclipse.xtend2.lib.StringConcatenationClient in project xtext-core by eclipse.
the class IdeaPluginGenerator method compileStandaloneSetup.
public JavaFileAccess compileStandaloneSetup(final Grammar grammar) {
JavaFileAccess _xifexpression = null;
boolean _isGenerateXtendStub = this.isGenerateXtendStub();
if (_isGenerateXtendStub) {
TypeReference _ideaStandaloneSetup = this._xtextGeneratorNaming.getIdeaStandaloneSetup(grammar);
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("class ");
String _simpleName = IdeaPluginGenerator.this._xtextGeneratorNaming.getIdeaStandaloneSetup(grammar).getSimpleName();
_builder.append(_simpleName);
_builder.append(" extends ");
TypeReference _runtimeGenSetup = IdeaPluginGenerator.this._xtextGeneratorNaming.getRuntimeGenSetup(grammar);
_builder.append(_runtimeGenSetup);
_builder.append(" {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("override createInjector() {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("val runtimeModule = new ");
TypeReference _runtimeModule = IdeaPluginGenerator.this._xtextGeneratorNaming.getRuntimeModule(grammar);
_builder.append(_runtimeModule, "\t\t");
_builder.append("()");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("val ideaModule = new ");
TypeReference _ideaModule = IdeaPluginGenerator.this._xtextGeneratorNaming.getIdeaModule(grammar);
_builder.append(_ideaModule, "\t\t");
_builder.append("()");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("val mergedModule = ");
_builder.append(Modules2.class, "\t\t");
_builder.append(".mixin(runtimeModule, ideaModule)");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("return ");
_builder.append(Guice.class, "\t\t");
_builder.append(".createInjector(mergedModule)");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
}
};
_xifexpression = this.fileAccessFactory.createXtendFile(_ideaStandaloneSetup, _client);
} else {
TypeReference _ideaStandaloneSetup_1 = this._xtextGeneratorNaming.getIdeaStandaloneSetup(grammar);
StringConcatenationClient _client_1 = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("public class ");
String _simpleName = IdeaPluginGenerator.this._xtextGeneratorNaming.getIdeaStandaloneSetup(grammar).getSimpleName();
_builder.append(_simpleName);
_builder.append(" extends ");
TypeReference _runtimeGenSetup = IdeaPluginGenerator.this._xtextGeneratorNaming.getRuntimeGenSetup(grammar);
_builder.append(_runtimeGenSetup);
_builder.append(" {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("@Override");
_builder.newLine();
_builder.append("\t");
_builder.append("public ");
_builder.append(Injector.class, "\t");
_builder.append(" createInjector() {");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
TypeReference _runtimeModule = IdeaPluginGenerator.this._xtextGeneratorNaming.getRuntimeModule(grammar);
_builder.append(_runtimeModule, "\t\t");
_builder.append(" runtimeModule = new ");
TypeReference _runtimeModule_1 = IdeaPluginGenerator.this._xtextGeneratorNaming.getRuntimeModule(grammar);
_builder.append(_runtimeModule_1, "\t\t");
_builder.append("();");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
TypeReference _ideaModule = IdeaPluginGenerator.this._xtextGeneratorNaming.getIdeaModule(grammar);
_builder.append(_ideaModule, "\t\t");
_builder.append(" ideaModule = new ");
TypeReference _ideaModule_1 = IdeaPluginGenerator.this._xtextGeneratorNaming.getIdeaModule(grammar);
_builder.append(_ideaModule_1, "\t\t");
_builder.append("();");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append(com.google.inject.Module.class, "\t\t");
_builder.append(" mergedModule = ");
_builder.append(Modules2.class, "\t\t");
_builder.append(".mixin(runtimeModule, ideaModule);");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("return ");
_builder.append(Guice.class, "\t\t");
_builder.append(".createInjector(mergedModule);");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
}
};
_xifexpression = this.fileAccessFactory.createJavaFile(_ideaStandaloneSetup_1, _client_1);
}
return _xifexpression;
}
use of org.eclipse.xtend2.lib.StringConcatenationClient in project xtext-core by eclipse.
the class TextFileAccess method setContent.
public void setContent(final StringConcatenationClient content) {
StringConcatenation _stringConcatenation = new StringConcatenation();
final Procedure1<StringConcatenation> _function = (StringConcatenation it) -> {
it.append(content);
};
StringConcatenation _doubleArrow = ObjectExtensions.<StringConcatenation>operator_doubleArrow(_stringConcatenation, _function);
this.internalContents = _doubleArrow;
}
use of org.eclipse.xtend2.lib.StringConcatenationClient in project xtext-core by eclipse.
the class ContentAssistFragment2 method _assignmentTerminal.
private StringConcatenationClient _assignmentTerminal(final RuleCall element, final StringConcatenationClient accessor) {
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("completeRuleCall(((");
_builder.append(RuleCall.class);
_builder.append(")");
_builder.append(accessor);
_builder.append("), context, acceptor);");
_builder.newLineIfNotEmpty();
}
};
return _client;
}
Aggregations