orion.edit.contentAssist

The orion.edit.contentAssist service contributes content assist providers to the editor. A content assist provider produces suggestions for text that may be inserted into the editor at a given point. Providers are invoked when the user triggers the "content assist" action by pressing Ctrl+Space in the editor.

Service methods

Implementations of orion.edit.contentAssist must define the following function:

getKeywords(prefix, buffer, selection)
When content assist is triggered, the editor calls this function to obtain suggestions from a content assist provider.
Returns Array giving possible strings that may be inserted into the editor.
Alternatively, a Dojo promise may be returned, which allows the suggestions to be computed asynchronously.
prefix String The substring extending from the first non-word character preceding the editing caret to the editing caret. This may give a clue about what the user intended to type, and can be used to narrow down the results to be returned.
buffer String The entire buffer being edited.
selection orion.textview.Selection The current selection in the editor.

Service attributes

Implementations of orion.edit.contentAssist must define the following attributes:

name
String Name for the content assist provider.
pattern
String A regular expression pattern matching filenames that this provider can provide content assist for. The provider's getKeywords function will be called only for files that match this pattern.

Examples

var provider = new eclipse.PluginProvider();
provider.registerServiceProvider("orion.edit.contentAssist",
  {
     getKeywords: function(prefix, buffer, selection) {
       return [ "break", "case", "catch", "continue", "debugger", "default", "delete", "do", "else",
                "finally", "for", "function", "if", "in", "instanceof", "new", "return", "switch", "this",
                "throw", "try", "typeof", "var", "void", "while", "with" ];
     }
  },
  {
    name: "JavaScript content assist",
    pattern: "\\.js$"
  });
provider.connect();

The above example provides content assist suggestions for files whose name ends in .js. It offers JavaScript keywords as suggestions.