| Summary: | [content assist] Override method proposal does not auto-insert on '(' | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Chris West (Faux) <eclipse> |
| Component: | Text | Assignee: | JDT-Text-Inbox <jdt-text-inbox> |
| Status: | CLOSED DUPLICATE | QA Contact: | |
| Severity: | minor | ||
| Priority: | P3 | CC: | daniel_megert, markus.kell.r |
| Version: | 3.6 | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
Content assist never supported to narrow down by typing '(' and then the parameter type name. That it works in the anonymous case is a bug in the first place.
We have no plans at this time to support content assist filtering by parameter types.
*** This bug has been marked as a duplicate of bug 308217 *** |
Build Identifier: I20100506-0800 If you are inside an anonymous inner class, you can ctrl+space complete overrides (methods from the superclass that you want to re-implement). If the method name is sufficient to select the override, this works as expected. If, however, the method in the superclass has many overloads (methods with the same name with different signatures (parameter types / counts)), then at least part of the argument list is required to complete the method. If you type this, then you see two problems. 1) The enter key does not confirm the selection option in the auto-complete drop-down. 2) The auto-complete is applied at (slightly) the wrong place, causing invalid code. I suspect these are the same issue, hence one bug report. Motivation: JDT's ASTVisitor. :) Issue is present in previous versions. Reproducible: Always Steps to Reproduce: 1) Suppose your cursor is sitting inside the anonymous inner class in some code like this: class Bracket { void foo() { accept(new Visitor() { // inside the anonymous inner class }); } void accept(Visitor a) {} static class StupidlyLongNameOne {} static class AnotherStupidlyLongName {} abstract static class Visitor { void visit(StupidlyLongNameOne one) {} void visit(AnotherStupidlyLongName two) {} } } You want to overload "visit(AnotherStupidlyLongName)". 2) Type "visi", and hit ctrl+space. A completion will be offered with "visit(StupidlyLongNameOne one)" and "visit(AnotherStupidlyLongName two)" in. This is correct. 3) Assume there's hundreds of possible overloads, and you want to filter them with the keyboard. Do not cancel the auto-complete dialog. Continue typing "t(Ano", so the contents of the anonymous inner class is "visit(Ano)". (The close bracket is added by the editor (like it does whenever you type an open bracket). Your cursor is just before the close bracket.) 4) At this point, there should be just the one overload visible in the completion drop-down, as it has correctly filtered them as you typed. 5) Hit return. The cursor simply jumps past the close bracket without completing anything or closing the auto-complete drop-down. 6) Hit return again. The auto-complete dropdown disappears without moving the cursor. You're now back in a normal editor, with the code reading: accept(new Visitor() { visit(Ano) }); This is unexpected behaviour 1. I believe the first press of the return key (step 5) should perform the same action as using the mouse to double click the list. Unfortunately, this doesn't quite work either: 7) Delete the contents of the anonymous inner class and follow steps 1-4 again; that is, you have the auto-complete drop-down with only one element in it displayed, with the cursor in "visit(Ano[HERE])". 8) Double-click the entry in the drop-down. 9) The following will be generated: void visit(AnotherStupidlyLongName two) {};) This is correct, apart from the ";)" on the end. This is unexpected behaviour 2. I guess the ) is the one added by the editor in "3)", and the ; is an artefact of the "syntax error" that's happening when the completion is applied. It's worth noting that the semi-colon is technically legal, that is, generating "void visit(AnotherStupidlyLongName two) {};" would be fine, although would generate a warning with high-enough warnings settings.