orion.edit.contentAssist | ||
---|---|---|
![]() |
![]() |
|
orion.edit.command | orion.edit.editor |
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.
Implementations of orion.edit.contentAssist must define the following function:
Returns an Array giving possible completions that may be inserted into the editor. Result elements must be either String objects with literal string completions, or proposal objects with the following properties:
Implementations of orion.edit.contentAssist must define the following attributes:
The example below provides content assist suggestions for files whose name ends in .js. It offers JavaScript keywords as suggestions.
var provider = new eclipse.PluginProvider(); provider.registerServiceProvider("orion.edit.contentAssist", { computeProposals: 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", contentType: ["text.javascript"] }); provider.connect();
The example below will provide completion on the character 'a' that will insert an HTML anchor element. After completion the cursor will be positioned within the href attribute.
var provider = new eclipse.PluginProvider(); provider.registerServiceProvider("orion.edit.contentAssist", { computeProposals: function(prefix, buffer, selection) { var proposals = []; if (prefix === 'a') { proposals.push({ proposal: "a href=\"\"></a>", description: "<a></a> - HTML anchor element", escapePosition: selection.offset+7}); } return proposals; }, { name: "HTML content assist", contentType: ["text.html"] }); provider.connect();
![]() |
![]() |
![]() |
orion.edit.command | orion.edit.editor |