|
|
|
|
|
|
|
|
Re: unique name validation in project, not the whole workspace [message #1046916 is a reply to message #1046900] |
Mon, 22 April 2013 14:39 |
Michal S Messages: 74 Registered: July 2011 |
Member |
|
|
Christian,
thank you for your answer.
I also ask for visible containers.
Problem is, that if I use getVisibleContainers(resourceDescription, resourceDescriptions) and resourceDescriptions object contains only descriptions of related resources, than also visible containers contain only limited amount of containers (not all of them...).
Here is my function:
def collectAllDescriptions(EClass clazz){
val resourceDescriptions = rdp.getResourceDescriptions(resource)
val resourceDescription = resourceDescriptions.getResourceDescription(resource.URI)
val containers = containerManager.getVisibleContainers(resourceDescription,resourceDescriptions)
var out = new ArrayList<IEObjectDescription>()
for(container:containers){
out.addAll(container.getExportedObjectsByType(clazz))
}
out
}
rdp is injected ResourceDescriptionsProvider and resource is processed resource.
If I use Project->Clean, everything works well, as object resourceDescriptions contains all model files contained in project. Problem occurs only when I save single model file and generator is called (resourceDescriptions contain only limited amount of descriptions).
Thank you,
Michal
|
|
|
|
|
|
Re: unique name validation in project, not the whole workspace [message #1047484 is a reply to message #1046940] |
Tue, 23 April 2013 09:13 |
Michal S Messages: 74 Registered: July 2011 |
Member |
|
|
Hello Christian,
I set up new "Greeting" project and it works there out of the box...
Problem is somewhere in my code
I tried to debug, what the difference is and I found out, that following code gives different results:
containerManager.getVisibleContainers(resourceDescription,resourceDescriptions)
In case of greeting project, where everything works perfectly, the result is:
[[StateBasedContainer] container '=rrrrrrrrrrrrrrrrrrrrrrr/src' from org.eclipse.xtext.ui.containers.JavaProjectsState@ffde9e]
And If I watch elementData->0->descriptions, it contains:
org.eclipse.xtext.builder.clustering.CurrentDescriptions$ResourceSetAware@1c60440
In case of my real project, where it does not work, the result is:
[[StateBasedContainer] container 'all' from org.eclipse.xtext.resource.containers.FlatResourceSetBasedAllContainersState@b75459]
And If I watch elementData->0->descriptions, it contains:
[ResourceSetBasedResourceDescriptions
[DefaultResourceDescription uri=platform:/resource/LCEProject/src/file.tcf]
]
I don't understand, why it behaves differently. Do you have any idea, why could this situation occur?
Thank you & Best regards,
Michal
EDIT:
I found out, that containerManager in Greeting example uses as stateProvider
org.eclipse.xtext.ui.containers.ContainerStateProvider , on the other hand, in case of my real project
org.eclipse.xtext.resource.containers.ResourceSetBasedAllContainersStateProvider .
Difference between Greeting example is, that I @Inject containerManager and resourceDescriptionsProvider in MyDslGenerator class as follows:
@Inject
ResourceDescriptionsProvider rdp
@Inject
IContainer$Manager containerManager
In case of my real project I use not Injected class and I inject the containerManager in that class in constructor as follows:
val injector = Guice::createInjector(new MyRealRuntimeModule)
this.containerManager = injector.getInstance(typeof(IContainer$Manager))
Could be this the reason of my problems?
[Updated on: Tue, 23 April 2013 11:13] Report message to a moderator
|
|
|
|
|
|
|
|
Re: unique name validation in project, not the whole workspace [message #1047655 is a reply to message #1047595] |
Tue, 23 April 2013 13:37 |
Michal S Messages: 74 Registered: July 2011 |
Member |
|
|
Hello Christian,
to explain my problem:
I use in my DSL multiple generators (I generate various implementations from my models ... and I switch between them using preferencePage or arguments of runGenerator() in Main class).
I created own package for every generator. Default MyDslGenerator.xtend was used just to create objects of my specific generators. Previously, I have not injected them, but just created standardly using constructor. If I injected e.g. ResourceDescriptionsProvider or Container.Manager in this standardly created objects, it was always null injected. That is why I tried to use
val injector = Guice::createInjector(new MyDslRuntimeModule)
this.containerManager = injector.getInstance(typeof(IContainer$Manager))
Now, after reading Jan's blog, I realize, this was bad approach.
Just before you answered, I changed the structure of my generator that way, that I @Inject all specific generators in MyDslGenerator.xtend ... and consequently I can @Inject ResourceDescriptionsProvider or Container.Manager without any problem in my specific generators, so it works very well now.
Thank you & Best regards
Michal
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06547 seconds