use of org.eclipse.xtend2.lib.StringConcatenationClient in project xtext-core by eclipse.
the class IdeaPluginGenerator method compileFacetConfiguration.
public JavaFileAccess compileFacetConfiguration(final Grammar grammar) {
JavaFileAccess _xifexpression = null;
boolean _isGenerateXtendStub = this.isGenerateXtendStub();
if (_isGenerateXtendStub) {
_xifexpression = this.fileAccessFactory.createXtendFile(this._ideaPluginClassNames.getFacetConfiguration(grammar));
} else {
_xifexpression = this.fileAccessFactory.createJavaFile(this._ideaPluginClassNames.getFacetConfiguration(grammar));
}
final JavaFileAccess file = _xifexpression;
file.importType(TypeReference.typeRef("com.intellij.openapi.components.PersistentStateComponent"));
file.importType(TypeReference.typeRef("com.intellij.openapi.components.State"));
file.importType(TypeReference.typeRef("com.intellij.openapi.components.Storage"));
file.importType(TypeReference.typeRef("com.intellij.openapi.components.StoragePathMacros"));
file.importType(TypeReference.typeRef("com.intellij.openapi.components.StorageScheme"));
boolean _inheritsXbase = this._xbaseUsageDetector.inheritsXbase(grammar);
if (_inheritsXbase) {
file.importType(TypeReference.typeRef("org.eclipse.xtext.xbase.idea.facet.XbaseFacetConfiguration"));
file.importType(TypeReference.typeRef("org.eclipse.xtext.xbase.idea.facet.XbaseGeneratorConfigurationState"));
} else {
file.importType(TypeReference.typeRef("org.eclipse.xtext.idea.facet.AbstractFacetConfiguration"));
file.importType(TypeReference.typeRef("org.eclipse.xtext.idea.facet.GeneratorConfigurationState"));
}
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
{
boolean _isGenerateXtendStub = IdeaPluginGenerator.this.isGenerateXtendStub();
if (_isGenerateXtendStub) {
_builder.append("@State(name = \"");
String _name = grammar.getName();
_builder.append(_name);
_builder.append("Generator\", storages = #[");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("@Storage(id = \"default\", file = StoragePathMacros.PROJECT_FILE),");
_builder.newLine();
_builder.append("\t\t");
_builder.append("@Storage(id = \"dir\", file = StoragePathMacros.PROJECT_CONFIG_DIR");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("+ \"/");
String _simpleName = IdeaPluginGenerator.this._ideaPluginExtension.getSimpleName(grammar);
_builder.append(_simpleName, "\t\t\t\t");
_builder.append("GeneratorConfig.xml\", scheme = StorageScheme.DIRECTORY_BASED)])");
_builder.newLineIfNotEmpty();
} else {
_builder.append("@State(name = \"");
String _name_1 = grammar.getName();
_builder.append(_name_1);
_builder.append("Generator\", storages = {");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("@Storage(id = \"default\", file = StoragePathMacros.PROJECT_FILE),");
_builder.newLine();
_builder.append("\t\t");
_builder.append("@Storage(id = \"dir\", file = StoragePathMacros.PROJECT_CONFIG_DIR");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("+ \"/");
String _simpleName_1 = IdeaPluginGenerator.this._ideaPluginExtension.getSimpleName(grammar);
_builder.append(_simpleName_1, "\t\t\t\t");
_builder.append("GeneratorConfig.xml\", scheme = StorageScheme.DIRECTORY_BASED)})");
_builder.newLineIfNotEmpty();
}
}
{
boolean _isGenerateXtendStub_1 = IdeaPluginGenerator.this.isGenerateXtendStub();
boolean _not = (!_isGenerateXtendStub_1);
if (_not) {
_builder.append("public");
}
}
_builder.append(" class ");
String _simpleName_2 = IdeaPluginGenerator.this._ideaPluginClassNames.getFacetConfiguration(grammar).getSimpleName();
_builder.append(_simpleName_2);
_builder.append(" extends ");
{
boolean _inheritsXbase = IdeaPluginGenerator.this._xbaseUsageDetector.inheritsXbase(grammar);
if (_inheritsXbase) {
_builder.append("XbaseFacetConfiguration implements PersistentStateComponent<XbaseGeneratorConfigurationState>");
} else {
_builder.append("AbstractFacetConfiguration implements PersistentStateComponent<GeneratorConfigurationState>");
}
}
_builder.append("{");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("}");
_builder.newLine();
}
};
file.setContent(_client);
return file;
}
use of org.eclipse.xtend2.lib.StringConcatenationClient in project xtext-core by eclipse.
the class IdeaPluginGenerator method compilePomDeclarationSearcher.
public JavaFileAccess compilePomDeclarationSearcher(final Grammar it) {
TypeReference _pomDeclarationSearcher = this._ideaPluginClassNames.getPomDeclarationSearcher(it);
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("public class ");
String _simpleName = IdeaPluginGenerator.this._ideaPluginClassNames.getPomDeclarationSearcher(it).getSimpleName();
_builder.append(_simpleName);
_builder.append(" extends ");
TypeReference _typeRef = TypeReference.typeRef("org.eclipse.xtext.idea.pom.AbstractXtextPomDeclarationSearcher");
_builder.append(_typeRef);
_builder.append(" {");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("\t");
_builder.append("public ");
String _simpleName_1 = IdeaPluginGenerator.this._ideaPluginClassNames.getPomDeclarationSearcher(it).getSimpleName();
_builder.append(_simpleName_1, "\t");
_builder.append("() {");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("super(");
TypeReference _ideaLanguage = IdeaPluginGenerator.this._ideaPluginClassNames.getIdeaLanguage(IdeaPluginGenerator.this.getGrammar());
_builder.append(_ideaLanguage, "\t\t");
_builder.append(".INSTANCE);");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
}
};
return this.fileAccessFactory.createJavaFile(_pomDeclarationSearcher, _client);
}
use of org.eclipse.xtend2.lib.StringConcatenationClient in project xtext-core by eclipse.
the class IdeaPluginGenerator method compileFileTypeFactory.
public JavaFileAccess compileFileTypeFactory(final Grammar grammar) {
TypeReference _fileTypeFactory = this._ideaPluginClassNames.getFileTypeFactory(grammar);
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("public class ");
String _simpleName = IdeaPluginGenerator.this._ideaPluginClassNames.getFileTypeFactory(grammar).getSimpleName();
_builder.append(_simpleName);
_builder.append(" extends ");
TypeReference _typeRef = TypeReference.typeRef("com.intellij.openapi.fileTypes.FileTypeFactory");
_builder.append(_typeRef);
_builder.append(" {");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("\t");
_builder.append("@Override");
_builder.newLine();
_builder.append("\t");
_builder.append("public void createFileTypes(@");
TypeReference _typeRef_1 = TypeReference.typeRef("org.jetbrains.annotations.NotNull");
_builder.append(_typeRef_1, "\t");
_builder.append(" ");
TypeReference _typeRef_2 = TypeReference.typeRef("com.intellij.openapi.fileTypes.FileTypeConsumer");
_builder.append(_typeRef_2, "\t");
_builder.append(" consumer) {");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("consumer.consume(");
TypeReference _fileType = IdeaPluginGenerator.this._ideaPluginClassNames.getFileType(grammar);
_builder.append(_fileType, "\t\t");
_builder.append(".INSTANCE, ");
TypeReference _abstractFileType = IdeaPluginGenerator.this._ideaPluginClassNames.getAbstractFileType(grammar);
_builder.append(_abstractFileType, "\t\t");
_builder.append(".DEFAULT_EXTENSION);");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("}");
_builder.newLine();
}
};
return this.fileAccessFactory.createJavaFile(_fileTypeFactory, _client);
}
use of org.eclipse.xtend2.lib.StringConcatenationClient in project xtext-core by eclipse.
the class IdeaPluginGenerator method generate.
@Override
public void generate() {
boolean _isEnabled = this.getProjectConfig().getIdeaPlugin().isEnabled();
boolean _not = (!_isEnabled);
if (_not) {
return;
}
final String fileExtension = IterableExtensions.<String>head(this.getLanguage().getFileExtensions());
final Grammar grammar = this.getLanguage().getGrammar();
final GuiceModuleAccess.BindingFactory bindFactory = new GuiceModuleAccess.BindingFactory();
bindFactory.addTypeToType(TypeReference.typeRef("org.eclipse.xtext.parser.antlr.IAntlrTokenFileProvider"), this._ideaPluginClassNames.getAntlrTokenFileProvider(grammar));
bindFactory.addTypeToType(TypeReference.typeRef("org.eclipse.xtext.parser.antlr.Lexer"), this._ideaPluginClassNames.getPsiInternalLexer(grammar));
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("binder.bind(");
_builder.append(Lexer.class);
_builder.append(".class)");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append(".annotatedWith(");
_builder.append(Names.class, "\t");
_builder.append(".named(");
_builder.append(LexerBindings.class, "\t");
_builder.append(".RUNTIME))");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append(".to(");
TypeReference _psiInternalLexer = IdeaPluginGenerator.this._ideaPluginClassNames.getPsiInternalLexer(grammar);
_builder.append(_psiInternalLexer, "\t");
_builder.append(".class);");
_builder.newLineIfNotEmpty();
}
};
bindFactory.addConfiguredBinding("RuntimeLexer", _client);
bindFactory.addTypeToType(TypeReference.typeRef("com.intellij.lang.PsiParser"), this._ideaPluginClassNames.getPsiParser(grammar));
bindFactory.addTypeToType(TypeReference.typeRef("org.eclipse.xtext.idea.parser.TokenTypeProvider"), this._ideaPluginClassNames.getTokenTypeProvider(grammar));
bindFactory.addTypeToType(TypeReference.typeRef("com.intellij.lang.ParserDefinition"), this._ideaPluginClassNames.getParserDefinition(grammar));
bindFactory.addTypeToTypeSingleton(TypeReference.typeRef("org.eclipse.xtext.idea.lang.IElementTypeProvider"), this._ideaPluginClassNames.getElementTypeProvider(grammar));
bindFactory.addTypeToType(TypeReference.typeRef("org.eclipse.xtext.idea.facet.AbstractFacetConfiguration"), this._ideaPluginClassNames.getFacetConfiguration(grammar));
TypeReference _typeRef = TypeReference.typeRef("com.intellij.facet.FacetTypeId");
StringConcatenationClient _client_1 = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
TypeReference _facetType = IdeaPluginGenerator.this._ideaPluginClassNames.getFacetType(grammar);
_builder.append(_facetType);
_builder.append(".TYPEID");
}
};
bindFactory.addTypeToInstance(_typeRef, _client_1);
bindFactory.addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ide.editor.contentassist.antlr.IContentAssistParser"), this.caNaming.getParserClass(grammar));
StringConcatenationClient _client_2 = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("binder.bind(");
TypeReference _typeRef = TypeReference.typeRef("org.eclipse.xtext.ide.editor.contentassist.antlr.internal.Lexer");
_builder.append(_typeRef);
_builder.append(".class).annotatedWith(");
_builder.append(Names.class);
_builder.append(".named(");
TypeReference _typeRef_1 = TypeReference.typeRef("org.eclipse.xtext.ide.LexerIdeBindings");
_builder.append(_typeRef_1);
_builder.append(".CONTENT_ASSIST)).to(");
TypeReference _lexerClass = IdeaPluginGenerator.this.caNaming.getLexerClass(grammar);
_builder.append(_lexerClass);
_builder.append(".class);");
}
};
bindFactory.addConfiguredBinding("ContentAssistLexer", _client_2);
boolean _inheritsXbase = this._xbaseUsageDetector.inheritsXbase(grammar);
if (_inheritsXbase) {
bindFactory.addTypeToType(TypeReference.typeRef("org.eclipse.xtext.common.types.xtext.AbstractTypeScopeProvider"), TypeReference.typeRef("org.eclipse.xtext.idea.common.types.StubBasedTypeScopeProvider"));
TypeReference _typeReference = new TypeReference("org.eclipse.xtext.xbase.typesystem.internal", "IFeatureScopeTracker.Provider");
bindFactory.addTypeToType(_typeReference, TypeReference.typeRef("org.eclipse.xtext.xbase.typesystem.internal.OptimizingFeatureScopeTrackerProvider"));
StringConcatenationClient _client_3 = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("binder.bind(");
TypeReference _typeRef = TypeReference.typeRef("org.eclipse.xtext.psi.IPsiModelAssociations");
_builder.append(_typeRef);
_builder.append(".class)");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append(".annotatedWith(");
_builder.append(LanguageSpecific.class, "\t");
_builder.append(".class)");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append(".to(");
TypeReference _typeRef_1 = TypeReference.typeRef("org.eclipse.xtext.idea.common.types.DerivedMemberAwarePsiModelAssociations");
_builder.append(_typeRef_1, "\t");
_builder.append(".class);");
_builder.newLineIfNotEmpty();
}
};
bindFactory.addConfiguredBinding("LanguageSpecificPsiModelAssociations", _client_3);
bindFactory.addTypeToType(TypeReference.typeRef("org.eclipse.xtext.idea.highlighting.IHighlightingConfiguration"), TypeReference.typeRef("org.eclipse.xtext.xbase.idea.highlighting.XbaseHighlightingConfiguration"));
bindFactory.addTypeToType(TypeReference.typeRef("org.eclipse.xtext.idea.formatting.BlockFactory"), TypeReference.typeRef("org.eclipse.xtext.xbase.idea.formatting.XbaseBlockFactory"));
bindFactory.addTypeToType(TypeReference.typeRef("org.eclipse.xtext.idea.formatting.ChildAttributesProvider"), TypeReference.typeRef("org.eclipse.xtext.xbase.idea.formatting.XbaseChildAttributesProvider"));
bindFactory.addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ide.editor.bracketmatching.IBracePairProvider"), TypeReference.typeRef("org.eclipse.xtext.xbase.idea.bracketmatching.XbaseBracePairProvider"));
bindFactory.addTypeToType(TypeReference.typeRef("org.eclipse.xtext.idea.findusages.IReferenceSearcher"), TypeReference.typeRef("org.eclipse.xtext.xbase.idea.findusages.JvmElementAwareReferenceSearcher"));
bindFactory.addTypeToType(TypeReference.typeRef("org.eclipse.xtext.xbase.compiler.IGeneratorConfigProvider"), TypeReference.typeRef("org.eclipse.xtext.xbase.idea.facet.XbaseGeneratorConfigProvider"));
TypeReference _typeRef_1 = TypeReference.typeRef("org.eclipse.xtext.idea.findusages.WordsScannerProvider");
TypeReference _typeReference_1 = new TypeReference("org.eclipse.xtext.xbase.idea.findusages", "XbaseWordsScanner.XbaseWordsScannerProvider");
bindFactory.addTypeToType(_typeRef_1, _typeReference_1);
}
bindFactory.contributeTo(this.getLanguage().getIdeaGenModule());
JavaFileAccess _compileStandaloneSetup = this.compileStandaloneSetup(grammar);
JavaFileAccess _compileIdeaSetup = this.compileIdeaSetup(grammar);
JavaFileAccess _compileCompletionContributor = this.compileCompletionContributor(grammar);
JavaFileAccess _compileFileType = this.compileFileType(grammar);
JavaFileAccess _compileFacetConfiguration = this.compileFacetConfiguration(grammar);
JavaFileAccess _compileColorSettingsPage = this.compileColorSettingsPage(grammar);
final Consumer<JavaFileAccess> _function = (JavaFileAccess it) -> {
it.writeTo(this.getProjectConfig().getIdeaPlugin().getSrc());
};
Collections.<JavaFileAccess>unmodifiableList(CollectionLiterals.<JavaFileAccess>newArrayList(_compileStandaloneSetup, _compileIdeaSetup, _compileCompletionContributor, _compileFileType, _compileFacetConfiguration, _compileColorSettingsPage)).forEach(_function);
TextFileAccess _compileServicesISetup = this.compileServicesISetup(grammar);
JavaFileAccess _compileAbstractCompletionContributor = this.compileAbstractCompletionContributor(grammar);
JavaFileAccess _compileLanguage = this.compileLanguage(grammar);
JavaFileAccess _compileAbstractFileType = this.compileAbstractFileType(grammar, fileExtension);
JavaFileAccess _compileFileTypeFactory = this.compileFileTypeFactory(grammar);
JavaFileAccess _compileFileImpl = this.compileFileImpl(grammar);
JavaFileAccess _compileTokenTypeProvider = this.compileTokenTypeProvider(grammar);
JavaFileAccess _compileElementTypeProvider = this.compileElementTypeProvider(grammar);
JavaFileAccess _compileParserDefinition = this.compileParserDefinition(grammar);
JavaFileAccess _compileSyntaxHighlighterFactory = this.compileSyntaxHighlighterFactory(grammar);
JavaFileAccess _compileSemanticHighlightVisitor = this.compileSemanticHighlightVisitor(grammar);
JavaFileAccess _compileExtensionFactory = this.compileExtensionFactory(grammar);
JavaFileAccess _compileCodeBlockModificationListener = this.compileCodeBlockModificationListener(grammar);
JavaFileAccess _compilePsiParser = this.compilePsiParser(grammar);
JavaFileAccess _compileAntlrTokenFileProvider = this.compileAntlrTokenFileProvider(grammar);
JavaFileAccess _compilePomDeclarationSearcher = this.compilePomDeclarationSearcher(grammar);
JavaFileAccess _compileFacetType = this.compileFacetType(grammar);
JavaFileAccess _compileBaseColorSettingsPage = this.compileBaseColorSettingsPage(grammar);
final Consumer<TextFileAccess> _function_1 = (TextFileAccess it) -> {
it.writeTo(this.getProjectConfig().getIdeaPlugin().getSrcGen());
};
Collections.<TextFileAccess>unmodifiableList(CollectionLiterals.<TextFileAccess>newArrayList(_compileServicesISetup, _compileAbstractCompletionContributor, _compileLanguage, _compileAbstractFileType, _compileFileTypeFactory, _compileFileImpl, _compileTokenTypeProvider, _compileElementTypeProvider, _compileParserDefinition, _compileSyntaxHighlighterFactory, _compileSemanticHighlightVisitor, _compileExtensionFactory, _compileCodeBlockModificationListener, _compilePsiParser, _compileAntlrTokenFileProvider, _compilePomDeclarationSearcher, _compileFacetType, _compileBaseColorSettingsPage)).forEach(_function_1);
if (this.deployable) {
final TextFileAccess pluginXml = this.compilePluginXml(grammar);
boolean _isFile = this.getProjectConfig().getIdeaPlugin().getMetaInf().isFile(pluginXml.getPath());
boolean _not_1 = (!_isFile);
if (_not_1) {
pluginXml.writeTo(this.getProjectConfig().getIdeaPlugin().getMetaInf());
}
this.compilePluginGenXml(grammar).writeTo(this.getProjectConfig().getIdeaPlugin().getMetaInf());
}
}
use of org.eclipse.xtend2.lib.StringConcatenationClient in project xtext-core by eclipse.
the class IdeaPluginGenerator method compileFileImpl.
public JavaFileAccess compileFileImpl(final Grammar grammar) {
TypeReference _fileImpl = this._ideaPluginClassNames.getFileImpl(grammar);
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("public final class ");
String _simpleName = IdeaPluginGenerator.this._ideaPluginClassNames.getFileImpl(grammar).getSimpleName();
_builder.append(_simpleName);
_builder.append(" extends ");
TypeReference _typeRef = TypeReference.typeRef("org.eclipse.xtext.psi.impl.BaseXtextFile");
_builder.append(_typeRef);
_builder.append(" {");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("\t");
_builder.append("public ");
String _simpleName_1 = IdeaPluginGenerator.this._ideaPluginClassNames.getFileImpl(grammar).getSimpleName();
_builder.append(_simpleName_1, "\t");
_builder.append("(");
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("super(viewProvider, ");
TypeReference _ideaLanguage = IdeaPluginGenerator.this._ideaPluginClassNames.getIdeaLanguage(grammar);
_builder.append(_ideaLanguage, "\t\t");
_builder.append(".INSTANCE);");
_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_2 = TypeReference.typeRef("com.intellij.openapi.fileTypes.FileType");
_builder.append(_typeRef_2, "\t");
_builder.append(" getFileType() {");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("return ");
TypeReference _fileType = IdeaPluginGenerator.this._ideaPluginClassNames.getFileType(grammar);
_builder.append(_fileType, "\t\t");
_builder.append(".INSTANCE;");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
}
};
return this.fileAccessFactory.createJavaFile(_fileImpl, _client);
}
Aggregations