Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 352257 - Getter and Setter in Name Style preview can differ from generated code
Summary: Getter and Setter in Name Style preview can differ from generated code
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-refactoring (show other bugs)
Version: 8.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 8.0.1   Edit
Assignee: Marc-André Laperle CLA
QA Contact: Emanuel Graf CLA
URL:
Whiteboard:
Keywords:
: 350948 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-07-15 19:59 EDT by Marc-André Laperle CLA
Modified: 2012-05-22 20:32 EDT (History)
3 users (show)

See Also:


Attachments
Trim seed name for getters and setters (2.73 KB, patch)
2011-07-17 02:01 EDT, Marc-André Laperle CLA
malaperle: iplog-
Details | Diff
Trim seed name for getters and setters, trimFieldName moved (14.98 KB, patch)
2011-07-18 01:47 EDT, Marc-André Laperle CLA
cdtdoug: 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 2011-07-15 19:59:42 EDT
Using CDT 8.0.0.201107150206

1. Open Name Style preferences, for class field, set 
Prefix: m
Capitalization: Camel Case
2. Click on Getter, notice how in preview it displays "getMMyField"
3. Execute Generate Getters and Setters on a class containing int mMyField;
4. getMyField and setMyField are generated
Comment 1 Marc-André Laperle CLA 2011-07-17 02:01:22 EDT
Created attachment 199790 [details]
Trim seed name for getters and setters
Comment 2 Marc-André Laperle CLA 2011-07-17 02:11:27 EDT
In NameStyleBlock.Category.composeExampleName, the name passed to NameComposer needs to be trimmed for the cases of getters and setters as it is done inside GetterSetterNameGenerator. That means calling GetterSetterNameGenerator.trimFieldName from NameStyleBlock which doesn't seem ideal. I think trimFieldName should be moved to NameComposer (and be renamed to trimSeedName?). I could see other cases where we would want to trim the seed name. For example, Generate Constructor (bug 306902 WIP) also calls trimFieldName to generate parameter names. Sergey, what do you think?
Comment 3 Sergey Prigogin CLA 2011-07-17 11:43:10 EDT
(In reply to comment #2)
> In NameStyleBlock.Category.composeExampleName, the name passed to NameComposer
> needs to be trimmed for the cases of getters and setters as it is done inside
> GetterSetterNameGenerator. That means calling
> GetterSetterNameGenerator.trimFieldName from NameStyleBlock which doesn't seem
> ideal. I think trimFieldName should be moved to NameComposer (and be renamed to
> trimSeedName?). I could see other cases where we would want to trim the seed
> name. For example, Generate Constructor (bug 306902 WIP) also calls
> trimFieldName to generate parameter names. Sergey, what do you think?

I agree with moving. The name of the method should still contain the word "Field" since in future we may need other seed trimming methods.
Comment 4 Marc-André Laperle CLA 2011-07-18 00:58:28 EDT
*** Bug 350948 has been marked as a duplicate of this bug. ***
Comment 5 Marc-André Laperle CLA 2011-07-18 01:47:54 EDT
Created attachment 199803 [details]
Trim seed name for getters and setters, trimFieldName moved
Comment 6 Marc-André Laperle CLA 2011-07-19 13:00:45 EDT
Fixed in cdt_8_0 and master > 20110719.
Comment 7 CDT Genie CLA 2011-07-19 13:19:43 EDT
*** cdt git genie on behalf of 352257 ***

    Bug 352257 - Getter and Setter in Name Style preview can differ from
    generated code

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=0c0e19f36e881efcd52702d88262d46d9064fc85
Comment 8 CDT Genie CLA 2011-07-19 13:19:45 EDT
*** cdt git genie on behalf of 352257 ***

    Bug 352257 - Getter and Setter in Name Style preview can differ from
    generated code

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=601fae9798ef7ca1020b04da62ea671fb8d4ff83