Community
Participate
Working Groups
Cross reference view doesn't update after a build
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.
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).
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.
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.
This seems to be broken (needs further investigation) - after fix for bug 107589 :-( Therefore, reopening bug.
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.