| Summary: | API Use Scan builder throws NPE for a missing Inner Type problem | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] PDE | Reporter: | Ankur Sharma <ankur_sharma> | ||||||||||
| Component: | API Tools | Assignee: | Ankur Sharma <ankur_sharma> | ||||||||||
| Status: | VERIFIED FIXED | QA Contact: | |||||||||||
| Severity: | normal | ||||||||||||
| Priority: | P3 | CC: | curtis.windatt.public, Michael_Rennie | ||||||||||
| Version: | 3.7 | Flags: | Michael_Rennie:
review+
curtis.windatt.public: review+ |
||||||||||
| Target Milestone: | 3.7 M4 | ||||||||||||
| Hardware: | PC | ||||||||||||
| OS: | Windows XP | ||||||||||||
| Whiteboard: | |||||||||||||
| Bug Depends on: | |||||||||||||
| Bug Blocks: | 332157 | ||||||||||||
| Attachments: |
|
||||||||||||
|
Description
Ankur Sharma
Created attachment 184702 [details]
Test Case patch to reproduce the NPE
The problem occurs with the simple missing type problem as well. Created attachment 184705 [details]
Bug fix patch
Created attachment 184706 [details]
test case patch to reproduce/catch the NPE
+1 Fixed in HEAD. Fixes the failing tests and adds another test case. Reviewing the code with Mike, we found that there was an unnecessary if statement. If a type cannot be found, the util method to get the resource will return the manifest, so there is no need to check. That if statement was to put the marker for missing inner type on the parent type instead of the project. (In reply to comment #7) > That if statement was to put the marker for missing inner type on the parent > type instead of the project. The if statement assumed that the parent type was the name of the type proceeding the first '$' in the type name. This will not always give the parent type in the case of multiple inner types. Consider the example: public class A { class B { class C { class D { } } } } If the reference to D is removed the marker will be placed on A, which is not the parent type of D. We just need to tweak the if statement a bit to look for the last index of '$' in the type name and take the proceeding name. (In reply to comment #8) > We just need to tweak the if statement a bit to look for the last index of '$' > in the type name and take the proceeding name. True and that would mean to recurse back until we find a type that still exists. For example, the reference is for D and type C is renamed. This would make D unresolvable and the problem marker then will have to be placed on B. I feel we shall open a new bug for this that we will look in for M5 Created attachment 184794 [details]
fix
roll-up patch that includes the NPE check and walks the enclosing type names to find the smallest (existing) enclosing type to place the marker on.
The 'inner.patch' fails the existing tests. This is because of the change
if(!Util.isManifest(res.getProjectRelativePath())) {
- resource = res.getProjectRelativePath().toString();
+ rname = res.getProjectRelativePath().toString();
}
else {
- resource = "."; //$NON-NLS-1$
+ rname = res.getProject().getName();
}
The reason it fails is because 'rname' is supposed to the the resource name which will be found using IJavaProject.findMember. That is why if a marker has to be placed on project, we have to set it to "." which will have findMember to return the project. The project name will make it return null and the marker will not get created.
The fix that is going in to M4 will be the original bug fix patch attachment# 184705 [details]. We will improve the marker placement in M5 in bug 332157. |