use of org.eclipse.xtext.xtext.generator.model.ManifestAccess in project xtext-core by eclipse.
the class XtextAntlrGeneratorFragment2 method addUiBindingsAndImports.
protected void addUiBindingsAndImports() {
@Extension final ContentAssistGrammarNaming naming = this.contentAssistNaming;
final TypeReference caLexerClass = naming.getLexerClass(this.getGrammar());
ManifestAccess _manifest = this.getProjectConfig().getGenericIde().getManifest();
boolean _tripleNotEquals = (_manifest != null);
if (_tripleNotEquals) {
ManifestAccess _manifest_1 = this.getProjectConfig().getGenericIde().getManifest();
final Procedure1<ManifestAccess> _function = (ManifestAccess it) -> {
Set<String> _exportedPackages = it.getExportedPackages();
String _packageName = caLexerClass.getPackageName();
String _packageName_1 = naming.getParserClass(this.getGrammar()).getPackageName();
String _packageName_2 = naming.getInternalParserClass(this.getGrammar()).getPackageName();
Iterables.<String>addAll(_exportedPackages, Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList(_packageName, _packageName_1, _packageName_2)));
};
ObjectExtensions.<ManifestAccess>operator_doubleArrow(_manifest_1, _function);
}
GuiceModuleAccess.BindingFactory _addTypeToType = new GuiceModuleAccess.BindingFactory().addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ui.editor.contentassist.IProposalConflictHelper"), TypeReference.typeRef("org.eclipse.xtext.ui.editor.contentassist.antlr.AntlrProposalConflictHelper"));
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("binder.bind(");
TypeReference _lexerSuperClass = naming.getLexerSuperClass(XtextAntlrGeneratorFragment2.this.getGrammar());
_builder.append(_lexerSuperClass);
_builder.append(".class)");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append(".annotatedWith(");
_builder.append(Names.class, "\t");
_builder.append(".named(");
TypeReference _typeRef = TypeReference.typeRef("org.eclipse.xtext.ide.LexerIdeBindings");
_builder.append(_typeRef, "\t");
_builder.append(".CONTENT_ASSIST))");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append(".to(");
_builder.append(caLexerClass, "\t");
_builder.append(".class);");
_builder.newLineIfNotEmpty();
}
};
GuiceModuleAccess.BindingFactory _addConfiguredBinding = _addTypeToType.addConfiguredBinding("ContentAssistLexer", _client);
StringConcatenationClient _client_1 = 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(");
TypeReference _typeRef = TypeReference.typeRef("org.eclipse.xtext.ide.LexerIdeBindings");
_builder.append(_typeRef, "\t");
_builder.append(".HIGHLIGHTING))");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append(".to(");
TypeReference _lexerClass = XtextAntlrGeneratorFragment2.this.productionNaming.getLexerClass(XtextAntlrGeneratorFragment2.this.getGrammar());
_builder.append(_lexerClass, "\t");
_builder.append(".class);");
_builder.newLineIfNotEmpty();
}
};
GuiceModuleAccess.BindingFactory _addConfiguredBinding_1 = _addConfiguredBinding.addConfiguredBinding("HighlightingLexer", _client_1);
StringConcatenationClient _client_2 = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("binder.bind(");
_builder.append(ITokenDefProvider.class);
_builder.append(".class)");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append(".annotatedWith(");
_builder.append(Names.class, "\t");
_builder.append(".named(");
TypeReference _typeRef = TypeReference.typeRef("org.eclipse.xtext.ide.LexerIdeBindings");
_builder.append(_typeRef, "\t");
_builder.append(".HIGHLIGHTING))");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append(".to(");
_builder.append(AntlrTokenDefProvider.class, "\t");
_builder.append(".class);");
_builder.newLineIfNotEmpty();
}
};
GuiceModuleAccess.BindingFactory _addConfiguredBinding_2 = _addConfiguredBinding_1.addConfiguredBinding("HighlightingTokenDefProvider", _client_2);
TypeReference _typeReference = new TypeReference("org.eclipse.xtext.ui.editor.contentassist", "ContentAssistContext.Factory");
GuiceModuleAccess.BindingFactory _addTypeToType_1 = _addConfiguredBinding_2.addTypeToType(_typeReference, TypeReference.typeRef("org.eclipse.xtext.ui.editor.contentassist.antlr.DelegatingContentAssistContextFactory")).addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ide.editor.contentassist.antlr.IContentAssistParser"), naming.getParserClass(this.getGrammar()));
StringConcatenationClient _client_3 = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("binder.bind(");
_builder.append(caLexerClass);
_builder.append(".class).toProvider(");
_builder.append(LexerProvider.class);
_builder.append(".create(");
_builder.append(caLexerClass);
_builder.append(".class));");
_builder.newLineIfNotEmpty();
}
};
final GuiceModuleAccess.BindingFactory uiBindings = _addTypeToType_1.addConfiguredBinding("ContentAssistLexerProvider", _client_3);
boolean _hasSyntheticTerminalRule = this.hasSyntheticTerminalRule();
if (_hasSyntheticTerminalRule) {
uiBindings.addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ide.editor.contentassist.CompletionPrefixProvider"), TypeReference.typeRef("org.eclipse.xtext.ide.editor.contentassist.IndentationAwareCompletionPrefixProvider"));
}
uiBindings.contributeTo(this.getLanguage().getEclipsePluginGenModule());
}
use of org.eclipse.xtext.xtext.generator.model.ManifestAccess in project xtext-core by eclipse.
the class XtextAntlrGeneratorFragment2 method addIdeBindingsAndImports.
protected void addIdeBindingsAndImports() {
@Extension final ContentAssistGrammarNaming naming = this.contentAssistNaming;
ManifestAccess _manifest = this.getProjectConfig().getGenericIde().getManifest();
boolean _tripleNotEquals = (_manifest != null);
if (_tripleNotEquals) {
ManifestAccess _manifest_1 = this.getProjectConfig().getGenericIde().getManifest();
final Procedure1<ManifestAccess> _function = (ManifestAccess it) -> {
Set<String> _exportedPackages = it.getExportedPackages();
String _packageName = naming.getLexerClass(this.getGrammar()).getPackageName();
String _packageName_1 = naming.getParserClass(this.getGrammar()).getPackageName();
String _packageName_2 = naming.getInternalParserClass(this.getGrammar()).getPackageName();
Iterables.<String>addAll(_exportedPackages, Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList(_packageName, _packageName_1, _packageName_2)));
Set<String> _requiredBundles = it.getRequiredBundles();
_requiredBundles.add("org.antlr.runtime");
};
ObjectExtensions.<ManifestAccess>operator_doubleArrow(_manifest_1, _function);
}
GuiceModuleAccess.BindingFactory _bindingFactory = new GuiceModuleAccess.BindingFactory();
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("binder.bind(");
TypeReference _lexerSuperClass = naming.getLexerSuperClass(XtextAntlrGeneratorFragment2.this.getGrammar());
_builder.append(_lexerSuperClass);
_builder.append(".class)");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append(".annotatedWith(");
_builder.append(Names.class, "\t");
_builder.append(".named(");
TypeReference _typeRef = TypeReference.typeRef("org.eclipse.xtext.ide.LexerIdeBindings");
_builder.append(_typeRef, "\t");
_builder.append(".CONTENT_ASSIST))");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append(".to(");
TypeReference _lexerClass = naming.getLexerClass(XtextAntlrGeneratorFragment2.this.getGrammar());
_builder.append(_lexerClass, "\t");
_builder.append(".class);");
_builder.newLineIfNotEmpty();
}
};
final GuiceModuleAccess.BindingFactory ideBindings = _bindingFactory.addConfiguredBinding("ContentAssistLexer", _client).addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ide.editor.contentassist.antlr.IContentAssistParser"), naming.getParserClass(this.getGrammar())).addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ide.editor.contentassist.IProposalConflictHelper"), TypeReference.typeRef("org.eclipse.xtext.ide.editor.contentassist.antlr.AntlrProposalConflictHelper"));
if (this.partialParsing) {
ideBindings.addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ide.editor.contentassist.antlr.ContentAssistContextFactory"), TypeReference.typeRef("org.eclipse.xtext.ide.editor.contentassist.antlr.PartialContentAssistContextFactory"));
}
boolean _hasSyntheticTerminalRule = this.hasSyntheticTerminalRule();
if (_hasSyntheticTerminalRule) {
ideBindings.addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ide.editor.contentassist.CompletionPrefixProvider"), TypeReference.typeRef("org.eclipse.xtext.ide.editor.contentassist.IndentationAwareCompletionPrefixProvider"));
}
ideBindings.contributeTo(this.getLanguage().getIdeGenModule());
}
use of org.eclipse.xtext.xtext.generator.model.ManifestAccess in project xtext-core by eclipse.
the class ImportNamespacesScopingFragment2 method generate.
@Override
public void generate() {
this.contributeRuntimeGuiceBindings();
this.generateGenScopeProvider();
boolean _isGenerateStub = this.isGenerateStub();
if (_isGenerateStub) {
boolean _isGenerateXtendStub = this.isGenerateXtendStub();
if (_isGenerateXtendStub) {
this.generateXtendScopeProvider();
} else {
this.generateJavaScopeProvider();
}
ManifestAccess _manifest = this.getProjectConfig().getRuntime().getManifest();
boolean _tripleNotEquals = (_manifest != null);
if (_tripleNotEquals) {
Set<String> _exportedPackages = this.getProjectConfig().getRuntime().getManifest().getExportedPackages();
String _packageName = this.getScopeProviderClass(this.getGrammar()).getPackageName();
_exportedPackages.add(_packageName);
boolean _isGenerateXtendStub_1 = this.isGenerateXtendStub();
if (_isGenerateXtendStub_1) {
Set<String> _requiredBundles = this.getProjectConfig().getRuntime().getManifest().getRequiredBundles();
String _xbaseLibVersionLowerBound = this.getProjectConfig().getRuntime().getXbaseLibVersionLowerBound();
String _plus = ("org.eclipse.xtext.xbase.lib;bundle-version=\"" + _xbaseLibVersionLowerBound);
String _plus_1 = (_plus + "\"");
_requiredBundles.add(_plus_1);
}
}
}
}
use of org.eclipse.xtext.xtext.generator.model.ManifestAccess in project xtext-core by eclipse.
the class SerializerFragment2 method generate.
@Override
public void generate() {
new GuiceModuleAccess.BindingFactory().addTypeToType(TypeReference.typeRef(ISemanticSequencer.class), this.getSemanticSequencerClass(this.getGrammar())).addTypeToType(TypeReference.typeRef(ISyntacticSequencer.class), this.getSyntacticSequencerClass(this.getGrammar())).addTypeToType(TypeReference.typeRef(ISerializer.class), TypeReference.typeRef(Serializer.class)).contributeTo(this.getLanguage().getRuntimeGenModule());
ManifestAccess _manifest = this.getProjectConfig().getRuntime().getManifest();
boolean _tripleNotEquals = (_manifest != null);
if (_tripleNotEquals) {
Set<String> _exportedPackages = this.getProjectConfig().getRuntime().getManifest().getExportedPackages();
String _serializerBasePackage = this.getSerializerBasePackage(this.getGrammar());
_exportedPackages.add(_serializerBasePackage);
Set<String> _requiredBundles = this.getProjectConfig().getRuntime().getManifest().getRequiredBundles();
String _xbaseLibVersionLowerBound = this.getProjectConfig().getRuntime().getXbaseLibVersionLowerBound();
String _plus = ("org.eclipse.xtext.xbase.lib;bundle-version=\"" + _xbaseLibVersionLowerBound);
String _plus_1 = (_plus + "\"");
_requiredBundles.add(_plus_1);
}
this.generateAbstractSemanticSequencer();
this.generateAbstractSyntacticSequencer();
boolean _isGenerateStub = this.isGenerateStub();
if (_isGenerateStub) {
this.generateSemanticSequencer();
this.generateSyntacticSequencer();
}
if (this.generateDebugData) {
this.generateGrammarConstraints();
Iterable<Pair<String, String>> _generateDebugGraphs = this.debugGraphGenerator.generateDebugGraphs();
for (final Pair<String, String> fileToContent : _generateDebugGraphs) {
this.getProjectConfig().getRuntime().getSrcGen().generateFile(fileToContent.getKey(), fileToContent.getValue());
}
}
}
use of org.eclipse.xtext.xtext.generator.model.ManifestAccess in project xtext-core by eclipse.
the class CodeMiningFragment method generate.
@Override
public void generate() {
ManifestAccess _manifest = this.getProjectConfig().getEclipsePlugin().getManifest();
boolean _tripleNotEquals = (_manifest != null);
if (_tripleNotEquals) {
Set<String> _importedPackages = this.getProjectConfig().getEclipsePlugin().getManifest().getImportedPackages();
_importedPackages.add("org.eclipse.xtext.ui.codemining;resolution:=optional");
}
GuiceModuleAccess.BindingFactory _bindingFactory = new GuiceModuleAccess.BindingFactory();
final Procedure1<GuiceModuleAccess.BindingFactory> _function = (GuiceModuleAccess.BindingFactory it) -> {
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("try {");
_builder.newLine();
_builder.append("\t");
_builder.append("Class.forName(\"org.eclipse.jface.text.codemining.ICodeMiningProvider\");");
_builder.newLine();
_builder.append("\t");
_builder.append("binder.bind(");
TypeReference _typeRef = TypeReference.typeRef("org.eclipse.jface.text.codemining.ICodeMiningProvider");
_builder.append(_typeRef, "\t");
_builder.append(".class)");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append(".to(");
TypeReference _codeMiningProviderClass = CodeMiningFragment.this.getCodeMiningProviderClass();
_builder.append(_codeMiningProviderClass, "\t\t");
_builder.append(".class);");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("binder.bind(");
TypeReference _typeRef_1 = TypeReference.typeRef("org.eclipse.xtext.ui.editor.reconciler.IReconcileStrategyFactory");
_builder.append(_typeRef_1, "\t");
_builder.append(".class).annotatedWith(");
TypeReference _typeRef_2 = TypeReference.typeRef(Names.class);
_builder.append(_typeRef_2, "\t");
_builder.append(".named(\"codeMinding\"))");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append(".to(");
TypeReference _typeRef_3 = TypeReference.typeRef("org.eclipse.xtext.ui.codemining.XtextCodeMiningReconcileStrategy");
_builder.append(_typeRef_3, "\t\t");
_builder.append(".Factory.class);");
_builder.newLineIfNotEmpty();
_builder.append("} catch(");
TypeReference _typeRef_4 = TypeReference.typeRef(ClassNotFoundException.class);
_builder.append(_typeRef_4);
_builder.append(" ignore) {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("// no bindings if code mining is not available at runtime");
_builder.newLine();
_builder.append("}");
_builder.newLine();
}
};
it.addConfiguredBinding("CodeMinding", _client);
it.contributeTo(this.getLanguage().getEclipsePluginGenModule());
};
ObjectExtensions.<GuiceModuleAccess.BindingFactory>operator_doubleArrow(_bindingFactory, _function);
boolean _isGenerateXtendStub = this.isGenerateXtendStub();
if (_isGenerateXtendStub) {
this.generateXtendCodeMiningProvider();
} else {
this.generateJavaCodeMiningProvider();
}
PluginXmlAccess _pluginXml = this.getProjectConfig().getEclipsePlugin().getPluginXml();
boolean _tripleNotEquals_1 = (_pluginXml != null);
if (_tripleNotEquals_1) {
List<CharSequence> _entries = this.getProjectConfig().getEclipsePlugin().getPluginXml().getEntries();
StringConcatenation _builder = new StringConcatenation();
_builder.append("<!-- code mining -->");
_builder.newLine();
_builder.append("<extension point=\"org.eclipse.ui.workbench.texteditor.codeMiningProviders\">");
_builder.newLine();
_builder.append("\t");
_builder.append("<codeMiningProvider");
_builder.newLine();
_builder.append("\t\t");
_builder.append("class=\"");
TypeReference _eclipsePluginExecutableExtensionFactory = this._xtextGeneratorNaming.getEclipsePluginExecutableExtensionFactory(this.getGrammar());
_builder.append(_eclipsePluginExecutableExtensionFactory, "\t\t");
_builder.append(":org.eclipse.jface.text.codemining.ICodeMiningProvider\"");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("id=\"");
String _name = this.getGrammar().getName();
_builder.append(_name, "\t\t");
_builder.append(".CodeMiningProvider\"");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("label=\"");
String _simpleName = GrammarUtil.getSimpleName(this.getGrammar());
_builder.append(_simpleName, "\t\t");
_builder.append(" Codemining\">");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("<enabledWhen>");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("<with variable=\"editorInput\">");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("<adapt type=\"org.eclipse.core.resources.IFile\">");
_builder.newLine();
_builder.append("\t\t\t\t\t");
_builder.append("<test");
_builder.newLine();
_builder.append("\t\t\t\t\t\t");
_builder.append("property=\"org.eclipse.core.resources.contentTypeId\"");
_builder.newLine();
_builder.append("\t\t\t\t\t\t");
_builder.append("value=\"");
String _name_1 = this.getGrammar().getName();
_builder.append(_name_1, "\t\t\t\t\t\t");
_builder.append(".contenttype\">");
_builder.newLineIfNotEmpty();
_builder.append("\t\t\t\t\t");
_builder.append("</test>");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("</adapt>");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("</with>");
_builder.newLine();
_builder.append("\t\t");
_builder.append("</enabledWhen>");
_builder.newLine();
_builder.append("\t");
_builder.append("</codeMiningProvider>");
_builder.newLine();
_builder.append("</extension>");
_builder.newLine();
_entries.add(_builder.toString());
}
}
Aggregations