| Summary: | Index not updated when complete folder deleted | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | [Tools] CDT | Reporter: | Marko Tomljenovic <marko.tomljenovic> | ||||||||||||
| Component: | cdt-core | Assignee: | Anton Leherbauer <aleherb+eclipse> | ||||||||||||
| Status: | RESOLVED FIXED | QA Contact: | Doug Schaefer <cdtdoug> | ||||||||||||
| Severity: | major | ||||||||||||||
| Priority: | P3 | CC: | aleherb+eclipse, yevshif | ||||||||||||
| Version: | 7.0.2 | Flags: | aleherb+eclipse:
review?
(mschorn.eclipse) |
||||||||||||
| Target Milestone: | 8.0 | ||||||||||||||
| Hardware: | PC | ||||||||||||||
| OS: | Windows XP | ||||||||||||||
| Whiteboard: | |||||||||||||||
| Attachments: |
|
||||||||||||||
|
Description
Marko Tomljenovic
Created attachment 193825 [details]
Plugin with context menu action that results in invalid index
Created attachment 193827 [details]
Test project with src files to test contextmenuaction.zip with
Created attachment 194036 [details]
Project indexer settings
After some playing around it is simply enough to delete a folder that contains sources to reproduce the error. The problem is that the DeltaAnalyzer is not handling removed CContainers at all which is the case when a complete folder is removed. From what I understand till now there a two ways to solve this bug: 1. CElementDelta objects must be created for all files within the folder that have been deleted 2. Provide the resource delta for the deleted files within the folder so that the DeltaAnalyzer can determine PotentialTranslationUnits for the removed files (In reply to comment #6) > From what I understand till now there a two ways to solve this bug: > > 1. CElementDelta objects must be created for all files within the folder that > have been deleted > 2. Provide the resource delta for the deleted files within the folder so that > the DeltaAnalyzer can determine PotentialTranslationUnits for the removed files I am following the first approach. The problem now could be located up to class 'CelementDelta' and method 'removed()' and 'addAffectedChild()'. Why does method 'removed()' assume that a removed celement does not have any affected children (in case of removed folder it has affected children) For removed files of a removed folder the method 'addAffectedChild()' does not add the c element delta of the removed file as an affected child of the c element delta of the removed folder. Anybody an idea? Created attachment 194258 [details]
DeltaAnalyzer to collect removed resources from resource delta
I'd rather not change the way CModelDeltas are created. Cutting off the deltas for removed and added resources is intentional and is the same in JDT world. Changing that could cause regressions for existing clients. Attached is a proposed fix for DeltaAnalyzer to always scan through resource deltas for removed resources. This should not have a relevant impact on performance.
It would be great if you could contribute a JUnit test case for this bug!
Created attachment 194267 [details]
Revised fix
I just noticed that the resource delta is not always part of the CElementDelta. That was due to an omission in the DeltaProcesser. This patch includes both fixes.
(In reply to comment #8) > Created attachment 194258 [details] > DeltaAnalyzer to collect removed resources from resource delta > > I'd rather not change the way CModelDeltas are created. Cutting off the deltas > for removed and added resources is intentional and is the same in JDT world. > Changing that could cause regressions for existing clients. Attached is a > proposed fix for DeltaAnalyzer to always scan through resource deltas for > removed resources. This should not have a relevant impact on performance. > It would be great if you could contribute a JUnit test case for this bug! Are there any helper classes/plugins for writing cdt tests? (In reply to comment #9) > Created attachment 194267 [details] > Revised fix > > I just noticed that the resource delta is not always part of the CElementDelta. > That was due to an omission in the DeltaProcesser. This patch includes both > fixes. Are you sure your patch is correct? After applying your changes on the 7.0.2 sources the bug still seem to exist! (In reply to comment #11) > (In reply to comment #9) > > Created attachment 194267 [details] [details] > > Revised fix > > > > I just noticed that the resource delta is not always part of the CElementDelta. > > That was due to an omission in the DeltaProcesser. This patch includes both > > fixes. > > Are you sure your patch is correct? After applying your changes on the 7.0.2 > sources the bug still seem to exist! Does CElementDelta.addResourceDelta need not be changed too to allow resource deltas for removed c elements? (In reply to comment #10) > Are there any helper classes/plugins for writing cdt tests? Look into org.eclipse.cdt.core.tests. There are numerous examples which you can use as boilerplate. (In reply to comment #11) > Are you sure your patch is correct? After applying your changes on the 7.0.2 > sources the bug still seem to exist! I just tried with 7.0.2 and the patch works for me. I followed exactly your steps to reproduce. (In reply to comment #12) > Does CElementDelta.addResourceDelta need not be changed too to allow resource > deltas for removed c elements? No, I don't think so. There is still no resource delta for add or removed elements, but the parent container will have a resource delta. (In reply to comment #13) > (In reply to comment #10) > > Are there any helper classes/plugins for writing cdt tests? > > Look into org.eclipse.cdt.core.tests. There are numerous examples which you > can use as boilerplate. > > (In reply to comment #11) > > Are you sure your patch is correct? After applying your changes on the 7.0.2 > > sources the bug still seem to exist! > > I just tried with 7.0.2 and the patch works for me. I followed exactly your > steps to reproduce. > > (In reply to comment #12) > > Does CElementDelta.addResourceDelta need not be changed too to allow resource > > deltas for removed c elements? > > No, I don't think so. There is still no resource delta for add or removed > elements, but the parent container will have a resource delta. You are right, it works. It will take some time to provide a test since I will be on leave for a month. (In reply to comment #14) > You are right, it works. > It will take some time to provide a test since I will be on leave for a month. Thanks for the confirmation. I am going to create a test myself. A month from now is too close to release time. Markus, would you review my changes in DeltaAnalyzer? (In reply to comment #15) > (In reply to comment #14) > > You are right, it works. > > It will take some time to provide a test since I will be on leave for a month. > Thanks for the confirmation. I am going to create a test myself. A month from > now is too close to release time. > Markus, would you review my changes in DeltaAnalyzer? Looks good. Thanks Markus. I have committed the fix together with test case IndexBugsTests.testUpdateOnFolderRemove_343538 to HEAD. *** cdt cvs genie on behalf of aleherbau *** Bug 343538 - Index not updated when complete folder deleted [*] IndexBugsTests.java 1.103 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBugsTests.java?root=Tools_Project&r1=1.102&r2=1.103 [*] DeltaAnalyzer.java 1.10 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/DeltaAnalyzer.java?root=Tools_Project&r1=1.9&r2=1.10 [*] DeltaProcessor.java 1.74 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/DeltaProcessor.java?root=Tools_Project&r1=1.73&r2=1.74 |