Bug 371838 - [Extract Local Variable] Suggested name is wrong for chained function calls with literal in last call
Summary: [Extract Local Variable] Suggested name is wrong for chained function calls w...
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-refactoring (show other bugs)
Version: 8.1.0   Edit
Hardware: All All
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-16 21:20 EST by Marc-André Laperle CLA
Modified: 2020-09-04 15:20 EDT (History)
2 users (show)

See Also:


Attachments
Minimal project to verify the problem (1.95 KB, application/x-zip-compressed)
2013-04-22 15:32 EDT, Jesse Weinstein CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marc-André Laperle CLA 2012-02-16 21:20:00 EST
Using 8.1.0.201202161734

Example:

struct Foo {
public:
    float GetNum(int) {}
};

Foo GetFoo() {}

int main() {
    GetFoo().GetNum(0);
}

Select 'GetFoo().GetNum(0)', invoke Extract Local Variable. 'i' is suggested instead of 'num'. 

If I change the code to this:
    int a;
    GetFoo().GetNum(a);

then 'num' is correctly suggested.

Foo GetFoo(float) {}
int main() {
    GetFoo(0);
}

'foo' is also correctly suggested.
Comment 1 Jesse Weinstein CLA 2013-04-22 15:32:05 EDT
Created attachment 229989 [details]
Minimal project to verify the problem

Verified on eclipse-SDK-4.3M5a-win32-x86_64. Slightly modified code used to verify (attached, and included below):

struct Foo {
public:
    float GetNum(int) {return 0;}
};

Foo GetFoo() {return Foo();}

int main() {
	int a;
    GetFoo().GetNum(0); //Extract Local Variable suggests "i"
    GetFoo().GetNum(a); //Extract Local Variable suggests "num"
    GetFoo(); //Extract Local Variable suggests "foo"
}