This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 164801 - introduce variable does not work properly with new operator
Summary: introduce variable does not work properly with new operator
Status: RESOLVED WONTFIX
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 6.x
Hardware: All All
: P4 blocker with 1 vote (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-05-08 20:59 UTC by vity
Modified: 2016-07-07 07:15 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description vity 2009-05-08 20:59:42 UTC
Introduce variable does not work properly in this case:
To reproduce this bug:
1. Write this code (new keyword is important):
 someExpression;
 new MyClass.myMethod();
2. Select |someExpression|, call function Introduce variable

You get this wrong result:
        newfinal ExpressionDataType variableName = someExpression;
 MyClass.myMethod();

Expected result:
 final ExpressionDataType variableName = someExpression;
 new MyClass.myMethod();


Reproducable both 6.7b and 6.5.1.
Comment 1 Jiri Prox 2009-05-11 10:43:28 UTC
Can you please attach specific example?
thanks
Comment 2 vity 2009-05-11 10:51:06 UTC
Why this bug was moved into "hints" subcomponent? It's refactoring bug...

>>Can you please attach specific example?
Dummy example:

"hello"
new String("bug").getBytes();
Comment 3 Jiri Prox 2009-05-11 11:05:27 UTC
Thanks for example
The introduce variable is implemented in java/hint module, even it is located in Refactor menu, that's why the issue was
moved.

The code contains error before refactoring, so the AST is broken and the code is not updated correctly. If there is ';'
behind the expression, the code is generated correctly. -> downgrading to P4
Comment 4 tprochazka 2009-05-12 05:20:36 UTC
I think that this is very annoying bug, because I must write ';' at the end of line a then select whole line without 
';' and then use 'Introduce variable'. I think that with ';' is not necessary selection, NB can automatically select 
all between ';'.

Another smaller problem is that netbeans remove empty line before selected statement during this refactoring.
Comment 5 Martin Balin 2016-07-07 07:15:40 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss