Summary: | Cannot create type hierarchy for abstract types when they have inline descendants and *.class* in project name | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Ivan <divacnd> | ||||||||||
Component: | Core | Assignee: | Olivier Thomann <Olivier_Thomann> | ||||||||||
Status: | VERIFIED FIXED | QA Contact: | |||||||||||
Severity: | normal | ||||||||||||
Priority: | P3 | CC: | markus.kell.r, Olivier_Thomann, stephan.herrmann, vijay.rajonline | ||||||||||
Version: | 3.6 | ||||||||||||
Target Milestone: | 3.6 M2 | ||||||||||||
Hardware: | PC | ||||||||||||
OS: | Windows XP | ||||||||||||
Whiteboard: | |||||||||||||
Attachments: |
|
Description
Ivan
2009-09-05 13:04:29 EDT
Created attachment 146555 [details]
example project
example plugin with buggy classes
Created attachment 146556 [details]
error log
Oops (looking at IndexBasedHierarchyBuilder.searchAllPossibleSubTypes()): int suffix = documentPath.toLowerCase().lastIndexOf(SUFFIX_STRING_class); if this matches in the middle of a string, I wouldn't call it a suffix ;-) further down substring(lastSlash+1, suffix) tries to create a substring with negative length since suffix is smaller than lastSlash. how about: if (documentPath.toLowerCase().endsWith(SUFFIX_STRING_class)) { int suffix = documentPath.length()-SUFFIX_STRING_class.lenght(); ? looks good :) . Should work :) Created attachment 146576 [details]
proposed patch with test
Here you go!
Now we only need a committer to accept the patch.
2 notes:
- I changed the example to use a source folder with ".class" in its name,
rather than a project. Fits easier into existing test infrastructure.
- I made a search for other occurrences of String.lastIndexOf(String),
but none looked suspecious to me. However, many places use this
method with a one char String. Would it matter for performance to
change it to using lastIndexOf(char)??
about perfomance: an idea came to me int suffix = documentPath.length() - SUFFIX_STRING_class.length(); if (documentPath.substring(suffix).toLowerCase().equals(SUFFIX_STRING_class)) { will work more quickly, especially with long pathes (In reply to comment #6) > about perfomance: an idea came to me > > int suffix = documentPath.length() - SUFFIX_STRING_class.length(); > if (documentPath.substring(suffix).toLowerCase().equals(SUFFIX_STRING_class)) > { > will work more quickly, especially with long pathes Why do you think so? endsWith looks pretty efficient, plus it avoids to create another string as substring does. Created attachment 146585 [details]
example project with a simple speed test
a simple speed test look at SpeedTest.java
Let's review this. Thanks Stephan! Patch looks good. Thanks for the patch. Released for 3.6M2. Regression test added in: org.eclipse.jdt.core.tests.model.TypeHierarchyTests#testBug288698 Verified for 3.6M2 *** Bug 295206 has been marked as a duplicate of this bug. *** |