Bug 263058 - [content assist] Incorrect parameter autonaming when overriding method
Summary: [content assist] Incorrect parameter autonaming when overriding method
Status: RESOLVED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.4.1   Edit
Hardware: All All
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: JDT-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-01-30 10:53 EST by Randy Hudson CLA
Modified: 2009-07-15 08:40 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Randy Hudson CLA 2009-01-30 10:53:18 EST
Build ID: 3.4.1

Steps To Reproduce:
I'm overriding Figure#getPreferredSize(int, int) in a subclass. In both the superclass (Figure), and in the interface declaring the method (IFigure), the method is defined as:

public Dimension getPreferredSize(int wHint, int hHint)

But when the "override template" is generated, I get:

public Dimension getPreferredSize(int hint, int hint2)

Why are the params named "hint" and "hint2"? It seems like some heuristic somewhere has decided that single letters followed by an uppercase letter should be ignored (as with field names used by convention in some platform plug-ins). That might make sense if I were doing a refactor->Extract method, but this should be a straightforward copy-down of the method signature.

I think I've also seen this when sub-classing SWT classes containing similar param names.

More information:
I don't know if this is relevant, but the override was being done within a nested class.  I can provide specific source code if you can't reproduce.
Comment 1 Frederic Fusier CLA 2009-01-30 11:02:32 EST
Move to JDT/UI
Comment 2 Dani Megert CLA 2009-02-02 03:53:37 EST
Are the methods in source or binary? If binary, is the source attached?

> I can provide specific source code if you can't reproduce.
That would be good.
Comment 3 Randy Hudson CLA 2009-02-02 09:06:19 EST
> Are the methods in source or binary? If binary, is the source attached?
Binary with source attached.
> > I can provide specific source code if you can't reproduce.
> That would be good.

Steps to reproduce:
1) Create a new class extending org.eclipse.swt.widgets.Layout
2) Look at the computeSize method.
Comment 4 Dani Megert CLA 2009-02-02 09:30:49 EST
This works for me using I20090129-1800. I get:

protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache)
Comment 5 Randy Hudson CLA 2009-02-02 09:39:58 EST
I'm using 3.4.1, both as my IDE and as my eclipse target.
Comment 6 Noel Grandin CLA 2009-07-15 07:59:28 EDT
I can confirm that the test case that Randy reported is fixed in 3.5.

But I'm still getting parameter name munging happening.

If I create an interface like so:

public interface MyInterface {
  void myMethod(long lMinTriggerPeriod_usec;
}

and then use content-assist when implementing my class, I get:

public class MyClass implements MyInterface {
  public void myMethod(long lMinTriggerPeriodUsec) {
    // TODO Auto-generated method stub
  }
}

Note the munging of "_usec" to "Usec".

Thanks.
Comment 7 Dani Megert CLA 2009-07-15 08:40:24 EDT
I'm marking this bug as WORKSFORME and filed bug 283539 for issue mentioned in the previous comment.