Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 330693 - Improve suggested variable name in Extract Local Variable
Summary: Improve suggested variable name in Extract Local Variable
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-refactoring (show other bugs)
Version: 7.0   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 7.0.2   Edit
Assignee: Emanuel Graf CLA
QA Contact: Emanuel Graf CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-19 13:00 EST by Marc-André Laperle CLA
Modified: 2011-01-24 10:26 EST (History)
2 users (show)

See Also:


Attachments
patch (2.50 KB, patch)
2011-01-04 07:17 EST, Emanuel Graf CLA
emanuel: iplog-
Details | Diff
Improved handling of long names (4.36 KB, patch)
2011-01-05 05:22 EST, Emanuel Graf CLA
emanuel: iplog-
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Marc-André Laperle CLA 2010-11-19 13:00:10 EST
A couple of things that should be improved:
- getField(), GetField(), isField() becomes getField, isField, it should be 'field'
- object->member->getField() becomes 'member,' it should be 'field'
Comment 1 Emanuel Graf CLA 2011-01-04 07:17:02 EST
Created attachment 185996 [details]
patch
Comment 2 Emanuel Graf CLA 2011-01-04 07:21:40 EST
Fixed in HEAD ans 7.0 >20110104
Comment 5 Marc-André Laperle CLA 2011-01-04 19:22:48 EST
Thanks! This is much better. I noticed something while using it:

foo->getVarWithLongName() becomes 'name'. I think it should be varWithLongName. What do you think?

I think it should remove common prefixes, like get, get_, Get, Get_, lower the first letter after that and keep the rest of the string intact.
Comment 6 Emanuel Graf CLA 2011-01-05 04:18:38 EST
(In reply to comment #5)
> Thanks! This is much better. I noticed something while using it:
> 
> foo->getVarWithLongName() becomes 'name'. I think it should be varWithLongName.
> What do you think?
> 
> I think it should remove common prefixes, like get, get_, Get, Get_, lower the
> first letter after that and keep the rest of the string intact.

Yeah your right that would be far better. I'll change this.
Comment 7 Emanuel Graf CLA 2011-01-05 05:22:14 EST
Created attachment 186078 [details]
Improved handling of long names
Comment 10 Marc-André Laperle CLA 2011-01-10 02:21:31 EST
Very nice! But I tested this for a couple of days and found another issue :) 

getFoo(getBar())

If I select the whole thing, 'bar' is suggested. Similarly, 

getFoo(getBar(getFooBar()))

fooBar is suggested. 

I haven't looked at the code closely but some AST magic is probably needed to make sure is gets the 'outer' call before doing string processing. I can open a separate bug if you like.
Comment 11 Marc-André Laperle CLA 2011-01-24 10:26:21 EST
Opened bug 335202 the issue I mentioned.