Support for opening and editing source files.
The module adds ability to open Java sources and to edit them in the Editor window.
However, the syntax highlighting, code completion and other nice things are provided
by the Editor module.
While editing the source files, Java module tracks position of the caret in the
Editor window, providing support for context-sensitive actions, properties etc.
Source text
parsing
Java module analyzes contents of the source text and provides MOF compliant object model of the java code. Our read-write Java Metamodel is stored in MDR and other modules can easily access the model
through JMI and implement end user features. Let's highlight few of them:
Navigator
The Navigator window provides a compact view of the currently selected file and simplifies navigation between different parts of the file.
For Java files, constructors, methods, and fields are displayed. You can view these members either as a simple list or as an inheritance tree.
(Details...)
Code Completion
The IDE has a dynamic Java code completion feature that enables you to type a few characters and then display a list of possible classes, methods, variables, and so on that can be used to automatically complete the expression.
(Details...)
Mark Occurrences
This module is not part of NetBeans 5.0. It is available on Development Update Center.
The Mark Occurrences module highlights the references to Class, Method, Field, Parameter or Local variable under the caret in a Java Source File. It also highlights the normal and exceptional method returns when the caret is on the method's return type symbol. When the caret is on a Throwable in the throws clause of the method declaration the places where that Throwable is potentially thrown are highlighted. This includes method invocations and throw statements.
(Details...)
As the user is editing the source in the editor, Java module tries to update the structure
on the background, providing accurate high-level view for the source text. Nodes
are created for individual language elements: classes, constructors, fields,
methods and even initializers and structured in the tree to reflect hierarchical
structure of the source text. Each of the nodes corresponds to a portion of text
that defines that particular piece of code.
Source generation
Probably the most important part of the module enables
other parts of the IDE to manipulate the source text without knowing the boring
details about the exact text layout. For example, if you use Rename Refactoring, you'll get a
dialog asking for new name. But the Refactoring module does not write changes directly to the source,
it even does not know what position it should write to. Instead, it uses JMI for Java Metamodel and ask the Java module to do the change.
Writable Java Metamodel is background technology for many features:
Editor Hints
As you are typing in the Source Editor, the IDE detects and marks errors with the error glyph and other markers. For some errors, the IDE can suggest can suggest a solution and generate the necessary code. When the IDE can provide such a hint to correct the error, the lightbulb icon appears in the left margin.
(Details...)
Refactoring
When you use the IDE's refactoring operations, you can change the structure of your code and have the rest of your code updated to reflect the changes you have made.
(Details...)
Override Methods
You can use the Override and Implement Methods dialog box to quickly view all interface and superclass methods for a Java class and select which methods to override. Just go to main menu and try Source | Override Methods.
Fix Imports
Adds import statements that are needed by your code.
Removes unused import statements.
Surround With Try-catch
In the Source Editor, you can quickly generate code for try-catch blocks or convert existing blocks into try-catch blocks.
(Details...)
Pluggable
interface
The module exports an interface that can be used by
other modules to hook into node's creation process allowing them to change the
way the text is presented in the Explorer. The modules might
create additional nodes, change the default ones, change icon, attach additional
properties. The mechanism is currently used by JavaDoc module and Bean Patterns module.
Nodes created in the explorer offer a variety of actions that can be done with individual elements. Since the elements are coupled with the corresponding portions of text, changes made to the nodes will be written to the source text as appropriate Java code pieces. After a background reparse the nodes are updated to reflect the current text contents, so you can safely switch to the editor and edit the source text itself - choose whichever suits you best.
Creating new elements
is simplified by "New..." action on the context
menu. When invoked, it brings up a Customizer
that helps you with the element creation. The module puts the new element at the
appropriate place into the source text.
Want to comment or help ?
Since the basic features of the module are (more or less)
done, we might focus on tools built on top of the infrastructure too. We are open
to your ideas. If you feel that you would use some tool that performs boring tasks
on the source text(s) that can or if you have suggestions and improvements for
the existing ones, feel free to use
NetBeans mailing lists.