站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc 5.5.0

Overview (NetBeans Editor Code Completion SPI) - NetBeans API Javadoc 5.5.0

org.netbeans.modules.editor.completion/1 1.6.22

NetBeans Editor Code Completion SPI

See:
          Description

Editor Code Completion SPI
org.netbeans.api.editor.completion  
org.netbeans.spi.editor.completion  
org.netbeans.spi.editor.completion.support  

 

The Code Completion module is located under /cvs/editor/completion directory. It provides the CodeCompletionAPI with a simple API for showing and hiding of the completion located in org.netbeans.api.editor.completion and with SPI defining the completion providers that is located in org.netbeans.spi.editor.completion, and the implementation located in org.netbeans.modules.editor.completion.

What is New (see all changes)?

Use Cases

API

Show or hide completion window

The API is small and it only allows to explicitly show or hide the completion window.
It's being used by code templates that need to explicitly show the code completion window when tabbing to a particular parameter.
There may be certain actions that want to ensure that the code completion is hidden at the time when they are invoked. For example the actions pasting the content of the completion item into the document.

SPI

Provide completion content by independent providers

Completion infrastructure needs to obtain the results that are then displayed in the completion window.
There are three types of displayed results related to the current caret offset:

  • Code completion items
  • Documentation (e.g. the javadoc documentation)
  • Tooltip (e.g. for method parameters)

For the purpose of obtaining these completion results CompletionProvider exists.
There may be an arbitrary number of independent completion providers for a single completion popup window.
The completion providers are registered through the xml layer into Editors/<mime-type>/CompletionProviders. Once the document with the particular mime-type gets loaded the corresponding completion providers will get instantiated and used.

Threading:
The code completion's infrastructure invokes the requests for the completion results in the AWT thread.
Therefore all the methods of the completion providers are invoked in AWT thread but they may reschedule their processing into other threads.

Provide completion results computed asynchronously

The completion provider creates a task that computes the resulting data that will then be displayed by the code completion infrastructure.
The task creation and computation are called synchronously from the AWT event dispatch thread.
However there can be potentially long-running tasks (e.g. working with MDR) that are not desirable to be run in AWT thread.
Therefore the completion infrastructure provides a listener to which the completion task notifies the results.
The support class AsyncCompletionTask allows to post the task computation into RequestProcessor.

Provide list of completion items fulfilling various requirements

The completion task computes a collection of completion items which are then collected by the completion infrastructure and displayed.
Displaying. Each completion item must be able to display itself in a JList.
Sorting. The completion items may come from different completion providers and they must be sorted before displaying. The sort order should not only be alphabetical but it should also allow a prioritization of the items according to their importance in the given context.
Actions. The interaction of the user with the completion item is done by interacting with item's input map and action map.
Documentation. The item may want to display additional detailed information in a documentation popup window.

Exported Interfaces

This table lists all of the module exported APIs with defined stability classifications. It is generated based on answers to questions about the architecture of the module. Read them all...
Group of java interfaces
Interface NameIn/OutStabilitySpecified in What Document?
CodeCompletionAPIExportedOfficialindex.html

Implementation Details

What do other modules need to do to declare a dependency on this one?
OpenIDE-Module-Module-Dependecies: org.netbeans.modules.editor.completion/1 > 1.6.22

Read more about the implementation in the answers to architecture questions.


org.netbeans.modules.editor.completion/1 1.6.22

Built on May 28 2007.  |  Portions Copyright 1997-2005 Sun Microsystems, Inc. All rights reserved.