Summary: | [code assist] Content assist gives "assertion failed" for import Foo|.Bar | ||||||
---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Ary Borenszweig <ary> | ||||
Component: | Core | Assignee: | David Audel <david_audel> | ||||
Status: | VERIFIED FIXED | QA Contact: | |||||
Severity: | normal | ||||||
Priority: | P3 | CC: | daniel_megert, Olivier_Thomann, sebastian.zarnekow | ||||
Version: | 3.5 | ||||||
Target Milestone: | 3.5 M6 | ||||||
Hardware: | PC | ||||||
OS: | Windows Vista | ||||||
Whiteboard: | |||||||
Attachments: |
|
Description
Ary Borenszweig
2008-08-07 09:04:31 EDT
Move to JDT/Text Back to JDT Core: org.eclipse.jdt.core.CompletionProposal.getReplaceStart() gives a wrong (to big) value. Note that it's even questionable to propose "p . T e s t 2 ;]" here as this results in a compiler error. I'd like the proposal "foo.Test2", to replace "Test2". In my original scenario, I had something like this: public class Test2 { public static enum Operator { And, Or } } So I typed in another class, in the imports section (I had "Test2.Operator" in the clipboard): import static Test2.Operator.*; Then I noticed a compiler error, because Test2 wasn't found because it isn't qualified. So I put the cursor after Test2, requested autocomplete and got the problem. That's why I was expecting the proposal to replace "Test2" with "foo.Test2", which in this case doesn't result in a compiler error. By all means, we live in 2008: don't hack imports by hand. Simply use Organize Imports (Ctrl+Shift+O) or even better, let the Save actions do it for you ;-) I use organize imports all the time, but see my original scenario. I want "And" or "Or" to remain in my code, not "Operator.And" or "Test2.Operator.And". But organize imports doesn't add an "import static Test2.Operator.*" if it encounters "And" or "Or". Suppose I have a method in another class that accepts an Operator. In the caller, I only want to type "And" or "Or", so the import for "Test2.Operator" is not present already. And organize imports doesn't work for that. That's what I mean. That's the only situation where I need to add an import by hand: if it's static. Makes sense. If you use that Operator often you can add it to the Content Assist > Favorites. If you do so, you can then type A + code assist and it inserts 'And' plus import for you. Wow! Thanks! I didn't know that. That is new in 3.4, right? Nope, that's already in 3.3.x. Hi, this bug also occurs if the programmer places the cursor between characters 't' and 'h', import java.lang.Mat|h.PI; or 'h' and '.', import java.lang.Math|.PI; and then presses CTRL+SPACE. Note that this occurs whether there is the keyword "static" or not. Hope this helps somehow. Regards, Mário Created attachment 127648 [details]
Proposed fix
Released for 3.5M6. Tests added CompletionTests#testCompletionImportedType7() -> testCompletionImportedType8() Verified for 3.5M6 using I20090310-0100. *** Bug 273206 has been marked as a duplicate of this bug. *** |