General Information
Question (arch-what):
What is this project good for?
Answer:
The editor module provides a full-featured source text editor
that is integrated with the Form Editor, Explorer, compiler, and debugger.
List of the main features:
- Syntax highlighting of java, HTML, XML and other languages.
- Code Completion enables to type a few characters
and then display a list of suggestions appropriate
in the given context that can be then used
to automatically complete the expression.
- Word Matching enables enables to type the beginning characters
of a word used elsewhere in the code and then have the editor
generate the rest of the word.
- Abbreviations allow to expand typed text from a few
predefined characters into a full word or phrase.
- Goto Class enables to open a Java file in the Source Editor
by typing only the class name.
The IDE helps to identify the correct package name for the class.
- The Fast Import feature enables to quickly add import statements
for Java classes in the source file.
- Goto Declaration feature allows to quickly jump to a declaration
of a variable under the cursor.
- Goto Source allows to open source file containing
definition of a type that the variable under the cursor is of.
- Code folding allows to collapse sections of the code that are
unimportant to the user at the given time.
For example in java source the collapsable sections include
imports section, inner classes, methods and javadocs.
Question (arch-overall):
Describe the overall architecture.
Answer:
The editor functionality are mainly implementations of the Swing Text package APIs
plus extension features such as Syntax Coloring, Code Completion,
Word Matching, Abbreviations or Macros.
The editor consists of a library part (located under editor/lib
and described in a separate arch document)
and the module part (under src subfolder)
that depends on NetBeans APIs specified in this document.
Question (arch-usecases):
Describe the main
use cases of the new API. Who will use it under
what circumstances? What kind of code would typically need to be written
to use the module?
Answer:
No answer
Question (arch-time):
What are the time estimates of the work?
Answer:
No answer
Question (arch-quality):
How will the quality
of your code be tested and
how are future regressions going to be prevented?
Answer:
No answer
Question (arch-where):
Where one can find sources for your module?
WARNING: Question with id="arch-where" has not been answered!
Project and platform dependencies
Question (dep-nb):
What other NetBeans projects and modules does this one depend on?
Answer:
EditorModuleAPI
-
Editor defines APIs and SPIs both by
- Providing java classes in public packages for further reuse.
Most of the classes were created spontaneously (several years ago)
without fulfilling of the rules imposed on APIs and SPIs
at the present time.
There is an ongoing work to revisit the existing classes
and create stable APIs and SPIs (and possibly extract functionality
into a submodule where appropriate). However this is a long-term
task spanning several promotions.
- Being sensitive to content of certain directories in xml layer.
OpenAPIs
CodeFoldingAPI
EditorUtilAPI
-
Set of various editor-related utility classes and methods.
Question (dep-non-nb):
What other projects outside NetBeans does this one depend on?
Answer:
JAXP
-
Standard XML APIs (DOM, SAX) - distributed with the IDE (in lib/ext/xml-apis*.jar),
already part of JDK 1.4 and newer).
Question (dep-platform):
On which platforms does your module run? Does it run in the same
way on each?
Answer:
The module is 100% pure Java and runs on any platform.
Question (dep-jre):
Which version of JRE do you need (1.2, 1.3, 1.4, etc.)?
Answer:
Needs at least JRE 1.4.
Question (dep-jrejdk):
Do you require the JDK or is the JRE enough?
Answer:
Requires JRE only.
Deployment
Question (deploy-jar):
Do you deploy just module JAR file(s) or other files as well?
Answer:
org-netbeans-modules-editor.jar
- standard module jar file
Question (deploy-nbm):
Can you deploy an NBM via the Update Center?
Answer:
Yes.
Question (deploy-shared):
Do you need to be installed in the shared location only, or in the user directory only,
or can your module be installed anywhere?
Answer:
Module can be installed anywhere.
Question (deploy-packages):
Are packages of your module made inaccessible by not declaring them
public?
Answer:
Description of public packages:
-
org.netbeans.modules.editor
- NetBeans-specific editor infrastructure
-
org.netbeans.modules.editor.html
- NetBeans-specific editor infrastructure
-
org.netbeans.modules.editor.java
- NetBeans-specific java editor infrastructure
-
org.netbeans.modules.editor.options
- Editor generic options support plus options for plain, html and java editors
-
org.netbeans.modules.editor.plain
- NetBeans-specific plain text editor infrastructure
Question (deploy-dependencies):
What do other modules need to do to declare a dependency on this one,
in addition to or instead of the normal module dependency declaration
(e.g. tokens to require)?
Answer:
Nothing.
Compatibility with environment
Question (compat-i18n):
Is your module correctly internationalized?
Answer:
Yes.
Question (compat-standards):
Does the module implement or define any standards? Is the
implementation exact or does it deviate somehow?
Answer:
It conforms to the Swing Text Package API.
Question (compat-version):
Can your module coexist with earlier and future
versions of itself? Can you correctly read all old settings? Will future
versions be able to read your current settings? Can you read
or politely ignore settings stored by a future version?
Answer:
Only one version of the module can be installed at a time.
The settings are shared across different versions, they are stored
in a human readable form in XML files.
Question (compat-deprecation):
How the introduction of your project influences functionality
provided by previous version of the product?
WARNING: Question with id="compat-deprecation" has not been answered!
Access to resources
Question (resources-file):
Does your module use java.io.File
directly?
Answer:
No.
Question (resources-layer):
Does your module provide own layer? Does it create any files or
folders in it? What it is trying to communicate by that and with which
components?
Answer:
Yes, files are created for menus, actions, shortcuts, annotations,
settings storage:
- Global Goto Source action (
JavaFastOpenAction
) registered into /Actions/Edit
and its shortcut into /Shortcuts folder.
- Appropriate menu actions under /Menu/File, /Menu/Edit and /Menu/View.
- Indentation Engines under /Services/IndentEngine folder and /Templates/Services/IndentEngine.
- Editor's warm-up task under /WarmUp folder.
- Editor's options and Annotation Type nodes under /UI/Services/Editing folder
-
Annotation Types can be registered as .xml files under Editors/AnnotationTypes.
An example of a bookmark annotation descrioption xml file can be found
here.
DTDs can be found
here
and
here.
- Mime-type specific editor data under /Editors/mime-type folder (e.g. /Editors/text/plain).
A special mime-type "text/base" means global level inherited by each particular mime-type.
Files and subfolders of Editors/|mime-type|:
-
Editor kit registration by using EditorKit.instance:
<file name="EditorKit.instance">
<attr name="instanceClass" stringvalue="org.netbeans.modules.editor.html.HTMLKit"/>
</file>
-
Popup menu items (actions) can be registered under .../Popup subfolder.
Both system actions and editor's actions can be added to the popup.
The actions can be ordered using a standard sorting mechanism.
<folder name="Popup">
<file name="org-openide-actions-CutAction.instance"/>
<attr name="org-openide-actions-CutAction.instance/org-openide-actions-CopyAction.instance" boolvalue="true"/>
<file name="org-openide-actions-CopyAction.instance"/>
</folder>
Note: As the target mime-type's popup items get merged with "text/base" (global)
items the sorting can refer to the "text/base" as well.
Editor's actions are referenced by their name (Action.NAME
property)
which each editor action mandatorily has:
<folder name="Popup">
<file name="format"/>
</folder>
will add an editor action named "format" into popup.
- Side bar components can be registered under .../SideBar subfolder.
Their appearance can be specified using two optional attributes - position
(accepting values "North"
, "South"
, "East"
and
"West"
) and boolean scrollable
. Default values are
"West"
and "true"
(i.e. component appears in a row header
of JScrollPane displaying the editor's JEditoPane).
<folder name="SideBar">
<file name="org-netbeans-editor-GlyphGutter.instance"/>
<file name="org-netbeans-editor-StatusBar$StatusBarFactory.instance">
<attr name="position" stringvalue="South"/>
<attr name="scrollable" boolvalue="false"/>
</file>
</folder>
-
Default key bindings for a mime-type can be registered as .../Defaults/keybindings.xml.
Global keybindings can be found here
DTD can be found here
-
Default abbreviations for a mime-type can be registered as .../Defaults/abbreviations.xml.
Global keybindings can be found here
DTD can be found here
-
Default macros for a mime-type can be registered as .../Defaults/macros.xml.
DTD can be found here
Please see layer.xml for further details.
The org.netbeans.lib.editor.hyperlink.spi.HyperlinkProvider
instances can be registered by editors for the particular mime-types
into Editors/|mime-type|/HyperlinkProviders.
There can be multiple providers registered and their order
will be respected during querying by the hyperlinking infrastructure
(first provider which recognizes the given offset as a hyperlinking point
will be used).
Question (resources-read):
Does your module read any resources from layers? For what purpose?
Answer:
No.
Question (resources-mask):
Does your module mask/hide/override any resources provided by other modules in
their layers?
Answer:
No.
Question (resources-preferences):
Does your module uses preferences via Preferences API? Does your module use NbPreferences or
or regular JDK Preferences ? Does it read, write or both ?
Does it share preferences with other modules ? If so, then why ?
WARNING: Question with id="resources-preferences" has not been answered!
Lookup of components
Question (lookup-lookup):
Does your module use org.openide.util.Lookup
or any similar technology to find any components to communicate with? Which ones?
Answer:
In src/org/netbeans/modules/editor/EditorModule.java: Lookup.getDefault().lookup(DataLoaderPool.class)
In src/org/netbeans/modules/editor/EditorModule.java: Lookup.getDefault().lookup(DataLoaderPool.class))
In src/org/netbeans/modules/editor/EditorModule.java: Lookup.getDefault().lookup(WindowManager.class)
In src/org/netbeans/modules/editor/NbEditorKit.java: Lookup.getDefault().lookup(Keymap.class)
In src/org/netbeans/modules/editor/NbEditorKit.java: Lookup.getDefault().lookup(ClassLoader.class)
In src/org/netbeans/modules/editor/NbEditorUtilities.java: Lookup.getDefault().lookup(ErrorManager.class)
In src/org/netbeans/modules/editor/NbImplementationProvider.java: Lookup.getDefault().lookup(ClassLoader.class)
In src/org/netbeans/modules/editor/options/BaseOptions.java: Lookup.getDefault().lookup(getDefaultIndentEngineClass())
In src/org/netbeans/modules/editor/options/ColoringArrayEditorPanel.java: Lookup.getDefault().lookup(ClassLoader.class)
In src/org/netbeans/modules/editor/options/KeyBindingsEditorPanel.java: Lookup.getDefault().lookup(ClassLoader.class);
In src/org/netbeans/modules/editor/options/MIMEOptionFile.java: Lookup.getDefault().lookup(ModuleInfo.class);
Question (lookup-register):
Do you register anything into lookup for other code to find?
Answer:
org.netbeans.modules.editor.hyperlink.LayerHyperlinkProviderManager
is registered using META-INF/services
.
It is an extension of org.netbeans.lib.editor.hyperlink.HyperlinkProviderManager
allowing to instantiate the org.netbeans.lib.editor.hyperlink.spi.HyperlinkProvider
instances from the xml layer of the System FS for particular mime-types.
Question (lookup-remove):
Do you remove entries of other modules from lookup?
Answer:
No.
Execution Environment
Question (exec-property):
Is execution of your code influenced by any environment or
Java system (System.getProperty
) property?
On a similar note, is there something interesting that you
pass to java.util.logging.Logger
? Or do you observe
what others log?
Answer:
netbeans.debug.editor.warmup
-
System property to debug execution of the editor's warmup task (e.g. time intervals that each warmup section takes etc.).
netbeans.debug.exceptions
-
Obsolete now, we will remove those when time allows.
Question (exec-component):
Is execution of your code influenced by any (string) property
of any of your components?
Answer:
There are certain document properties (javax.swing.text.Document.getProperty()
)
that influence the document execution:
mimeType
-
Document property containing mime-type of the particular document e.g. "text/x-java".
It allows to search for particular editor settings based on
the mime-type such as tooltip annotations providers etc.
Maintained by org.openide.text
package.
Document.StreamDescriptionProperty
-
Document property containing either DataObject
or FileObject
from which the Document
content was loaded.
Maintained by org.openide.text
package.
DefaultEditorKit.EndOfLineStringProperty
-
Document property containing line separator that was used when the document content was
loaded from a java.io.Reader
by an EditorKit.read()
.
line-limit
-
Document property that determines the number of characters in the longest line
determined during the document loading from a reader by the editor kit.
Following component client properties incluence the component behavior:
errorStripeOnly
-
The component should only be displayed with the error stripe side bar.
The other side bars will not be displayed.
Question (exec-ant-tasks):
Do you define or register any ant tasks that other can use?
Answer:
No.
Question (exec-classloader):
Does your code create its own class loader(s)?
Answer:
No.
Question (exec-reflection):
Does your code use Java Reflection to execute other code?
Answer:
Reflection is used for:
- in the src/org/netbeans/modules/editor/EditorModule.java
the "kitRegistryKey" field JEditorPane is accessed in order
to plug the layer.xml registration of editor kits
into the JeditorPane's method of kit registration seamlessly.
- in the src/org/netbeans/modules/editor/options/MIMEOptionFolder.java
there are two fields "TAG_ROOT" and "FILENAME" accessed by reflection
from a MIMEOptionFile class associated with a given MIMEProcessor.
This could possibly be fixed by adding corresponding package-private methods
into MIMEOptionFile abstract class and access those in the MIMEOptionFolder.
NbKeymap.context
-
The context
field is accessed by reflection
from MultiKeymap.
Question (exec-privateaccess):
Are you aware of any other parts of the system calling some of
your methods by reflection?
Answer:
No.
Question (exec-process):
Do you execute an external process from your module? How do you ensure
that the result is the same on different platforms? Do you parse output?
Do you depend on result code?
Answer:
No.
Question (exec-introspection):
Does your module use any kind of runtime type information (instanceof
,
work with java.lang.Class
, etc.)?
Answer:
No.
Question (exec-threading):
What threading models, if any, does your module adhere to? How the
project behaves with respect to threading?
Answer:
Threading model of the document model adheres to javax.swing.text.Document
interface. There can be multiple reader threads accessing
the document simultaneously but only one mutating thread at the time.
Document.render(Runnable) must be used for all the readonly operations
accessing the document. The editor fully supports org.openide.text.NbDocument.runAtomic()
and NbDocument.runAtomicAsUser() extensions that allow transactions
on top of the document.
All the UI-related tasks adhere to Swing/AWT conventions i.e. they
must be performed in EQ thread.
Question (security-policy):
Does your functionality require modifications to the standard policy file?
Answer:
XXX no answer for security-policy
Question (security-grant):
Does your code grant additional rights to some other code?
Answer:
XXX no answer for security-grant
Format of files and protocols
Question (format-types):
Which protocols and file formats (if any) does your module read or write on disk,
or transmit or receive over the network? Do you generate an ant build script?
Can it be edited and modified?
Answer:
-
Editor settings are stored in .xml files of custom XML format
(DTDs in /src/org/netbeans/modules/editor/resources/DTDs/Options directory)
-
Annotations are stored in the .xml files
(DTDs in /cvs/editor/src/org/netbeans/modules/editor/AnnotationTypes/annotation-type-1_0.dtd and
/cvs/editor/src/org/netbeans/modules/editor/AnnotationTypes/annotation-type-1_1.dtd).
-
Key Bindings are stored in keybindings.xml files
Question (format-dnd):
Which protocols (if any) does your code understand during Drag & Drop?
Answer:
None.
Question (format-clipboard):
Which data flavors (if any) does your code read from or insert to
the clipboard (by access to clipboard on means calling methods on java.awt.datatransfer.Transferable
?
Answer:
- Editor just forwards the clipboard operation requests
into javax.swing.text.JTextComponent's cut(), copy() and paste() methods.
Performance and Scalability
Question (perf-startup):
Does your module run any code on startup?
Answer:
It registers an operation listener to watch for changes in dataobjects.
Question (perf-exit):
Does your module run any code on exit?
Answer:
No.
Question (perf-scale):
Which external criteria influence the performance of your
program (size of file in editor, number of files in menu,
in source directory, etc.) and how well your code scales?
Answer:
The number of characters of the source file multiplied by 2 to respect
2bytes for each unicode characters.
Each line separator adds another line element plus a position
object.
Question (perf-limit):
Are there any hard-coded or practical limits in the number or size of
elements your code can handle?
Answer:
No explicit limits. Technically, the available memory size is the limit...
Question (perf-mem):
How much memory does your component consume? Estimate
with a relation to the number of windows, etc.
Answer:
Rough numbers:
- one source file opened in the editor: 534KB
Question (perf-wakeup):
Does any piece of your code wake up periodically and do something
even when the system is otherwise idle (no user interaction)?
Answer:
No.
Question (perf-progress):
Does your module execute any long-running tasks?
Answer:
Opening a editor can be quite long task.
The creation of the text component (JEditorPane instance) has to be done in AWT event queue
thread.
Setting of the document into the text component has to be done in AWT as well
as the document is regular property and thus it must be modified in AWT only.
Other tasks during editor opening (such as parsing)
do not need to be run in the AWT and they are run on the background.
Question (perf-huge_dialogs):
Does your module contain any dialogs or wizards with a large number of
GUI controls such as combo boxes, lists, trees, or text areas?
Answer:
No.
Question (perf-menus):
Does your module use dynamically updated context menus, or
context-sensitive actions with complicated and slow enablement logic?
Answer:
The "goto declaration" and "goto source" are somewhat complicated
especially during the first invocation.
Question (perf-spi):
How the performance of the plugged in code will be enforced?
Answer:
No answer