summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorBalazs Grill2013-02-20 05:36:09 (EST)
committer Zoltan Ujhelyi2013-02-20 05:44:13 (EST)
commit7187d5415fccb31b3891ec5c4836c63a32dc36b5 (patch)
tree254e62c27cd60a0cc04e61a84502dee6e48685a0
parent98ea95e37a1f9d0584712db20098cb3e00ababba (diff)
downloadorg.eclipse.incquery-7187d5415fccb31b3891ec5c4836c63a32dc36b5.zip
org.eclipse.incquery-7187d5415fccb31b3891ec5c4836c63a32dc36b5.tar.gz
org.eclipse.incquery-7187d5415fccb31b3891ec5c4836c63a32dc36b5.tar.bz2
[399832] Corrected ID support and used package name instead of prefix
REOPENED - Wrong package nsURI is generated into the globalEiqModel.xmi when using packages from eiqgen https://bugs.eclipse.org/bugs/show_bug.cgi?id=399832
-rw-r--r--plugins/org.eclipse.incquery.tooling.core/src/org/eclipse/incquery/tooling/core/generator/util/EMFPatternURIHandler.java24
1 files changed, 21 insertions, 3 deletions
diff --git a/plugins/org.eclipse.incquery.tooling.core/src/org/eclipse/incquery/tooling/core/generator/util/EMFPatternURIHandler.java b/plugins/org.eclipse.incquery.tooling.core/src/org/eclipse/incquery/tooling/core/generator/util/EMFPatternURIHandler.java
index c9da48f..436edd8 100644
--- a/plugins/org.eclipse.incquery.tooling.core/src/org/eclipse/incquery/tooling/core/generator/util/EMFPatternURIHandler.java
+++ b/plugins/org.eclipse.incquery.tooling.core/src/org/eclipse/incquery/tooling/core/generator/util/EMFPatternURIHandler.java
@@ -7,6 +7,7 @@
*
* Contributors:
* Mark Czotter - initial API and implementation
+ * Zoltan Ujhelyi, Abel Hegedus, Balazs Grill - enhancements for subpackage support
*******************************************************************************/
package org.eclipse.incquery.tooling.core.generator.util;
@@ -53,7 +54,7 @@ public class EMFPatternURIHandler extends URIHandlerImpl {
List<String> fragments = new ArrayList<String>();
EPackage p = e;
while (nonEmptySuperPackage(p) != null) {
- fragments.add(p.getNsPrefix());
+ fragments.add(p.getName());
p = nonEmptySuperPackage(p);
uriString = p.getNsURI();
@@ -109,12 +110,29 @@ public class EMFPatternURIHandler extends URIHandlerImpl {
*/
for (EPackage p : uriToEPackageMap.values()) {
EObject eObject = p.eResource().getEObject(fragment);
+ EPackage e = p;
if(eObject != null) {
if(eObject instanceof ENamedElement) {
+ remainingFragment = "";
+ EObject parent = eObject.eContainer();
+ /*
+ * Because this element was found by ID, p may not be the containing
+ * package. We must find the correct parent package along with all
+ * name elements inbetween.
+ */
+ while (parent!= null && !(parent instanceof EPackage)){
+ if (parent instanceof ENamedElement){
+ remainingFragment += "/" + ((ENamedElement) parent).getName();
+ }
+ parent = parent.eContainer();
+ }
+ if (parent instanceof EPackage){
+ e = (EPackage)parent;
+ }
String name = ((ENamedElement) eObject).getName();
- remainingFragment = "/" + name;
+ remainingFragment += "/" + name;
}
- URI newUri = packageUriMap.get(p);
+ URI newUri = packageUriMap.get(e);
String newFragment = newUri.fragment() == null ? "/" + remainingFragment : newUri.fragment()
+ remainingFragment;
newUri = newUri.appendFragment(newFragment);