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" />
                    </folder>
    
    		<!--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" />
                        </file>
                    </folder>
                    
                    <folder name="CompletionProviders">
                        <file name="org-netbeans-modules-spellchecker-completion-WordCompletion.instance"/>
                    </folder>
                </folder>
            </folder>
        </folder>
    

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 dev@spellchecker.netbeans.org.

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

lahvac

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today