| Summary: | deleted links loose target when calling DeltaBuildDetector | ||
|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | valentin Mising name <intellij> |
| Component: | Resources | Assignee: | Platform-Resources-Inbox <platform-resources-inbox> |
| Status: | RESOLVED INVALID | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | Szymon.Brandys |
| Version: | 4.2 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| Whiteboard: | |||
|
Description
valentin Mising name
Excuse me. I mean that DeltaBuildDetector implements IResourceDeltaVisitor inside IncrementalProjectBuilder and suppose that you know how to add it. Here is a reproducing code
static {
IResourceChangeListener listener = new IResourceChangeListener() {
public void resourceChanged(IResourceChangeEvent event) {
//System.err.println(String.format("Something changed! build kind = %s, res = %s, src = %s, type = %s", event.getBuildKind(), event.getResource(), event.getSource(), event.getType()));
//iterate(event.getDelta().getResource(), " ", event.getDelta().getKind());
try {
event.getDelta().accept(new IResourceDeltaVisitor() {
public boolean visit(IResourceDelta delta) throws CoreException {
IResource res = delta.getResource();
if (delta.getResource().getType() == IResource.FILE) {
System.err.println(String.format("fullpath = %s, target = %s, delta kind = %s", res.getFullPath(), res.getLocation(), delta.getKind()));
}
return true;
}
});
} catch (CoreException e) {
// handle error
}
}
};
ResourcesPlugin.getWorkspace().addResourceChangeListener(listener);
}
Linking C:\1 and deleting it afterwards produces the following output:
fullpath = /r/1, target = C:/1, delta kind = 1 (ADD)
fullpath = /r/1, target = C:/Users/valentin/runtime-EclipseApplication/r/1, delta kind = 2 (DELETE)
You see how file location has changed from C:\1 to PROJECT_LOC\1
This is intended behavior. At the time when the DELETE event is thrown, the resource does not exist already. And according to the #getLocation javadoc "If this resource is a file or folder under a project that exists, or a linked resource under a closed project, this method returns a (non-null) path computed from the location of the project's local content area and the project-relative path of the file or folder. This is true regardless of whether the file or folders exists, or whether the project is open or closed." |