Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 327729 - [Scoping] Track references to resource external elements
Summary: [Scoping] Track references to resource external elements
Status: CLOSED WORKSFORME
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 2.0.0   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-14 00:13 EDT by Sven Efftinge CLA
Modified: 2012-11-19 08:28 EST (History)
2 users (show)

See Also:
sven.efftinge: indigo+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sven Efftinge CLA 2010-10-14 00:13:31 EDT
Currently references to external EObjects are only tracked, if the actual EObjectDescription was taken from the global scope. The ImportedNamesAdapter which wraps global scopes during the linking phase does this. However in situations, where you look up elements from external EObjects which have been loaded in the local scope provider, the reference is not tracked. 
A typical example is a feature on a class, which is referenced by a feature call. 
Example:
   "foo".length()

'length()' in this case could be a reference to java.lang.String.length(). The scope containing that element, would typically be created in the local scope, by using the type of the target expression (i.e. java.lang.Sting in this case). As the global scope was never asked for 'java.lang.String.length()' the resource wouldn't be treated as affected if the methods signature changes.

A possible solution would be to use aliases locally, so in case the scope is asked for an element of name 'length' the local scope actually calls its parent for the qualified name of the element 'java.lang.String.length()'. 

Another solution could be to wrap any local scopes, and track during linking whether the returned IEObjectDescription is contained in a different resource and if so, register the IEObjectDescription.getQualifiedName.
Comment 1 Moritz Eysholdt CLA 2010-10-14 18:48:39 EDT
Wouldn't it be the responsibility of IResourceDescription.getReferenceDescriptions() to export an IReferenceDescription if the reference should be tracked?

By "tracked", do you mean "made available in IResourceDescription.getImportedNames()"?
Comment 2 Sven Efftinge CLA 2010-10-15 02:38:57 EDT
I meant add the qualified names to the list of names in IResourceDescriptin.getImportedNames(), which is the information on which IResourceDescription.Manager.isAffected(Delta, IResourceDescription) is based by default.
Comment 3 Sebastian Zarnekow CLA 2011-01-10 10:48:42 EST
(In reply to comment #2)
> I meant add the qualified names to the list of names in
> IResourceDescriptin.getImportedNames(), which is the information on which
> IResourceDescription.Manager.isAffected(Delta, IResourceDescription) is based
> by default.

#isAffected takes the actually established cross references into account, too.
However, it will still return false as soon as a new method is introduced in the referenced type that overloads / overrides the previously referenced method, e.g.

123.value

where 123's type is MySpecialNumber type and I introduce getValue in MySpecialNumberType. I don't think it's the right way to add 
MySpecialNumberType#value, MySpecialNumberType#getValue, MyNumberType#value ... to the list of imported names.

It should be possible to add synthetic references to the list of reference descriptions that point to the resources of the actually referenced types.
Comment 4 Sven Efftinge CLA 2012-11-19 08:28:10 EST
closing this as WORKSFORME, since this is considered a language specific problem. We can't solve every language's problem in a generic way.