Friday Dec 21, 2007

NetBeans 6.0 FCS compatible Code Templates Tools on NetBeans Plugin Portal

Only yesterday I discovered that the Code Template Tools module was not working with NetBeans 6.0 FCS. I have fixed the issue and uploaded the module on NetBean Plugin Portal. The older, NetBeans 5.x compatible module can be downloaded from here.

UPDATE: I have improved the Surround With... Action (Ctrl+J T) for interactive use. Now it shows a pop up dialog with a list of templates. You can select a template and type ENTER or double click to insert the template in the editor. If the editor has some selected text then the templates using the ${selection} parameter are shown at the top of the template list. You can just type the template prefix to select a matching template quickly.

Wednesday Nov 21, 2007

JPDA (Java) Debugger Threads View Enhancements module on NetBeans Plugin Portal

I have uploaded the JPDA (Java) Debugger Threads View Enhancements module module to the NetBeans Plugin Portal.

Enhanced Threads View

This module unifies Threads and Call stack view (somewhat like Eclipse Java Debugger Threads View). The call stack frames are shown as the children of suspended thread in the Threads view. It supports same actions on as Call Stack view and more. For example, it shows actions to jump to types of local variable of a Call stackframe as well as the Show Classes action. It also shows full method signature of the Call stack frame. It additionally shows the actual class of the 'this' variable if it differs from the class that declares the method of the call stack frames.

The Show Classes action shows all the classes loaded in the JVM along with the loading and initiating ClassLoaders. This is useful for debugging class loading in multi-ClassLoder appications such as NetBeans itself.

Classes view


DISCLAIMER: This module is experimental. So no guarantees. Use the module at your own risk.

Friday May 11, 2007

How is it implemented? Java Editor Hint: Change variable type fix

In the previous entry I talked about the Change Variable Type fix. In this entry I will talk about how it is implemented.

Registration of the factory

Like many other features in NetBeans the hints/fixes/suggestions are implemented using a factory mechanism. The factory is registered in the module's layer file like this:

  <folder name="org-netbeans-modules-java-hints">
    <folder name="rules">\\
      <folder name="errors">
        <file name="org-netbeans-modules-javahints-ChangeTypeCreator.instance"/>

The factory is registered under the org-netbeans-modules-java-hints/rules/errors folder because it creates a fix for certain compilation errors such as type mismatch of the left and right side of a vatriable declaration statement.

Implementation of the factory

As the user edits the source code, the Java editor incrementally runs the javac in the background. As the javac emits compilation errors the editor shows the red squiggly lines. Aside from that it also invokes the factories registered to handle the particular compilation errors. In this case org.netbeans.modules.javahints.ChangeTypeCreator is one such factory. The ChangeTypeCreator implements the interface This intreface essentially has two important method:

    /\*\* Get the diagnostic codes this rule should run on
    public Set<String> getCodes();
    /\*\* Return possible fixes for a given diagnostic report.
    public List<Fix> run(CompilationInfo compilationInfo,
                         String diagnosticKey,
                         int offset,
                         TreePath treePath,
                         Data<T> data);

The getCodes() method essentially indicates the set of compilatioin error codes that are handled by the factory. The ChangeTypeCreator handles:


These codes are part of standard error codes emitted by the javac.

In the run(...) method of ChangeTypeCreator,enough information about the context in the editor is passed in. The ChangeTypeCreator uses the APIs to determine the types of expressions on the left and right side of a variable assignmenets and returns an instance of org.netbeans.modules.javahints.ChangeTypeHint. This instance is used to populate the list of fixes that appear as actions in the light bulb pop up menu in the left margin of the editor.

Implementation of the Change variable type fix

The ChangeTypeHint which implements org.netbeans.spi.editor.hints.Fix . It provides the text of menu item which is returned from:

    public String getText()

The actual fix is implemented in the method:

 public ChangeInfo implement()

using the Java Source APIs.

Friday May 04, 2007

Java Editor Hint: Change variable type fix

