Bug 351524 - [content assist] Content assist -> Implement method creates method with wrong formatting and missing @Override
Summary: [content assist] Content assist -> Implement method creates method with wrong...
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.6.2   Edit
Hardware: All All
: P3 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: JDT-Text-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on: 377176
Blocks:
  Show dependency tree
 
Reported: 2011-07-08 04:46 EDT by misja CLA
Modified: 2024-03-03 13:53 EST (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description misja CLA 2011-07-08 04:46:56 EDT
Build Identifier: M20110210-1200

If I press Ctrl-Space in a class that implements an interface and choose to implement a method, the generated method sometimes has the following problems:

- My formatting preferences are not respected: Both open- and closing braces are on the same line even though each of them should be on a new line
- The generated method is ended with a semicolon (;). So after the closing brace a semicolon is appended
- There's no @Override annotation added to the generated method. This immediately generates a warning with my compiler warning settings.

I'll add an attachment with an example.

Reproducible: Sometimes

Steps to Reproduce:
1. Create a new class
2. Add 'implements' and choose some interface
3. Press Ctrl-Space in the class body and choose to implement some method

This doesn't happen every time.
I noticed that it happens more frequently if:
- the subclass is an anonymous inner class
- the subclass is still completely empty
Comment 1 misja CLA 2011-07-08 04:50:52 EDT
Here's an example of such a generated method:

Thread thread = new Thread()
{
    public void run() {};
}

Note that both braces are on the same line even though my code formatter specifies that each of them should be on a new line.
Sometimes the code generator does this correctly, and sometimes the code looks like this.
Comment 2 Dani Megert CLA 2011-07-11 05:50:14 EDT
Self-contained snippet:
class Y {
	public void foo() {
	}
}

public class Snippet extends Y {
	foo();
	foo
}

Content assist after "foo" inserts:
public void foo() {};

If the foo() call removed or commented out, then it works fine.


The bug is in OverrideCompletionProposal.java.

See also bug 317497.
Comment 3 Markus Keller CLA 2012-04-19 08:17:52 EDT
I can't reproduce comment 2 (inserts a correct overriding method), but comment 1 is due to a bad AST recovery, see bug 377176.
Comment 4 Eclipse Genie CLA 2018-12-30 14:11:56 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 5 Eclipse Genie CLA 2020-12-23 18:20:14 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 6 Eclipse Genie CLA 2024-03-03 13:53:55 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.