use of org.eclipse.emf.codegen.ecore.genmodel.GenPackage 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);
}
}
}
Aggregations