|
|
|
|
| Re: importURI of ecore-only based model [message #1081722 is a reply to message #1081569] |
Wed, 07 August 2013 11:53   |
Eclipse User |
|
|
|
Hi Christian,
your blog post helped me a lot! But there are some things that are not covered in your post or comments there. Since my use-case is a bit different (not UML-related) I decided to ask here:
The way you provided the resourceServiceProvider for a custom model (.uml in your case) searches for any *.uml file in the project (or even workspace?) and adds any elements to the index of xtext (so that they can be referenced). This is ok to demonstrate that it is possible to reference other model items from a custom xtext language, but I think in reality you rather would like to "include" only certain files that have been selected explicitly by the user. I think the overriden "DefaultResourceDescriptionStrategy" is the right point to start, but for now I don't know how I could connect it with some statement in my custom language (e.g. "use" or "import"). "importURI" could be somehow useful, but I fear that I'm too new to xtext to find it out on my own Do you have any examples / hints how to achieve this?
Another thing that took me some time to figure out was, that the resourceServiceProvider plugin is only started, if a new file for the custom language is *created*. I already had a .mydsl-file (.umlmodel in your case) in the workspace of my Eclipse runtime instance. Apparently the plugin wasn't called and existing .mymdl (.uml) files were ignored, scoping was not working. Only after creating a *new* .mydsl-file all .mymdl files were parsed and scoping in the xtext-editor suddenly worked. But when closing the Eclipse instance and restarting, references cannot be resolved again (I first have to create another .mydsl file), and so on. Any idea what's going wrong here?
Best regards,
Till
|
|
|
|
| Re: importURI of ecore-only based model [message #1082366 is a reply to message #1081740] |
Thu, 08 August 2013 09:19   |
Eclipse User |
|
|
|
Christian Dietrich wrote on Wed, 07 August 2013 12:24Hi,
the import uri mechanism works on top of the resourceservice provider.
the files are indexed if the project has xtext nature (right click on project, configure, add xtext nature)
~Christian
Hi Christian,
thanks for your answer, but I meant something different... I think my question was confusing
Xtext nature was already added and files are indexed correctly. What I want to achieve is that only those files are indexed that are imported explicitely (e.g. using importURI). Reason for this: I want to have something similar to the "import" statement of java for other packages. Anything the user wants to reference, must be brought into scope explicitely first.
The second problem is less important. Just let me describe the behavior I see after following your UML-example (altough "UML" is substituted by my own meta-model):
1. I start an Eclipse runtime for the DSL
2. I add a .model file (the equivalent to .uml)
3. I add a .dsl file
4. The .model file is indexed
5. Scoping of elements within .model does work; referenes are resolved
6. I save the .dsl file: one error per reference occurs: "Couldn't resolve reference to Item 'MyItem'", but in the same seconds the error markers in the xtext editor disappear (are replaced by that gray symbol for former errors).
7. If I close and reopen the .dsl file, corresponding lines are again marked with an error which go away as soon as I save the .dsl file.
[Updated on: Thu, 08 August 2013 09:22] by Moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04340 seconds