Bug 73014

Summary: [quick fix] fix type missmatch with toString() or valueOf()
Product: [Eclipse Project] JDT Reporter: Sandip Chitale <sandipchitale>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: ASSIGNED --- QA Contact:
Severity: enhancement    
Priority: P3 CC: eclipse, goerge
Version: 3.0   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Sandip Chitale CLA 2004-08-31 17:55:40 EDT
For the following declarations:
class Bar {
}
class Foo extends Bar {
}
Foo foo = ...;
Bar bar = ...;

foo = bar;

will trigger a quick fix with possibilities of

Add cast to Integer
Change type of foo to ...
Change type of bar to ...

This is all fine. I think a special case of String type variables should also 
be handled e.g. in the following case:

String barString = bar;

an additional possibility of:

Get the string value of 'bar' using bar.toString()

If the user selects this the code changes to:

String barString = bar.toString();

Another possibility is:

Get the string value of 'bar' using String.valueOf(bar)

If the user selects this the code changes to:

String barString = String.valueOf(bar);

This will work even when bar is not a Class or Interface.

These f course could be lower priority quick fixes.
Comment 1 Sandip Chitale CLA 2004-08-31 17:58:40 EDT
Additional coersive Quick Fixes could be supported between Striung type, basic 
types and their Object counterparts using the valueOf(), parse<blah>() methods.
Comment 2 Jerome Lanneluc CLA 2004-09-01 04:36:35 EDT
Moving to JDT UI for comments