Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 367088 - [typing] Automatically add variable declaration
Summary: [typing] Automatically add variable declaration
Status: RESOLVED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.8   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-19 10:42 EST by Nathan Reynolds CLA
Modified: 2011-12-20 13:10 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nathan Reynolds CLA 2011-12-19 10:42:45 EST
Build Identifier: 20110916-0149

Let's say I have the following in a method.

int i;

Then, I type "j = i;"  The variable j is not declared.  So, the editor should automatically add the type in front of j or add the declaration at the top of the method.  Such as shown below.

int i, j;

j = i;

This could be done when assigning a variable to:

- the return value of a method
- a member variable
- a static variable
- a "new some_object_type();"
- a "new some_object_type[];"

Why bother the engineer with types when the editor can automatically do it?

Reproducible: Always
Comment 1 Deepak Azad CLA 2011-12-20 04:45:25 EST
> j = i;
You can use one of the quick fixes offered for the error on 'j' - 'Create local variable', 'Create Field' or 'Create parameter'. Is using a quick fix too hard ?

> So, the editor should
> automatically add the type in front of j or add the declaration at the top of
> the method.
It is not clear about what the developer wants to do in each and every situation, hence I would not start creating declarations automatically.

At best we may possibly show the quick fix popup automatically, but even this is stretching things a bit.
Comment 2 Nathan Reynolds CLA 2011-12-20 11:08:39 EST
I guess the current solution is good enough.