saker.build Documentation TaskDoc JavaDoc Packages
public interface ScriptCompletionProposal
Interface for defining the functionality of a script completion proposal.

A completion proposal consists of a label to display in the completion popup, a list of text changes to apply when the proposal is selected, and additional information to describe the semantics of the proposal.

The label is combined of multiple parts to optinally separately stylize the displayed text. (getDisplayString(), getDisplayType(), getDisplayRelation()) The proposal label is usually displayed in the following format:

 <getDisplayString()> : <getDisplayType()> - <getDisplayRelation()>
 
If any of the extension display label methods return null, their part is omitted (with the preceeding separator).

The text changes are a list of modifications to the source code which are applied after each other. All the positions in a text change is relative to the original document on which the proposal request was invoked. The text changes must not overlap in range. This is similar to the behaviour described in the Language Server Procol. See LSP TextEdit[] strucure.

Additional information may be displayed to the user when a proposal is highlighted. It can be returned in a formatted structure using getInformation().

Methods
public default String
Gets the relation label to display in the proposal popup for this item.
public String
Gets the primary label to dislay in the proposal popup for this item.
public default String
Gets the secondary label to display in the proposal popup for this item.
public default PartitionedTextContent
Gets the semantic informations about this proposal.
public default String
Gets the identifier that is associated with this proposal schema.
public default Map<String, String>
Gets the schema meta-data that is associated with the proposal.
public int
Gets the selection offset where the cursor should be moved to after the text changes are applied.
public default String
Gets an arbitary text for sorting the proposals.
public List<extends CompletionProposalEdit>
Gets the edits to apply when this proposal is selected by the user.
public default String getDisplayRelation()
Gets the relation label to display in the proposal popup for this item.

A good vlaue for this might be the enclosing related element in the source code for the semantic item in this proposal. (E.g. an enclosing class name for a called method, the task name for a proposed parameter name).

See the usual display format in the documentation of ScriptCompletionProposal.

The display relation.
public abstract String getDisplayString()
Gets the primary label to dislay in the proposal popup for this item.

See the usual display format in the documentation of ScriptCompletionProposal.

The string to display.
public default String getDisplayType()
Gets the secondary label to display in the proposal popup for this item.

A good value for this might be the expected type of the semantic item for this proposal. (E.g. method/task return type.)

See the usual display format in the documentation of ScriptCompletionProposal.

The display type.
Gets the semantic informations about this proposal.
The partitioned text content describing the proposal or null if not available.
public default String getSchemaIdentifier()
Gets the identifier that is associated with this proposal schema.

The schema identifiers are arbitrary strings that should uniquely identify the nature of the proposal. It can be used by IDE plugins and others to interpret the proposal and present the user a more readable display.

One use case for this is to create IDE plugins that assign various icons for the proposal.

E.g.:

 "org.company.scripting.proposal"
 
The schema identifier or null if none.
public default Map<String, String> getSchemaMetaData()
Gets the schema meta-data that is associated with the proposal.

The meta-data can contain arbitrary key-value pairs that can be used to describe various aspects of the proposal. This is used to convey information to the IDE plugins about different aspects of the proposal.

The meta-data for the proposal. May be null or empty.
public abstract int getSelectionOffset()
Gets the selection offset where the cursor should be moved to after the text changes are applied.

The returned offset is an offset in the resulting document. (Unlike the offsets in getTextChanges().)

Not all IDE implementations support this method.

The offset of the cursor after applying the text changes.
public default String getSortingInformation()
Gets an arbitary text for sorting the proposals.

IDE implementations may sort the proposals based on the returned text. The sorting is stable, equal elements will not be reordered.

Implementations should test the behaviour of returning non-null from this method by testing in an IDE.

Returning null is usually fine.

The sorting information or null.
public abstract List<extends CompletionProposalEdit> getTextChanges()
Gets the edits to apply when this proposal is selected by the user.

The regions in the text changes must not overlap.

The changes are applied in sequential order.

An unmodifiable list of proposal edits.