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 35661 - Surround selected code
Summary: Surround selected code
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Editor (show other bugs)
Version: 3.x
Hardware: All All
: P1 blocker with 2 votes (vote)
Assignee: Jan Becicka
URL: http://ui.netbeans.org/docs/hi/promoD...
Keywords:
: 28971 50065 60420 (view as bug list)
Depends on: 35750
Blocks:
  Show dependency tree
 
Reported: 2003-08-21 11:12 UTC by mvinar
Modified: 2007-08-13 15:09 UTC (History)
3 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mvinar 2003-08-21 11:12:38 UTC
User problem:
-----------------------------------
--

User need:
-----------------------------------
The user often wants to surround certain piece of
code with if, for, try/catch, synchronized, etc.
statement. This is awkward since he has to jump to
the beginning, position the cursor right, type the
code, jump to the end, position cursor, write a
code. The IDE can automate this.

Product requirement:
-----------------------------------
Surround selected code with if, for, try/catch
etc. statements.
Comment 1 Petr Nejedly 2004-03-26 22:00:46 UTC
Added URL of Gabo's UI spec.

Gabo: The spec misses one thing (which is a bit more tricky):
Once you wrap something into runnable, all the local variables that
are used from inside the wrapped block have to be re-declared as final
(or new final local variables if the original ones are written to later)

Example:

private void dummy(String s) {
  comp.setText(s);
}
->

private void dummy(final String s) {
    Runnable runnable = new Runnable() {
        public void run() {
            comp.setText(s);
        }
    };
}

One more note: most of the time you're just passing the runnable
somewhere and rarely store the Runnable, so it may be better to
provide pass-as-runnable action instead:
private void dummy(final String s) {
    |(new Runnable() {
        public void run() {
            comp.setText(s);
        }
    });
}

Comment 2 Roman Strobl 2005-04-22 13:24:34 UTC
For your information, work on surround by try/catch has been started. Honzo,
have you see the UI spec?
Comment 3 Roman Strobl 2005-04-22 13:33:45 UTC
*** Issue 50065 has been marked as a duplicate of this issue. ***
Comment 4 Jan Becicka 2005-05-25 15:31:03 UTC
*** Issue 28971 has been marked as a duplicate of this issue. ***
Comment 5 Jan Becicka 2005-05-25 15:36:26 UTC
Honzo L., are you going to implement it for NB 4.2? If not please reassign this
issue to me. Thanks.
Comment 6 Jan Becicka 2005-06-10 11:46:00 UTC
Started - new branch created "private_surround_with_try_catch"
Checking in editor/src/org/netbeans/modules/editor/java/Bundle.properties;
/cvs/java/editor/src/org/netbeans/modules/editor/java/Bundle.properties,v  <-- 
Bundle.properties
new revision: 1.8.18.1; previous revision: 1.8
done
Checking in editor/src/org/netbeans/modules/editor/java/JavaKit.java;
/cvs/java/editor/src/org/netbeans/modules/editor/java/JavaKit.java,v  <-- 
JavaKit.java
new revision: 1.10.2.1; previous revision: 1.10
done
Checking in
editor/src/org/netbeans/modules/editor/java/NbJavaSettingsInitializer.java;
/cvs/java/editor/src/org/netbeans/modules/editor/java/NbJavaSettingsInitializer.java,v
 <--  NbJavaSettingsInitializer.java
new revision: 1.2.28.1; previous revision: 1.2
done
Checking in
editor/src/org/netbeans/modules/java/editor/resources/DefaultKeyBindings.xml;
/cvs/java/editor/src/org/netbeans/modules/java/editor/resources/DefaultKeyBindings.xml,v
 <--  DefaultKeyBindings.xml
new revision: 1.2.28.1; previous revision: 1.2
done
Checking in editor/src/org/netbeans/modules/java/editor/resources/layer.xml;
/cvs/java/editor/src/org/netbeans/modules/java/editor/resources/layer.xml,v  <--
 layer.xml
new revision: 1.4.16.1; previous revision: 1.4
done
Checking in javacore/src/org/netbeans/modules/javacore/TryWrapper.java;
/cvs/java/javacore/src/org/netbeans/modules/javacore/TryWrapper.java,v  <-- 
TryWrapper.java
new revision: 1.7.16.1; previous revision: 1.7
done
Comment 7 Jan Becicka 2005-06-16 13:19:54 UTC
Basic version of surround with try catch implemented:
Checking in java/editor/src/org/netbeans/modules/editor/java/Bundle.properties;
/cvs/java/editor/src/org/netbeans/modules/editor/java/Bundle.properties,v  <-- 
Bundle.properties
new revision: 1.10; previous revision: 1.9
done
Checking in java/editor/src/org/netbeans/modules/editor/java/JavaKit.java;
/cvs/java/editor/src/org/netbeans/modules/editor/java/JavaKit.java,v  <-- 
JavaKit.java
new revision: 1.12; previous revision: 1.11
done
Checking in
java/editor/src/org/netbeans/modules/editor/java/NbJavaSettingsInitializer.java;
/cvs/java/editor/src/org/netbeans/modules/editor/java/NbJavaSettingsInitializer.java,v
 <--  NbJavaSettingsInitializer.java
new revision: 1.3; previous revision: 1.2
done
Checking in
java/editor/src/org/netbeans/modules/java/editor/resources/DefaultKeyBindings.xml;
/cvs/java/editor/src/org/netbeans/modules/java/editor/resources/DefaultKeyBindings.xml,v
 <--  DefaultKeyBindings.xml
new revision: 1.3; previous revision: 1.2
done
Checking in java/editor/src/org/netbeans/modules/java/editor/resources/layer.xml;
/cvs/java/editor/src/org/netbeans/modules/java/editor/resources/layer.xml,v  <--
 layer.xml
new revision: 1.6; previous revision: 1.5
done
Checking in java/javacore/src/org/netbeans/modules/javacore/TryWrapper.java;
/cvs/java/javacore/src/org/netbeans/modules/javacore/TryWrapper.java,v  <-- 
TryWrapper.java
new revision: 1.8; previous revision: 1.7
done
Checking in
java/javacore/src/org/netbeans/modules/javacore/jmiimpl/javamodel/ElementFinder.java;
/cvs/java/javacore/src/org/netbeans/modules/javacore/jmiimpl/javamodel/ElementFinder.java,v
 <--  ElementFinder.java
new revision: 1.4; previous revision: 1.3
done
Comment 8 Martin Matula 2005-06-23 10:26:33 UTC
*** Issue 60420 has been marked as a duplicate of this issue. ***
Comment 9 rsk 2006-02-02 14:01:09 UTC
Any status update on this? Also will the try-catch be intelligent and look at
the exceptions thrown, or just catch "Exception" as shown in the UI Doc?
Comment 10 Jan Becicka 2006-02-02 14:38:25 UTC
Surround with try-catch is fully functional in the NB 5.0 and it is "smart" in
terms of what exceptions are being catched.
Comment 11 rsk 2006-02-02 14:41:11 UTC
Thank you for the heads up

You mind if I run through IZ and close all the surround with requests?
Comment 12 Jan Becicka 2006-02-02 14:53:14 UTC
I don't mind. Actually I appreciate that :) But please close only "surround with
try-catch" issues. For instance this issue covers also surround with if | for |
while statement etc. That is why the issue is still open.
Thanks!
Comment 13 Jan Becicka 2007-06-08 12:29:30 UTC
Implemented in 6.0
Comment 14 Jan Becicka 2007-08-13 15:09:11 UTC
Already fixed.