Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 338374

Summary: Generate ToString should omit the fields prefix/suffix
Product: [Eclipse Project] JDT Reporter: Heiko Böttger <heiko.boettger>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P3    
Version: 3.7   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Heiko Böttger CLA 2011-02-28 04:04:43 EST
Build Identifier:  I20110127-2034

When generating the ToString-Method the prefix and suffix of each field is included in the output string. The prefix and suffix are defined in CodeStyle-PreferencePage, these are known character sequences that can be omit. Since ToString only uses non-static fields there is no benefit in seeing the prefix and suffix. 

May be this could be build in as a predefined template.

Reproducible: Always

Steps to Reproduce:
1. Create a Class with some fields using the definied prefix (here 'f'):

class Data {
  private final SignalType             fSignalType;
  private final long                   fTime;
  private final int                    fPosition;
}

2. Call the Source -> Generate ToString

Output using default template will be:

  @Override
  public String toString() {
    return "Data [fSignalType=" + fSignalType + ", fTime=" + fTime
        + ", fPosition=" + fPosition + "]";
  }


Wished output using would be:

  @Override
  public String toString() {
    return "Data [signalType=" + fSignalType + ", time=" + fTime
        + ", position=" + fPosition + "]";
  }