org.rhq.scripting
Interface CodeCompletion


public interface CodeCompletion

An interface for performing code completion in a given language. This inspired by the jline's Completor interface but is defined separately so that we don't introduce a dependency on jline where it doesn't make sense.

Author:
Lukas Krejci

Method Summary
 int complete(PrintWriter output, String context, int cursorPosition, List candidates)
          Generates the completion candidates and fills the supplied list with them.
 void setMetadataProvider(MetadataProvider metadataProvider)
          Provides the code completion implementation with the metadata provider it can use to format more meaningful completion hints.
 void setScriptContext(ScriptContext scriptContext)
          The code completor can use the provided script context to find out about possible completions.
 

Method Detail

setScriptContext

void setScriptContext(ScriptContext scriptContext)
The code completor can use the provided script context to find out about possible completions.

This method is called once before the first complete(PrintWriter, String, int, List) method is called.

Parameters:
scriptContext -

setMetadataProvider

void setMetadataProvider(MetadataProvider metadataProvider)
Provides the code completion implementation with the metadata provider it can use to format more meaningful completion hints.

Parameters:
metadataProvider -

complete

int complete(PrintWriter output,
             String context,
             int cursorPosition,
             List candidates)
Generates the completion candidates and fills the supplied list with them.

Parameters:
output - the output the completor can use to write some additional information to convey some additional info to the user
context - the context of the code completion, usually that is the current statement being edited by the user
cursorPosition - the position of the cursor inside the context
completions - this should be a list of strings but is intentionally left raw so that this interface is compatible with jline's Completor.
Returns:
the character index in the context for which the completion candidates were actually generated (might be different from the cursorPosition).


Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.