Bug 279897 - Implement suitable action for IResourceChangeEvent.PRE_CLOSE
Summary: Implement suitable action for IResourceChangeEvent.PRE_CLOSE
Status: VERIFIED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.6 M6   Edit
Assignee: Jay Arthanareeswaran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-06-11 02:17 EDT by Srikanth Sankaran CLA
Modified: 2010-03-09 09:29 EST (History)
3 users (show)

See Also:


Attachments
Proposed Patch (959 bytes, patch)
2010-01-29 00:06 EST, Jay Arthanareeswaran CLA
jarthana: review?
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Srikanth Sankaran CLA 2009-06-11 02:17:05 EDT
3.5 RC4

See bug#273385 comment#15. Currently, org.eclipse.jdt.internal.core.DeltaProcessor.resourceChanged(IResourceChangeEvent) does not react to
IResourceChangeEvent.PRE_CLOSE notification at all.
This defect is raised to track the investigation and
implementation of the right behavior in response to
this event.
Comment 1 Srikanth Sankaran CLA 2010-01-13 01:07:09 EST
Jay, can you please follow up ? Thanks.
Comment 2 Jay Arthanareeswaran CLA 2010-01-29 00:06:05 EST
Created attachment 157579 [details]
Proposed Patch

I think the only thing we need to do for PRE_CLOSE is to discard the jobs. 

Here are my reasons why we don't need the other things mentioned in  bug#273385 comment#15:

The DeltraProcessor#oldRoots doesn't seem to be used in any where during the close event. In fact I don't find it being used for project delete either. But that may not be in the scope of this bug.

The rest of the things done inside DeltaProcessor#deleting() either don't make sense in the context of PRE_CLOSE (like project.close() or invoked later during the POST_CHANGE event (see DeltaProcessor#checkProjectsAndClasspathChanges).

No regression test is included. To test, fire and hold a non-blocking job (like indexing) and firing the close event.
Comment 3 Olivier Thomann CLA 2010-02-02 11:23:15 EST
Should not we also check the nature of the project before discarding its jobs ?

case IResourceChangeEvent.PRE_CLOSE:
if(resource.getType() == IResource.PROJECT
	&& ((IProject) resource).hasNature(JavaCore.NATURE_ID)) {
   this.manager.indexManager.discardJobs(((IProject) resource).getName());
}
return;

Beside this, the patch looks good. Tagging as 3.6M6.
Jay, please release.
Comment 4 Jay Arthanareeswaran CLA 2010-02-03 03:08:37 EST
Looks like we already have the code in place for discarding jobs as well.

It's here - DeltaProcessor#checkProjectsAndClasspathChanges line number 2446. I don't know how I missed this the first time. Nevertheless it's there and effectively, we seem to have all the code in place already!
Comment 5 Olivier Thomann CLA 2010-02-03 10:33:13 EST
I am not sure that code is triggered on project close event.
Comment 6 Jay Arthanareeswaran CLA 2010-02-03 11:21:40 EST
(In reply to comment #5)
> I am not sure that code is triggered on project close event.

It is, indeed. When a project is closed, POST_CHANGE event is triggered, which eventually results in this code being invoked:

if (res.isOpen()) {
 ...
} else {
	boolean wasJavaProject = this.state.findJavaProject(res.getName()) != null;
	if (wasJavaProject) {
		close(element);
		removeFromParentInfo(element);
		currentDelta().closed(element);
		this.manager.indexManager.discardJobs(element.getElementName());
		this.manager.indexManager.removeIndexFamily(res.getFullPath());
	}
}

The line number I mentioned wasn't exactly correct, perhaps because I had the previous patch applied.
Comment 7 Olivier Thomann CLA 2010-02-03 11:37:28 EST
Then this can be closed as INVALID.
Comment 8 Jay Arthanareeswaran CLA 2010-02-03 11:40:00 EST
As mentioned in comment 2 comment 4 and comment 6, we need not do anything for
PRE_CLOSE event. Marking as INVALID.
Comment 9 Satyam Kandula CLA 2010-03-08 06:21:40 EST
Verified for 3.6M6
Comment 10 Olivier Thomann CLA 2010-03-09 09:29:34 EST
Verified.