|
|
Re: How could i parse string and link its model with my files in eclipse project? [message #1703305 is a reply to message #1703297] |
Thu, 30 July 2015 12:50 |
kimi raikonnan Messages: 145 Registered: June 2015 |
Senior Member |
|
|
Hi Stefan,
I have eclipse project contains 2 files, file1.dsl and file2.dsl, you can see the contents of the files below.
file1.dsl contains some statements as shown below and file2.dsl contains the declarations of the variables. (like in C++ or Java we have declarations and usage)
At this step file1.dsl and file2.dsl will be parsed successfully without any errors.
Lets imagine that we will delete this project and will create another one and the new project will contain only file1.dsl (which contains the usage)
At this step this file (file1.dsl) will contains some errors after parsing it, because we are using variables without declarations.
So what i need is to parse the content of file2.dsl directly without adding this file to the project.
I need to add the content of file2.dsl directly as a string in the code and parse it. just like that ( "int a;int b;" )
And link file1.dsl with the model generated after parsing my string
file1.dsl
------------------
a++;
b++;
file2.dsl
-----------------
int a;
int b;
Thanks
[Updated on: Thu, 30 July 2015 12:52] Report message to a moderator
|
|
|
|
|
|
|
|
|
Re: How could i parse string and link its model with my files in eclipse project? [message #1703504 is a reply to message #1703483] |
Sat, 01 August 2015 16:34 |
|
Hi Kimi,
Christian already described how my first suggestion would work. It is definitely the easiest if it is okay for the user projects to be Java projects.
If you want to go the scope provider route, you would create your own implementation of IGlobalScopeProvider (you can override DefaultGlobalScopeProvider as a starting point). In there, you load your hardcoded library models into a ResourceSet, use the ResourceDescription.Manager to get EObjectDescriptions ("index entries") for those library models and then add those to the scope returned from the GlobalScopeProvider.
If you are new to customizing Xtext languages, you should have a look at the user guide about scoping and dependency injection before continuing down that road.
Hope that helps =)
Stefan
|
|
|
Re: How could i parse string and link its model with my files in eclipse project? [message #1703525 is a reply to message #1703504] |
Sun, 02 August 2015 13:50 |
kimi raikonnan Messages: 145 Registered: June 2015 |
Senior Member |
|
|
Hi,
I am a little bit confused.
As i said by adding file1.dsl and file2.dsl in eclipse project every thing work smoothly and i got no syntax errors in file1.dsl, cross reference is working also without any modifications in GlobalScopeProvider.
My expectations after removing file2.dsl from the project and loading it from the code as shown below, my expectation was that every thing will work correctly and syntax errors of file1.dsl will disappear.
URI uri = URI.createURI("file2.dsl");
XtextResourceSet resourceSet = injector.getInstance(XtextResourceSet.class);
Resource resource = resourceSet.getResource(uri, true);
EcoreUtil2.resolveLazyCrossReferences(resource, null);
Even if the way of loading the resource is wrong but i have only to load it in correct way but without any modifications in GlobalScopeProvider.
[Updated on: Sun, 02 August 2015 13:59] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03053 seconds