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 122731 - regression? Result of "Surround with try" is different from 5.5.1
Summary: regression? Result of "Surround with try" is different from 5.5.1
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-11-26 03:41 UTC by Masaki Katakai
Modified: 2008-01-30 05:34 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 Masaki Katakai 2007-11-26 03:41:42 UTC
NetBeans 6.0 RC2:

The behavior of "Surround with try {..." is different from NetBeans 5.5.1.
In NB5.5.1, "int a;" will be moved to outside try {}.

Source :
--
public class Main {
    public Main() {
        int a = Integer.parseInt("5");
        System.out.println(a);
    }
}
--

Result NB6.0:
--
public class Main {
    public Main() {
        try {
            int a = Integer.parseInt("5");

        } catch (NumberFormatException numberFormatException) {
        }

        System.out.println(a);
    }
}
--

Result NB5.5.1:
--
public class Main {
    public Main() {
        int a;
        try {
            a = Integer.parseInt("5");
        } catch (NumberFormatException ex) {
            ex.printStackTrace();
        }
        System.out.println(a);
    }
}
--
Comment 1 Masaki Katakai 2007-11-26 03:43:38 UTC
Try "Surround with" for the line "        int a = Integer.parseInt("5");"
Comment 2 Jan Lahoda 2007-11-26 08:51:14 UTC
This relates to the Surround with try-catch hint (code template).
Comment 3 Dusan Balek 2007-11-29 14:39:06 UTC
Fixed. Selection template processing mechanism improved to move used variable declaration outside of blocks.

Checking in JavaCodeTemplateProcessor.java;
/cvs/java/editor/src/org/netbeans/modules/editor/java/JavaCodeTemplateProcessor.java,v  <--  JavaCodeTemplateProcessor.java
new revision: 1.20; previous revision: 1.19
done