Monday Jun 26, 2006

New Features in NetBeans IDE, part 2 - Improved Code Completion

Lets continue with our survey through newly planned features for a future version of NetBeans. Today, I would like to focus on one of the most important features of a modern IDE - code completion.

The code completion is undergoing a total rewrite. The new code completion should provide not only in much better performance than the old one, but also a handfull of new and cool features:

keywords suggestions: the code completion will propose keywords usable in a given context:

Keyword code completion

smart completion: a special type of the code completion which proposes only suggestions that match to the current situation by type. For example, if you type List l = new , the smart completion will only propose subclasses of List, like ArrayList:

Smart code completion

smart completion for catch clauses: for catch clauses, only exceptions thrown inside the corresponding try block are proposed by the smart code completion:

Smart code completion for catch clauses

suggestions of variable names: the code completion tries to infer a usable variable name.

filtering of suggestions by type: the code completion will propose only classes after extends clause, only interfaces afer implements clause and only Throwables after throw new.

code completion for Javadoc: it is planned that the code completion should work meaningfully only in the Javadoc comments.

Monday Jun 19, 2006

New Features in NetBeans IDE, part 1 - Improved Coloring

As you can probably imagine, the NetBeans development did not stop with NetBeans 5.0 and NetBeans 5.5. A new version of NetBeans, which is already being planned, is supposed to bring many new features. I would like to describe some of them here. Please note that all I will present here is preliminary and subject of change.

One of the most visible new features is extended coloring in the editor. The code should be colored not only according to the lexical information (aka syntax highlighting), but also according to syntax and semantic information. For example, fields should get a different colors than local variables, etc.:

Improved coloring the editor

Additionally, also content for Javadoc comments and string literals should be colored to allow better orientation:

Improved coloring of Javadoc comments

And last, but not least, the unused elements will be detected and shown in gray:

Unused elements are shown in gray

Many more new features and improvements are planned: improved code completion, improved code templates, editor hints improvements, and many others. Stay tuned for details.

Friday May 26, 2006

Spellchecker for NetBeans IDE

As some of you may already know, there is a spellchecker module for NetBeans. It can be installed from the nbextras.

You can read simple how-tos on nbextras and Tor's blog, so I would like to concentrate on more complex use and the internals of the spellchecker module.

In the spellchecker, the dictionary that should be used for spellchecking of a particular file is found through locale. Each dictionary registered in the spellchecker specifies a locale and each file specifies a locale too. When a file is to be spellchecked, the file locale is used to look-up the correct dicionary.

For Java, only "default locale" is currently used. The initial default locale is the system locale with which the IDE runs. If you need to change it (eg. you run on cs_CZ locale but write comments in english), go to Tools/Options/Spellchecker and set the Default Locale to whatever locale you need.

The english dictionaries (en_US and en_GB) are available on the nbextras update center. But, what if you need different dictionary? Solution is simple - create a word list for a given language and install it through Tools/Options/Spellchecker. The word list file format is simple: one word per line.

Although currently only Java and LaTeX are supported by the spellchecker, it is simple to add support for another language. Basically, the following needs to be done to support a new language:

  • write a new TokenList, which tokenizes the source code and returns words that should be spellchecked
  • write a new TokenListProvider, which will provide a TokenList for a given document
  • add some magic lines into the layer:
        <folder name="Editors">
            <folder name="<your mime-type before slash (usually text)>">
                <folder name="<your mime-type after slash>">
                    <folder name="TokenListProvider">
                        <file name="<FQN of your TokenListProvider, using '-' instead of '.'>.instance" />
    		<!--keep the following lines as they are-->
                    <folder name="Hints">
                        <file name="org-netbeans-modules-spellchecker-hints-DictionaryBasedHintsProvider.instance">
                            <attr name="instanceCreate" methodvalue="org.netbeans.modules.spellchecker.hints.DictionaryBasedHintsProvider.create" />
                    <folder name="CompletionProviders">
                        <file name="org-netbeans-modules-spellchecker-completion-WordCompletion.instance"/>

Ok, I think this is enough for one day. If you are interested in this project, be sure to check the TODO list and feel free to ask on




« April 2014