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

org.netbeans.spi.editor.completion
Interface CompletionProvider


@MimeLocation(subfolderName="CompletionProviders")
public interface CompletionProvider

The basic interface for providing code completion items. You should implement this interface if you want to provide items that are available to users when they invoke code completion in a text document. You should register your implementation on the system FileSystem under the Editors/<mime-type> folder. The registered implementation will then be used for documents that are of the specified mime-type.

Related documentation


Field Summary
static int COMPLETION_ALL_QUERY_TYPE
          The int value representing the query for an all code completion.
static int COMPLETION_QUERY_TYPE
          The int value representing the query for a code completion.
static int DOCUMENTATION_QUERY_TYPE
          The int value representing the query for a documentation.
static int TOOLTIP_QUERY_TYPE
          The int value representing the query for a tooltip hint.
 
Method Summary
 CompletionTask createTask(int queryType, JTextComponent component)
          Creates a task that performs a query of the given type on the given component.
 int getAutoQueryTypes(JTextComponent component, String typedText)
          Determines whether text typed in a document should automatically pop up the code completion window.
 

Field Detail

COMPLETION_QUERY_TYPE

static final int COMPLETION_QUERY_TYPE
The int value representing the query for a code completion.

See Also:
Constant Field Values

DOCUMENTATION_QUERY_TYPE

static final int DOCUMENTATION_QUERY_TYPE
The int value representing the query for a documentation.

See Also:
Constant Field Values

TOOLTIP_QUERY_TYPE

static final int TOOLTIP_QUERY_TYPE
The int value representing the query for a tooltip hint.

See Also:
Constant Field Values

COMPLETION_ALL_QUERY_TYPE

static final int COMPLETION_ALL_QUERY_TYPE
The int value representing the query for an all code completion.

See Also:
Constant Field Values
Method Detail

createTask

CompletionTask createTask(int queryType,
                          JTextComponent component)
Creates a task that performs a query of the given type on the given component.

This method is invoked in AWT thread only and the returned task may either be synchronous (if it's not complex) or it may be asynchronous (see AsyncCompletionTask).

The task usually inspects the component's document, the text up to the caret position and returns the appropriate result.

Parameters:
queryType - Type of the query. It can be one of the COMPLETION_QUERY_TYPE, COMPLETION_ALL_QUERY_TYPE, DOCUMENTATION_QUERY_TYPE, or TOOLTIP_QUERY_TYPE (but not their combination).
component - A text component where the query should be performed.
Returns:
A task performing the query.

getAutoQueryTypes

int getAutoQueryTypes(JTextComponent component,
                      String typedText)
Determines whether text typed in a document should automatically pop up the code completion window. This method is called by the code completion infrastructure only to check whether text that has just been typed into a text component triggers an automatic query invocation.

An implementation of this method can return any combination of the query type constants available in this interface to tell the infrastructure that it should call createTask(int, JTextComponent) and show the code completion window. Or it can return zero if the typed text does not trigger popping up the code completion window.

Please note that there could be multiple CompletionProviders registered for the same mime type and this method is called for all of them. This means that even if a particular implementation does not want the code completion window to pop up for the typed text (ie. returns zero from this method) there could be others that recognize the text as a trigger and will return non-zero. If at least one of the registered CompletionProviders returns non-zero from this method the infrastructure will call createTask in all the registered implementations asking them to provide completion items for the requested query type.

Parameters:
component - A component in which the text was typed.
typedText - Typed text.
Returns:
Any combination of the COMPLETION_QUERY_TYPE, COMPLETION_ALL_QUERY_TYPE, DOCUMENTATION_QUERY_TYPE, and TOOLTIP_QUERY_TYPE values, or zero if no query should be automatically invoked.

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

Built on December 5 2011.  |  Portions Copyright 1997-2011 Sun Microsystems, Inc. All rights reserved.