In NetBeans 6.0 Java editor supports writing custom, so called, fixes, hints and suggestions. These appear as a light bulb icon in the left margin of the Java editor. For example, in the code below:

100        List list = ...;
101        :
110        String s = list.get(0);

the type of the variable s does not match the type of the expression list.get(0). In such cases a light bulb icon appears in the left margin of the Java editor on the line 110 of the code. Clicking or invoking the fix action reveals a menu item saying Cast ...get(...) to String. Selecting the menu item changes the code on line 110 to:

110        String s = (String) list.get(0);

This is all well and good. However what if you wanted to adjust the type of the variable s to Object. It is very easy to write such a fix and that is what I have implemented.

With this fix, I always write my variable like this:

110        int i = .....; // some expression that return a type I don't know - assume it is RefactoringPluginFactory

Select the hint to change the type of i to the correct type.

110        RefactoringPluginFactory i = ....; 

(I know, I know some may say why I am doing this...because I am an extremely poor typist :( )
Then I quickly delete i and use the smart variable name proposal code completion to get:

110        RefactoringPluginFactory refactoringPluginFactory = ....;

I have added the fix to the Experimental Java Hints (contrib/editorhints/java) module. You can get the module from Development Update center.


DISCLAIMER: This module is experimental. So no guarantees. Use the module at your own risk.

Wednesday Apr 11, 2007

NetBeans 6.0 specific Update Center

NetBeans 6.0 Specific Update center

I have upgraded some of my modules to NetBeans 6.0 specific APIs. To handle those modules I have configured a NetBeans 6.0 specific Update Center so that you can install these modules.

So far I have uploaded the following modules:

I will be putting other 6.0 specific modules there soon.

You say - I don't know how to configure and use a NetBeans Update Center!. Don't worry, here is the tip:

The NetBeans 6.0 Update Center URL is:

To add the Update Center do the following in NetBeans IDE:

  1. Select Tools:Options menu item
  2. Click on Advanced Options button
  3. Select Options:IDE Configuration:System:Autoupdate Types
  4. Right Click and select New:General Update Center
  5. Enter Sandip Chitale's 6.0 Modules  for Name and click Finish
  6. In options dialog expand Autoupdate Types node, select Sandip Chitale's 6.0 Modules
  7. On the right hand side enter:

as the value for Server Url poropetry. Also make sure the Enabled property is selected. Then close all the dialogs.

Now select the Tools:Update Center menu item. You should see the Sandip Chitale's 6.0 Modules entry in the update centers list. Install the modules by finishing the wizard.

DISCLAIMER: These modules are experimental. So no guarantees. Use the modules at your own risk.

Tuesday Apr 10, 2007

UPDATED: Code Template Tools Module - Multiple selection/deletion of templates, importing templates from TextMate.

I have updated the Code Template Tools Module on my NetBeans update center described (here). This version of the module has been tested with NB5.5 and 6.0dev.

What is new?

  • I have multiple template selection and deletion functionality in Show Templates dialog.
  • A bug with Edit:Surround With menu has been fixed.
  • Tor has added the ability to import templates (for JRuby) from TextMate editor. Apparently the TextMate text editor is heavily used by Ruby community. Read all about it on Tor's blog.


DISCLAIMER: This module is experimental. So no guarantees. Use the module at your own risk.

Sunday Mar 25, 2007

UPDATED: LineTools module - Added ability to control case sensitivity of sorting.

I have updated the Line Tools Module on my NetBeans update center described here.

What is new

As per some one's suggestion added ability to control the case sensitivity of sorting. NOTE: This also affects the remove duplicates functionality.


DISCLAIMER: This module is experimental. So no guarantees. Use the module at your own risk.

Sunday Mar 04, 2007

Path Tools module uploaded

I have uploaded the Module Info Task module for Netbeans 5.5 and 6.0 to my NetBeans update center described here.

The Path Tools module installs the following actions:

Path Tools Actions

Copy Paths - Copy the full paths of the files/folder of selected node to the clipboard.  This also included the System File System nodes. Each file path is on a line. The lines are separated using the value specified by system property line.separator. For Project nodes the full path of the project directory is copied.

Explore - Launch the OS File Explorer (such as Windows Explorer or Finder or Koquerer or Nautilus) with the path of the file or folder of selected node selected in it. For Project nodes the project directory is selected. The Windows Explorer is used on MS Windows. Finder is used on MacOS. The Nautilus or Konquerer is used on Linux. The FileMgr is used on Solaris.

Shell On Path: Launch the OS shell (such as Command Prompt orXterm or Terminal) with the current directory set to path of the folder or parent path of the file of selected node. For Project nodes the project directory is used. The Command Prompt is used on MS Windows.  is used on MacOS (not implemented yet). The Xterm is used on Linux and Solaris (not implemented yet).

Edit - Launch the editor (such as Notepad or Edit or TextPad) with the path of the file or folder of selected node selected in it. For Project nodes the project directory is selected. The Notepad is used on MS Windows.

The commands to launch external programs can be configured using Tools:Options:Miscellaneous:Path Tools panel.

Path Tools Options

Sources - coming soon.

DISCLAIMER: This module is experimental. So no guarantees. Use the module at your own risk.

Sunday Feb 25, 2007

Declaration and Javadoc module functionality is now part of NetBeans 6.0

Sometime ago I blogged about Declaration and Javadoc module I just learned from Petr Hrebejk that he has integrated that functionality into the NetBeans 6.0 IDE. Thanks Petr. As many of you may know Petr is the manager for editor support in NetBeans 6.0. The functionality should be available in the next NetBeans 6.0 IDE build. Use Window:Declaration View and Window:Javadoc View menu items to show the Declaration and Javadoc windows. Enjoy!


Saturday Feb 24, 2007

Getting started with the new Generic Language Support Framework (Project Schliemann)

One of the main theme of NetBeans 6.0 is going to be - the support of scripting languages. There are many scripting languages sprouting almost every day. It is not possible to keep up and provide full support for these scripting languages in the IDE. However, using a declarative syntax, it is possible to provide the basic support for editing. That is precisely the goal of Generic Language Support Framework (Project Schliemann). It provides a declarative syntax for describing a new language. It is possible to add the editing support in a progressive manner.

  • syntax coloring
  • new file templates
  • code completion
  • code folding
  • hyperlink navigation
  • structure outline
  • documentation pop up
  • ...

I was playing with the new Windows powershell to do some scripting on my laptop. I though - "Hey, why not add the Windows powershell editing support to NetBeans using the new Generic Language Support Framework!". In about few hours I had the basic functionality implemented. Here is the screen shot showing the Windows powershell script being edited in NetBeans IDE.

Windows powershell script Editor Support

Currently the module implements:

  • syntax coloring
  • new file templates


  • code completion
  • hyperlinking
  • documentation pop up
  • structure outline
  • running the script

I have uploaded the Windows powershell script Editor Support module for Netbeans  6.0 to my NetBeans update center described here.

You will need to have the Generic Language Support Framework module.


DISCLAIMER: This module is experimental. So no guarantees. Use the module at your own risk.

Tuesday Nov 14, 2006

Incremental Search Toolbar module uploaded


The tool bar based variant of the Incremental Search module is now obsolete. Use the sidebar based version.

I have uploaded the Incremental Search Toolbar module to my Netbeans update center described here.

This module installs the Incremental Search Toolbar.

Incremental Search Toolbar

Typing Ctrl+/ puts the focus in the incremental search text field in the Incremental Search Toolbar. If there was text in the incremental search text field, it is preselected. You can start typing the text to search and the matching text will be highlighted in the current editor. The search text is shown in red color when no matching text is found. Typing ENTER or Ctrl+/ again,  finds the next match. Typing Shift+ENTER finds the previous match. Typing ESCAPE puts the focus back in current editor. The Find Next and Find Previous do what they imply.The Search Backwards check box searches the text in backward direction. The Match Case check box controls whether the case of text is considered while searching.


DISCLAIMER: This module is experimental. So no guarantees. Use the module at your own risk. 




« July 2016