use of org.eclipse.xtext.xtext.generator.model.PluginXmlAccess in project xtext-core by eclipse.
the class EMFGeneratorFragment2 method addProjectContributions.
protected void addProjectContributions(final Grammar grammar, final List<EPackage> generatedPackages, final ResourceSet rs) {
PluginXmlAccess _pluginXml = this.getProjectConfig().getRuntime().getPluginXml();
boolean _tripleNotEquals = (_pluginXml != null);
if (_tripleNotEquals) {
List<CharSequence> _entries = this.getProjectConfig().getRuntime().getPluginXml().getEntries();
StringConcatenation _builder = new StringConcatenation();
_builder.append("<extension point=\"org.eclipse.emf.ecore.generated_package\">");
_builder.newLine();
{
for (final EPackage pack : generatedPackages) {
_builder.append("\t");
_builder.append("<package ");
_builder.newLine();
_builder.append("\t");
_builder.append("\t");
_builder.append("uri = \"");
String _nsURI = pack.getNsURI();
_builder.append(_nsURI, "\t\t");
_builder.append("\"");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t");
_builder.append("class = \"");
String _qualifiedPackageInterfaceName = GenModelUtil2.getGenPackage(pack, rs).getQualifiedPackageInterfaceName();
_builder.append(_qualifiedPackageInterfaceName, "\t\t");
_builder.append("\"");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t");
_builder.append("genModel = \"");
String _relativePath = this.getRelativePath(this.getGenModelPath(grammar));
_builder.append(_relativePath, "\t\t");
_builder.append("\" />");
_builder.newLineIfNotEmpty();
}
}
_builder.append("</extension>");
_builder.newLine();
_entries.add(_builder.toString());
}
ManifestAccess _manifest = this.getProjectConfig().getRuntime().getManifest();
boolean _tripleNotEquals_1 = (_manifest != null);
if (_tripleNotEquals_1) {
CollectionExtensions.<String>addAll(this.getProjectConfig().getRuntime().getManifest().getRequiredBundles(), "org.eclipse.emf.ecore", "org.eclipse.emf.common");
}
for (final EPackage pack_1 : generatedPackages) {
{
final GenPackage genPackage = GenModelUtil2.getGenPackage(pack_1, rs);
if (((this.getProjectConfig().getRuntime().getManifest() != null) && (this.modelPluginID == null))) {
CollectionExtensions.<String>addAll(this.getProjectConfig().getRuntime().getManifest().getExportedPackages(), genPackage.getInterfacePackageName(), genPackage.getClassPackageName(), genPackage.getUtilitiesPackageName());
}
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("if (!");
_builder.append(EPackage.class);
_builder.append(".Registry.INSTANCE.containsKey(\"");
String _nsURI = pack_1.getNsURI();
_builder.append(_nsURI);
_builder.append("\")) {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append(EPackage.class, "\t");
_builder.append(".Registry.INSTANCE.put(\"");
String _nsURI_1 = pack_1.getNsURI();
_builder.append(_nsURI_1, "\t");
_builder.append("\", ");
String _qualifiedPackageInterfaceName = genPackage.getQualifiedPackageInterfaceName();
TypeReference _typeReference = new TypeReference(_qualifiedPackageInterfaceName);
_builder.append(_typeReference, "\t");
_builder.append(".eINSTANCE);");
_builder.newLineIfNotEmpty();
_builder.append("}");
_builder.newLine();
}
};
this.getLanguage().getRuntimeGenSetup().getRegistrations().add(_client);
}
}
}
use of org.eclipse.xtext.xtext.generator.model.PluginXmlAccess in project xtext-core by eclipse.
the class GeneratorFragment2 method generate.
@Override
public void generate() {
boolean _isGenerateStub = this.isGenerateStub();
if (_isGenerateStub) {
new GuiceModuleAccess.BindingFactory().addTypeToType(TypeReference.typeRef(IGenerator2.class), this.getGeneratorStub(this.getLanguage().getGrammar())).contributeTo(this.getLanguage().getRuntimeGenModule());
ManifestAccess _manifest = this.getProjectConfig().getRuntime().getManifest();
boolean _tripleNotEquals = (_manifest != null);
if (_tripleNotEquals) {
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);
}
boolean _isGenerateXtendStub = this.isGenerateXtendStub();
if (_isGenerateXtendStub) {
this.doGenerateXtendStubFile();
} else {
this.doGenerateJavaStubFile();
}
}
if ((this.isGenerateStub() || this.isGenerateJavaMain())) {
ManifestAccess _manifest_1 = this.getProjectConfig().getRuntime().getManifest();
boolean _tripleNotEquals_1 = (_manifest_1 != null);
if (_tripleNotEquals_1) {
Set<String> _exportedPackages = this.getProjectConfig().getRuntime().getManifest().getExportedPackages();
String _packageName = this.getGeneratorStub(this.getLanguage().getGrammar()).getPackageName();
_exportedPackages.add(_packageName);
}
}
boolean _isGenerateJavaMain = this.isGenerateJavaMain();
if (_isGenerateJavaMain) {
this.doGenerateJavaMain();
}
boolean _isGenerateXtendMain = this.isGenerateXtendMain();
if (_isGenerateXtendMain) {
this.doGenerateXtendMain();
}
boolean _isGenerateMwe = this.isGenerateMwe();
if (_isGenerateMwe) {
this.doGenerateMweFile();
}
this.contributeEclipsePluginGuiceBindings();
ManifestAccess _manifest_2 = this.getProjectConfig().getEclipsePlugin().getManifest();
boolean _tripleNotEquals_2 = (_manifest_2 != null);
if (_tripleNotEquals_2) {
Set<String> _requiredBundles_1 = this.getProjectConfig().getEclipsePlugin().getManifest().getRequiredBundles();
_requiredBundles_1.add("org.eclipse.xtext.builder");
}
PluginXmlAccess _pluginXml = this.getProjectConfig().getEclipsePlugin().getPluginXml();
boolean _tripleNotEquals_3 = (_pluginXml != null);
if (_tripleNotEquals_3) {
this.contributeEclipsePluginExtensions();
}
}
use of org.eclipse.xtext.xtext.generator.model.PluginXmlAccess 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());
}
}
use of org.eclipse.xtext.xtext.generator.model.PluginXmlAccess in project xtext-core by eclipse.
the class CompareFragment2 method generate.
@Override
public void generate() {
IBundleProjectConfig _eclipsePlugin = this.getProjectConfig().getEclipsePlugin();
ManifestAccess _manifest = null;
if (_eclipsePlugin != null) {
_manifest = _eclipsePlugin.getManifest();
}
boolean _tripleNotEquals = (_manifest != null);
if (_tripleNotEquals) {
Set<String> _requiredBundles = this.getProjectConfig().getEclipsePlugin().getManifest().getRequiredBundles();
Iterables.<String>addAll(_requiredBundles, Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("org.eclipse.compare", "org.eclipse.xtext.ui")));
}
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("binder.bind(");
_builder.append(String.class);
_builder.append(".class).annotatedWith(");
_builder.append(Names.class);
_builder.append(".named(");
TypeReference _typeReference = new TypeReference("org.eclipse.xtext.ui.UIBindings");
_builder.append(_typeReference);
_builder.append(".COMPARE_VIEWER_TITLE)).toInstance(\"");
String _simpleName = GrammarUtil.getSimpleName(CompareFragment2.this.getGrammar());
_builder.append(_simpleName);
_builder.append(" Compare\");");
}
};
final StringConcatenationClient statement = _client;
GuiceModuleAccess.BindingFactory _bindingFactory = new GuiceModuleAccess.BindingFactory();
TypeReference _typeReference = new TypeReference("org.eclipse.compare.IViewerCreator");
TypeReference _typeReference_1 = new TypeReference("org.eclipse.xtext.ui.compare.DefaultViewerCreator");
_bindingFactory.addTypeToType(_typeReference, _typeReference_1).addConfiguredBinding("CompareViewerTitle", statement).contributeTo(this.getLanguage().getEclipsePluginGenModule());
IBundleProjectConfig _eclipsePlugin_1 = this.getProjectConfig().getEclipsePlugin();
PluginXmlAccess _pluginXml = null;
if (_eclipsePlugin_1 != null) {
_pluginXml = _eclipsePlugin_1.getPluginXml();
}
boolean _tripleNotEquals_1 = (_pluginXml != null);
if (_tripleNotEquals_1) {
List<CharSequence> _entries = this.getProjectConfig().getEclipsePlugin().getPluginXml().getEntries();
StringConcatenation _builder = new StringConcatenation();
_builder.append("<extension point=\"org.eclipse.compare.contentViewers\">");
_builder.newLine();
_builder.append("\t");
_builder.append("<viewer id=\"");
String _name = this.getGrammar().getName();
_builder.append(_name, "\t");
_builder.append(".compare.contentViewers\"");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("class=\"");
TypeReference _eclipsePluginExecutableExtensionFactory = this._xtextGeneratorNaming.getEclipsePluginExecutableExtensionFactory(this.getGrammar());
_builder.append(_eclipsePluginExecutableExtensionFactory, "\t\t");
_builder.append(":org.eclipse.xtext.ui.compare.InjectableViewerCreator\"");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("extensions=\"");
String _join = IterableExtensions.join(this.getLanguage().getFileExtensions(), ",");
_builder.append(_join, "\t\t");
_builder.append("\">");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("</viewer>");
_builder.newLine();
_builder.append("\t");
_builder.append("<contentTypeBinding");
_builder.newLine();
_builder.append("\t\t");
_builder.append("contentTypeId=\"");
String _name_1 = this.getGrammar().getName();
_builder.append(_name_1, "\t\t");
_builder.append(".contenttype\"");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("contentViewerId=\"");
String _name_2 = this.getGrammar().getName();
_builder.append(_name_2, "\t\t");
_builder.append(".compare.contentViewers\" />");
_builder.newLineIfNotEmpty();
_builder.append("</extension>");
_builder.newLine();
_builder.append("<extension point=\"org.eclipse.compare.contentMergeViewers\">");
_builder.newLine();
_builder.append("\t");
_builder.append("<viewer id=\"");
String _name_3 = this.getGrammar().getName();
_builder.append(_name_3, "\t");
_builder.append(".compare.contentMergeViewers\"");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("class=\"");
TypeReference _eclipsePluginExecutableExtensionFactory_1 = this._xtextGeneratorNaming.getEclipsePluginExecutableExtensionFactory(this.getGrammar());
_builder.append(_eclipsePluginExecutableExtensionFactory_1, "\t\t");
_builder.append(":org.eclipse.xtext.ui.compare.InjectableViewerCreator\"");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("extensions=\"");
String _join_1 = IterableExtensions.join(this.getLanguage().getFileExtensions(), ",");
_builder.append(_join_1, "\t\t");
_builder.append("\" label=\"");
String _simpleName = GrammarUtil.getSimpleName(this.getGrammar());
_builder.append(_simpleName, "\t\t");
_builder.append(" Compare\">");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("</viewer>");
_builder.newLine();
_builder.append("\t");
_builder.append("<contentTypeBinding");
_builder.newLine();
_builder.append("\t\t");
_builder.append("contentTypeId=\"");
String _name_4 = this.getGrammar().getName();
_builder.append(_name_4, "\t\t");
_builder.append(".contenttype\"");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("contentMergeViewerId=\"");
String _name_5 = this.getGrammar().getName();
_builder.append(_name_5, "\t\t");
_builder.append(".compare.contentMergeViewers\" />");
_builder.newLineIfNotEmpty();
_builder.append("</extension>");
_builder.newLine();
_builder.append("<extension point=\"org.eclipse.ui.editors.documentProviders\">");
_builder.newLine();
_builder.append("\t");
_builder.append("<provider id=\"");
String _name_6 = this.getGrammar().getName();
_builder.append(_name_6, "\t");
_builder.append(".editors.documentProviders\"");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("class=\"");
TypeReference _eclipsePluginExecutableExtensionFactory_2 = this._xtextGeneratorNaming.getEclipsePluginExecutableExtensionFactory(this.getGrammar());
_builder.append(_eclipsePluginExecutableExtensionFactory_2, "\t\t");
_builder.append(":org.eclipse.xtext.ui.editor.model.XtextDocumentProvider\"");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("extensions=\"");
String _join_2 = IterableExtensions.join(this.getLanguage().getFileExtensions(), ",");
_builder.append(_join_2, "\t\t");
_builder.append("\">");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("</provider>");
_builder.newLine();
_builder.append("</extension>");
_builder.newLine();
_builder.append("<extension point=\"org.eclipse.team.core.fileTypes\">");
_builder.newLine();
{
List<String> _fileExtensions = this.getLanguage().getFileExtensions();
for (final String modelFileExtension : _fileExtensions) {
_builder.append("\t");
_builder.append("<fileTypes");
_builder.newLine();
_builder.append("\t");
_builder.append("\t");
_builder.append("extension=\"");
_builder.append(modelFileExtension, "\t\t");
_builder.append("\"");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t");
_builder.append("type=\"text\">");
_builder.newLine();
_builder.append("\t");
_builder.append("</fileTypes>");
_builder.newLine();
}
}
_builder.append("</extension>");
_builder.newLine();
_entries.add(_builder.toString());
}
}
Aggregations