use of org.eclipse.xtext.xtext.generator.model.JavaFileAccess 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.xtext.xtext.generator.model.JavaFileAccess 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.xtext.xtext.generator.model.JavaFileAccess in project xtext-core by eclipse.
the class IdeaPluginGenerator method compileFileType.
public JavaFileAccess compileFileType(final Grammar grammar) {
JavaFileAccess _xifexpression = null;
boolean _isGenerateXtendStub = this.isGenerateXtendStub();
if (_isGenerateXtendStub) {
TypeReference _fileType = this._ideaPluginClassNames.getFileType(grammar);
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("class ");
String _simpleName = IdeaPluginGenerator.this._ideaPluginClassNames.getFileType(grammar).getSimpleName();
_builder.append(_simpleName);
_builder.append(" extends ");
TypeReference _abstractFileType = IdeaPluginGenerator.this._ideaPluginClassNames.getAbstractFileType(grammar);
_builder.append(_abstractFileType);
_builder.append(" {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("public static final ");
String _simpleName_1 = IdeaPluginGenerator.this._ideaPluginClassNames.getFileType(grammar).getSimpleName();
_builder.append(_simpleName_1, "\t");
_builder.append(" INSTANCE = new ");
String _simpleName_2 = IdeaPluginGenerator.this._ideaPluginClassNames.getFileType(grammar).getSimpleName();
_builder.append(_simpleName_2, "\t");
_builder.append("()");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("new() {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("super(");
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.append("}");
_builder.newLine();
}
};
_xifexpression = this.fileAccessFactory.createXtendFile(_fileType, _client);
} else {
TypeReference _fileType_1 = this._ideaPluginClassNames.getFileType(grammar);
StringConcatenationClient _client_1 = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("public class ");
String _simpleName = IdeaPluginGenerator.this._ideaPluginClassNames.getFileType(grammar).getSimpleName();
_builder.append(_simpleName);
_builder.append(" extends ");
TypeReference _abstractFileType = IdeaPluginGenerator.this._ideaPluginClassNames.getAbstractFileType(grammar);
_builder.append(_abstractFileType);
_builder.append(" {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("public static final ");
String _simpleName_1 = IdeaPluginGenerator.this._ideaPluginClassNames.getFileType(grammar).getSimpleName();
_builder.append(_simpleName_1, "\t");
_builder.append(" INSTANCE = new ");
String _simpleName_2 = IdeaPluginGenerator.this._ideaPluginClassNames.getFileType(grammar).getSimpleName();
_builder.append(_simpleName_2, "\t");
_builder.append("();");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("public ");
String _simpleName_3 = IdeaPluginGenerator.this._ideaPluginClassNames.getFileType(grammar).getSimpleName();
_builder.append(_simpleName_3, "\t");
_builder.append("() {");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("super(");
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.append("}");
_builder.newLine();
}
};
_xifexpression = this.fileAccessFactory.createJavaFile(_fileType_1, _client_1);
}
return _xifexpression;
}
use of org.eclipse.xtext.xtext.generator.model.JavaFileAccess in project xtext-core by eclipse.
the class IdeaPluginGenerator method compileIdeaSetup.
public JavaFileAccess compileIdeaSetup(final Grammar grammar) {
JavaFileAccess _xifexpression = null;
boolean _isGenerateXtendStub = this.isGenerateXtendStub();
if (_isGenerateXtendStub) {
TypeReference _ideaSetup = this._ideaPluginClassNames.getIdeaSetup(grammar);
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("class ");
String _simpleName = IdeaPluginGenerator.this._ideaPluginClassNames.getIdeaSetup(grammar).getSimpleName();
_builder.append(_simpleName);
_builder.append(" implements ");
_builder.append(ISetup.class);
_builder.append(" {");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("\t");
_builder.append("override createInjectorAndDoEMFRegistration() {");
_builder.newLine();
_builder.append("\t\t");
TypeReference _typeRef = TypeReference.typeRef("org.eclipse.xtext.idea.extensions.EcoreGlobalRegistries");
_builder.append(_typeRef, "\t\t");
_builder.append(".ensureInitialized");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("new ");
TypeReference _ideaStandaloneSetup = IdeaPluginGenerator.this._xtextGeneratorNaming.getIdeaStandaloneSetup(grammar);
_builder.append(_ideaStandaloneSetup, "\t\t");
_builder.append("().createInjector");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("}");
_builder.newLine();
}
};
_xifexpression = this.fileAccessFactory.createXtendFile(_ideaSetup, _client);
} else {
TypeReference _ideaSetup_1 = this._ideaPluginClassNames.getIdeaSetup(grammar);
StringConcatenationClient _client_1 = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("public class ");
String _simpleName = IdeaPluginGenerator.this._ideaPluginClassNames.getIdeaSetup(grammar).getSimpleName();
_builder.append(_simpleName);
_builder.append(" implements ");
_builder.append(ISetup.class);
_builder.append(" {");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("\t");
_builder.append("@Override");
_builder.newLine();
_builder.append("\t");
_builder.append("public ");
_builder.append(Injector.class, "\t");
_builder.append(" createInjectorAndDoEMFRegistration() {");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
TypeReference _typeRef = TypeReference.typeRef("org.eclipse.xtext.idea.extensions.EcoreGlobalRegistries");
_builder.append(_typeRef, "\t\t");
_builder.append(".ensureInitialized();");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("return new ");
TypeReference _ideaStandaloneSetup = IdeaPluginGenerator.this._xtextGeneratorNaming.getIdeaStandaloneSetup(grammar);
_builder.append(_ideaStandaloneSetup, "\t\t");
_builder.append("().createInjector();");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("}");
_builder.newLine();
}
};
_xifexpression = this.fileAccessFactory.createJavaFile(_ideaSetup_1, _client_1);
}
return _xifexpression;
}
use of org.eclipse.xtext.xtext.generator.model.JavaFileAccess 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;
}
Aggregations