Bug 84317 - Cross reference view doesn't update after a build (when a method is renamed)
Summary: Cross reference view doesn't update after a build (when a method is renamed)
Status: RESOLVED FIXED
Alias: None
Product: AJDT
Classification: Tools
Component: UI (show other bugs)
Version: 1.2.0 M2   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 1.2.0 RC1   Edit
Assignee: Helen Beeken CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-02-03 06:25 EST by Matt Chapman CLA
Modified: 2005-09-12 05:24 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Chapman CLA 2005-02-03 06:25:08 EST
Cross reference view doesn't update after a build
Comment 1 Helen Beeken CLA 2005-02-09 12:09:51 EST
The scenario to cover is:

- If the name of an IJavaElement changes, then this name update etc. should be 
propogated to the Cross Reference view regardless of whether linking is 
enabled or not (this is what happens with the package explorer).

The update therefore needs to be triggered by the AJDT build. Also, the 
selection could possibly be able to be obtained in a similar way to the 
inplace view.
Comment 2 Helen Beeken CLA 2005-02-11 04:32:46 EST
There are various scenarios inside the one mentioned above:

(1) Linking is enabled: then the XRef view contains information about the
currently open editor/file. This means that the view can respond to selections
in the currently open editor (and after builds, update according to the
currently opened file)

(2) Linking is disabled and the xref view contains info about the currently open
editor/file:
 
    (a) the contents of a method changes, or a piece of advise is deleted: 
        In this case, the view can be refreshed by using the existing contents
        of the view (the changes are picked up via calls to the ContentProvider)

    (b) the name of a method changes:
        In this case, the view needs to get hold of the new IJavaElement and
        populate the view with this new information.

(3) Linking is disabld and the xref view contains info about a different file: 

    (a) the contents of a method changes, or a piece of advise is deleted: 
        In this case, the view can be refreshed by using the existing contents
        of the view (the changes are picked up via calls to the ContentProvider)

The only tricky one here is (2b).
Comment 3 Helen Beeken CLA 2005-02-11 08:06:33 EST
The fix for (1), (2a) and (3a) has been integrated:

BUILD COMPLETE -  build.186
Date of build: 02/11/2005 12:14:01
Time to build: 29 minutes 51 seconds
Last changed: 02/11/2005 11:50:54

This involved changing the code in the selectionChanged(...) method in
XReferenceView.java to reset the contents of the TreeViewer if selectionChanged
has been triggered by a build:

public void selectionChanged(IWorkbenchPart part, ISelection selection) {
	IXReferenceAdapter xra = XRefUIUtils.getXRefAdapterForSelection(part,selection);
	if (xra != null) {
		lastSelection = xra;
		if (linkingEnabled && !changeDrivenByBuild) {
			viewer.setInput(xra);
		} else if (changeDrivenByBuild){
			Object o = viewer.getInput();
			if (o instanceof IXReferenceAdapter) {
				IXReferenceAdapter xrefAdapter 
                                              = (IXReferenceAdapter)o;
				viewer.setInput(xrefAdapter);				
			}			
                }
	}
}

, and to create a new UIJob to drive selectionChanged(..) in the event of a build.
Comment 4 Helen Beeken CLA 2005-05-18 08:15:29 EDT
Closing this bug as fixed since it is reasonable that if the method name 
changes then the user needs to reclick in the editor to populate the cross 
reference view, rather than trying to get hold of the new IJavaElement and 
populating the view automatically after a build.
Comment 5 Helen Beeken CLA 2005-08-30 04:41:48 EDT
This seems to be broken (needs further investigation) - after fix for bug 107589 :-(

Therefore, reopening bug.

Comment 6 Helen Beeken CLA 2005-09-12 05:24:33 EDT
The fix for this bug has involved a rewrite of the selectionChanged(..) method
in the XReferenceView class to make the logic clearer. The behaviour needs to be
different depending on whether or not "link with editor" is enabled. The
scenarios detailed in comment #2 are clearly dealt with in this method, and
tests have been written to cover all these scenarios. The tests can be found in
org.eclipse.ajdt.ui.tests.visual.XReferenceViewBuildingTest in the ajdt.ui.test
plugin.

The fix has been integrated into both the AJDT 1.3 and AJDT 1.2 streams and can
be found in build:

AJDT 1.3:

BUILD COMPLETE -  build.106
Date of build: 09/09/2005 17:04:51
Time to build: 29 minutes 16 seconds
Last changed: 09/09/2005 16:49:28
Last log entry: removing commented out code

and it will be available in the next clean AJDT 1.2 build.