| Summary: | invalid warning for m2 import in grammar | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | [Modeling] TMF | Reporter: | Meinte Boersma <meinte.boersma> | ||||||
| Component: | Xtext | Assignee: | Project Inbox <tmf.xtext-inbox> | ||||||
| Status: | CLOSED FIXED | QA Contact: | |||||||
| Severity: | normal | ||||||||
| Priority: | P3 | CC: | clay, Ed.Merks, lorenzo.bettini, sebastian.zarnekow, serano.colameo, sven.efftinge | ||||||
| Version: | 2.4.0 | Flags: | sebastian.zarnekow:
kepler+
|
||||||
| Target Milestone: | RC1 | ||||||||
| Hardware: | All | ||||||||
| OS: | All | ||||||||
| Whiteboard: | |||||||||
| Bug Depends on: | 392988 | ||||||||
| Bug Blocks: | |||||||||
| Attachments: |
|
||||||||
|
Description
Meinte Boersma
The problem is more in line 426. The package should not be checked if it was generated by a super grammar. I have the same problem with 2.1.1, when adding import of xbase (on a new xtext project): import "http://www.eclipse.org/xtext/xbase/Xbase" as xbase though xbase is in the dependencies of the project (In reply to comment #2) > I have the same problem with 2.1.1, when adding import of xbase (on a new xtext > project): > > import "http://www.eclipse.org/xtext/xbase/Xbase" as xbase > > though xbase is in the dependencies of the project Is the error message the same as the one from comment #0? Does the error disappear if you close and reopen the project? @Sebastian: no, the problem (the warning) is still there even after closing and reopening the project I have this problem too with xtext 2.1.1. Any workaround? ~serano (In reply to comment #5) > I have this problem too with xtext 2.1.1. > > Any workaround? > > ~serano ...and btw, I cannot generate my xtext grammar anymore. 25421 [main] INFO clipse.emf.mwe.utils.GenModelHelper - Registered GenModel 'http://www.csg.com/cs/tools/mdgen/icm/IcmDsl' from 'platform:/resource/com.csg.cs.tools.mdgen.icm/src/com/csg/cs/tools/mdgen/icm/IcmDsl.genmodel' java.lang.IllegalArgumentException: non-prefix new value at org.eclipse.emf.common.util.URI.replacePrefix(URI.java:2716) at org.eclipse.xtext.generator.ecore.EcoreGeneratorFragment.toPlatformResourceURI(EcoreGeneratorFragment.java:396) at org.eclipse.xtext.generator.ecore.EcoreGeneratorFragment.access$0(EcoreGeneratorFragment.java:390) at org.eclipse.xtext.generator.ecore.EcoreGeneratorFragment$ToPlatformResourceDeresolvingURIHandler.deresolve(EcoreGeneratorFragment.java:386) at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.deresolve(XMLHelperImpl.java:821) at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getHREF(XMLHelperImpl.java:807) at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveEObjectSingle(XMLSaveImpl.java:1865) at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLSaveImpl.java:1309) at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XMLSaveImpl.java:2685) (In reply to comment #6) > (In reply to comment #5) > > I have this problem too with xtext 2.1.1. > > > > Any workaround? > > > > ~serano > > ...and btw, I cannot generate my xtext grammar anymore. > > 25421 [main] INFO clipse.emf.mwe.utils.GenModelHelper - Registered GenModel > 'http://www.csg.com/cs/tools/mdgen/icm/IcmDsl' from > 'platform:/resource/com.csg.cs.tools.mdgen.icm/src/com/csg/cs/tools/mdgen/icm/IcmDsl.genmodel' > java.lang.IllegalArgumentException: non-prefix new value > at org.eclipse.emf.common.util.URI.replacePrefix(URI.java:2716) > at > org.eclipse.xtext.generator.ecore.EcoreGeneratorFragment.toPlatformResourceURI(EcoreGeneratorFragment.java:396) > at > org.eclipse.xtext.generator.ecore.EcoreGeneratorFragment.access$0(EcoreGeneratorFragment.java:390) > at > org.eclipse.xtext.generator.ecore.EcoreGeneratorFragment$ToPlatformResourceDeresolvingURIHandler.deresolve(EcoreGeneratorFragment.java:386) > at > org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.deresolve(XMLHelperImpl.java:821) > at > org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getHREF(XMLHelperImpl.java:807) > at > org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveEObjectSingle(XMLSaveImpl.java:1865) > at > org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLSaveImpl.java:1309) > at > org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XMLSaveImpl.java:2685) ------ ok, something is odd here... I guess it has to do with scanClassPath = true option. however, the guilty method is in EcoreGeneratorFragment: private static URI toPlatformResourceURI(URI uri) { if (uri.isPlatform()) return uri; Map<String, URI> map = EcorePlugin.getPlatformResourceMap(); for (Entry<String, URI> entries : map.entrySet()) { final URI newPrefix = URI.createURI("platform:/resource/" + entries.getKey() + "/"); URI uri2 = uri.replacePrefix(entries.getValue(), newPrefix); if (uri2 != null) return uri2; } return uri; } the line which causes the IllegalArgumentException is the following: URI uri2 = uri.replacePrefix(entries.getValue(), newPrefix); where entries.getValue() is during debugging set to file:/C:/Data/projects/workspaceMDGEN/MDGE/lib/com.csg.cs.tools.mdgen.icm.generator/misc/resources/setup/ and newPrefix variable is => platform:/resource/##service.name##/ I really do not know why we need to go into java projects in the workspace which have really nothing to do with the Xtext grammar project... why is this needed? there is no dependencies at all between these projects. ~serano They seem to be on the classpath of the launch config, otherwise they wouldn't be processed. Pushed to master. (In reply to comment #8) > They seem to be on the classpath of the launch config, otherwise they wouldn't > be processed. Hi Sebastian, thanks again for your feedbacks yesterday evening. As you told me to do, I disabled the line with platformUri definition in my mwe2: Workflow { bean = StandaloneSetup { scanClassPath = true // platformUri = "${runtimeProject}/.." ...and now everything works fine. So, but then this means for me that it is better to not mix other projects in the workspace where the grammar project resides. Best regards, Serano This problem seems to show up again (apparently for the same missing '!') in Xtext 2.3.1. See for instance, the Scripting.xtext from the seven languages. I think this bug should be reopened. see comment #11 Created attachment 222735 [details]
proposed patch for xtext repo
Created attachment 222736 [details]
addon patch for xtend repo
the patch becomes obsolete with 392988 because it exports the Xbase.ecore model from the src folder. the remaining part of the patch to index models, stored in external folders, from a runtime workspace is still required.
@@ -65,12 +66,23 @@ public class Storage2UriMapperJavaImpl extends Storage2UriMapperImpl implements
@Override
public Iterable<Pair<IStorage, IProject>> getStorages(URI uri) {
+ if (isExternalPlatformResource(uri)) {
+ return cache.get(uri);
+ }
Iterable<Pair<IStorage, IProject>> storages = super.getStorages(uri);
if (!storages.iterator().hasNext()) {
return cache.get(uri);
}
return storages;
}
+
+ /**
+ * @since 2.4
+ */
+ protected boolean isExternalPlatformResource(URI uri) {
+ return uri.isPlatformResource() && uri.segmentCount() >= 3 && EXTERNAL_PROJECT_NAME.equals(uri.segment(1))
+ && uri.segment(2).startsWith(LINKED_FOLDER_NAME);
+ }
There're a lot of different topics covered here. I tried to reproduce the initial problem. This seems to be fixed. For any other problems mentioned throughout the comments we need dedicated bugzilla entries. Requested via bug 522520. -M. |