Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » index is incomplete during auto build after cleaning more than one project
index is incomplete during auto build after cleaning more than one project [message #1739356] Sat, 30 July 2016 13:43 Go to next message
Krzysztof Kot is currently offline Krzysztof KotFriend
Messages: 3
Registered: July 2016
Junior Member
Hi,

I'm implementing validation of duplicate names of elements between projects.

It is something similar to:
IResourceDescriptions resourceDescriptions = resourceDescriptionsProvider.getResourceDescriptions(validatedObj.eResource());
IResourceDescription resourceDescription = resourceDescriptions.getResourceDescription(validatedObj.eResource().getURI());
IEObjectDescription objectDescription = getIEObjectDescription(validatedObj, resourceDescription);

for (IContainer container : containerManager.getVisibleContainers(resourceDescription, resourceDescriptions)) {
	Iterable<IEObjectDescription> iterable = container.getExportedObjects(eClass, objectDescription.getQualifiedName(), true);
	Iterator<IEObjectDescription> iter = iterable.iterator();
	while (iter.hasNext()) {
		IEObjectDescription duplicate = iter.next();
		if (duplicate.equals(objectDescription)) {
			continue;
		}
		error(Messages.Validation_UniqueName, validatedObj, eAttribute);
		return;
	}
}

It works fine when I'm saving a file and when I'm cleaning one project. But when I'm cleaning more than one project it doesn't work correctly.

I think it is because Clean removes IResourceDescription of every file from every cleaned project and they are added during build for current project. (I debugged that they are removed from ClusteringBuilderState used by CurrentDescriptions).

When auto build is validating files from first project the IContainer(s) that should have IResourceDescription(s) from second project are empty so I see no duplicates. Index is not yet rebuild.

What can I do to make it works ?

Only idea I have now is to stop using IResourceDescriptions and load models myself inside validation but original approach seams faster and doesn't require duplicating code that checks visible containers.
Re: index is incomplete during auto build after cleaning more than one project [message #1739524 is a reply to message #1739356] Tue, 02 August 2016 16:31 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14736
Registered: July 2009
Senior Member
Hi,

when a depending project is build the dependent project should have
been and its index entries should be there.

can you elaborate on your usecase?

~Christian

On 2016-08-02 13:12:08 +0000, Krzysztof Kot said:

> Hi,
>
> I'm implementing validation of duplicate names of elements between projects.
>
> It is something similar to:
>
> IResourceDescriptions resourceDescriptions =
> resourceDescriptionsProvider.getResourceDescriptions(validatedObj.eResource());
>
> IResourceDescription resourceDescription =
> resourceDescriptions.getResourceDescription(validatedObj.eResource().getURI());
>
> IEObjectDescription objectDescription =
> getIEObjectDescription(validatedObj, resourceDescription);
>
> for (IContainer container :
> containerManager.getVisibleContainers(resourceDescription,
> resourceDescriptions)) {
> Iterable<IEObjectDescription> iterable =
> container.getExportedObjects(eClass,
> objectDescription.getQualifiedName(), true);
> Iterator<IEObjectDescription> iter = iterable.iterator();
> while (iter.hasNext()) {
> IEObjectDescription duplicate = iter.next();
> if (duplicate.equals(objectDescription)) {
> continue;
> }
> error(Messages.Validation_UniqueName, validatedObj, eAttribute);
> return;
> }
> }
>
> It works fine when I'm saving a file and when I'm cleaning one project.
> But when I'm cleaning more than one project it doesn't work correctly.
>
> I think it is because Clean removes IResourceDescription of every file
> from every cleaned project and they are added during build for current
> project. (I debugged that they are removed from ClusteringBuilderState
> used by CurrentDescriptions).
>
> When auto build is validating files from first project the
> IContainer(s) that should have IResourceDescription(s) from second
> project are empty so I see no duplicates. Index is not yet rebuild.
>
> What can I do to make it works ?
>
> Only idea I have now is to stop using IResourceDescriptions and load
> models myself inside validation but original approach seams faster and
> doesn't require duplicating code that checks visible containers.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: index is incomplete during auto build after cleaning more than one project [message #1739528 is a reply to message #1739524] Tue, 02 August 2016 16:59 Go to previous messageGo to next message
Krzysztof Kot is currently offline Krzysztof KotFriend
Messages: 3
Registered: July 2016
Junior Member
We are virtually showing merged content of two project (parent and child) in our custom "Package Explorer". Files from each project can reference file from other project. Child project files override parent project files.

As workaround I extracted logic from our containerManager.getVisibleContainers and I'm reusing it in validator without using container.getExportedObjects.

In our case container is file. And visible containers are visible files. It is implemented using extended AbstractAllContainersState.

I think problem was that Clean removes index and Build rebuild it so it is why validation of first built project was not working (because files from second project where not indexed yet). Probably this behavior it is ok for most use cases.

[Updated on: Tue, 02 August 2016 17:09]

Report message to a moderator

Re: index is incomplete during auto build after cleaning more than one project [message #1739532 is a reply to message #1739528] Tue, 02 August 2016 17:21 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14736
Registered: July 2009
Senior Member
well cyclic dependencies are not a thing eclipse is well at.
it builds project by project


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: index is incomplete during auto build after cleaning more than one project [message #1740078 is a reply to message #1739532] Tue, 09 August 2016 05:41 Go to previous message
Krzysztof Kot is currently offline Krzysztof KotFriend
Messages: 3
Registered: July 2016
Junior Member
Christian Dietrich wrote on Tue, 02 August 2016 17:21
well cyclic dependencies are not a thing eclipse is well at.
it builds project by project

Hi, I still have problem with this. You are right problem is cyclic dependency between projects. Is it maybe possible to change something that ResourceDescriptions are not taken from index so that it doesn't depend on build order.

I know it would be slower but I have only few files so even loading them to ResourceSet while resolving cross references would be ok for me I think.

Edit:

I fixed problem by extending ProjectAwareResourceDescriptionsProvider and loading dependent resources to ResourceSet and changing from ResourceDescriptionsProvider.NAMED_BUILDER_SCOPE to ResourceDescriptionsProvider.LIVE_SCOPE in LoadOptions so that ResourceDescription from ResourceSet are created.

For now it seams to work.

[Updated on: Thu, 11 August 2016 07:11]

Report message to a moderator

Previous Topic:Customizing ecore model
Next Topic:Override XtextBuilder
Goto Forum:
  


Current Time: Fri Dec 13 03:01:35 GMT 2024

Powered by FUDForum. Page generated in 0.03386 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top