diff --git a/docs/API-Reference/editor/CodeHintManager.md b/docs/API-Reference/editor/CodeHintManager.md index 5739d4ad0d..986b86748c 100644 --- a/docs/API-Reference/editor/CodeHintManager.md +++ b/docs/API-Reference/editor/CodeHintManager.md @@ -47,13 +47,17 @@ __CodeHintProvider Overview:__ A code hint provider should implement the following three functions: +```js - `CodeHintProvider.hasHints(editor, implicitChar)` - `CodeHintProvider.getHints(implicitChar)` - `CodeHintProvider.insertHint(hint)` +``` The behavior of these three functions is described in detail below. +```js __CodeHintProvider.hasHints(editor, implicitChar)__ +``` The method by which a provider indicates intent to provide hints for a given editor. The manager calls this method both when hints are @@ -83,21 +87,25 @@ may wish to prepare to cache data suitable for the current session. In particular, it should keep a reference to the editor object so that it can access the editor in future calls to getHints and insertHints. +```js param {Editor} editor +``` A non-null editor object for the active window. -param {string} implicitChar +param {String} implicitChar Either null, if the hinting request was explicit, or a single character that represents the last insertion and that indicates an implicit hinting request. -return {boolean} +return {Boolean} Determines whether the current provider is able to provide hints for the given editor context and, in case implicitChar is non- null, whether it is appropriate to do so. +```js __CodeHintProvider.getHints(implicitChar)__ +``` The method by which a provider provides hints for the editor context associated with the current session. The getHints method is called only @@ -152,15 +160,17 @@ once for each such editor change. Consequently, the provider may also assume that the document will not be changed outside of the editor during a session. -param {string} implicitChar +param {String} implicitChar Either null, if the request to update the hint list was a result of navigation, or a single character that represents the last insertion. +```js return {jQuery.Deferred|{ hints: Array., match: string, selectInitial: boolean, handleWideResults: boolean}} +``` Null if the provider wishes to end the hinting session. Otherwise, a response object, possibly deferred, that provides 1. a sorted array @@ -180,8 +190,9 @@ choose to let the manager handle emphasis for the simple and common case of prefix matching, or can provide its own emphasis if it wishes to use a more sophisticated matching algorithm. - +```js __CodeHintProvider.insertHint(hint)__ +``` The method by which a provider inserts a hint into the editor context associated with the current session. The provider may assume that the @@ -193,17 +204,17 @@ or not the end of the session should be immediately followed by a new explicit hinting request, which may result in a new hinting session being opened with some provider, but not necessarily the current one. -param {string} hint +param {String} hint The hint to be inserted into the editor context for the current session. -return {boolean} +return {Boolean} Indicates whether the manager should follow hint insertion with an explicit hint request. __CodeHintProvider.insertHintOnTab__ -type {?boolean} insertHintOnTab +type {Boolean} insertHintOnTab Indicates whether the CodeHintManager should request that the provider of the current session insert the currently selected hint on tab key events, or if instead a tab character should be inserted into the editor. If omitted, diff --git a/docs/API-Reference/editor/Editor.md b/docs/API-Reference/editor/Editor.md index 1bd96a8449..0eab9d2e49 100644 --- a/docs/API-Reference/editor/Editor.md +++ b/docs/API-Reference/editor/Editor.md @@ -47,6 +47,7 @@ const Editor = brackets.getModule("editor/Editor") * [.charCoords(pos, [mode])](#Editor+charCoords) ⇒ Object * [.getToken([cursor], [precise])](#Editor+getToken) ⇒ Object * [.getCharacterAtPosition(pos)](#Editor+getCharacterAtPosition) ⇒ string \| null + * [.getLine(lineNumber)](#Editor+getLine) ⇒ string \| null * [.getPrevCharacterAtPosition(pos)](#Editor+getPrevCharacterAtPosition) ⇒ string \| null * [.getNextToken([cursor], [skipWhitespace], [precise])](#Editor+getNextToken) ⇒ Object * [.getPreviousToken([cursor], [skipWhitespace], [precise])](#Editor+getPreviousToken) ⇒ Object @@ -554,6 +555,19 @@ x|y where `|` is the cursor, will return y | --- | --- | --- | | pos | CodeMirror.Position | The position from which to retrieve the character. This should be an object with `line` and `ch` properties. | + + +### editor.getLine(lineNumber) ⇒ string \| null +Retrieves a single line text + +**Kind**: instance method of [Editor](#Editor) +**Returns**: string \| null - The text at the given position if within bounds, + otherwise `null` if the position is out of range. + +| Param | Type | Description | +| --- | --- | --- | +| lineNumber | number | The lineNumber to extract text from | + ### editor.getPrevCharacterAtPosition(pos) ⇒ string \| null diff --git a/src/editor/CodeHintManager.js b/src/editor/CodeHintManager.js index f3b3841c9b..74823f5e87 100644 --- a/src/editor/CodeHintManager.js +++ b/src/editor/CodeHintManager.js @@ -63,13 +63,17 @@ * * A code hint provider should implement the following three functions: * + * ```js * - `CodeHintProvider.hasHints(editor, implicitChar)` * - `CodeHintProvider.getHints(implicitChar)` * - `CodeHintProvider.insertHint(hint)` + * ``` * * The behavior of these three functions is described in detail below. * + * ```js * __CodeHintProvider.hasHints(editor, implicitChar)__ + * ``` * * The method by which a provider indicates intent to provide hints for a * given editor. The manager calls this method both when hints are @@ -99,21 +103,25 @@ * particular, it should keep a reference to the editor object so that it * can access the editor in future calls to getHints and insertHints. * + * ```js * param {Editor} editor + * ``` * A non-null editor object for the active window. * - * param {string} implicitChar + * param {String} implicitChar * Either null, if the hinting request was explicit, or a single character * that represents the last insertion and that indicates an implicit * hinting request. * - * return {boolean} + * return {Boolean} * Determines whether the current provider is able to provide hints for * the given editor context and, in case implicitChar is non- null, * whether it is appropriate to do so. * * + * ```js * __CodeHintProvider.getHints(implicitChar)__ + * ``` * * The method by which a provider provides hints for the editor context * associated with the current session. The getHints method is called only @@ -168,15 +176,17 @@ * assume that the document will not be changed outside of the editor * during a session. * - * param {string} implicitChar + * param {String} implicitChar * Either null, if the request to update the hint list was a result of * navigation, or a single character that represents the last insertion. * + * ```js * return {jQuery.Deferred|{ * hints: Array., * match: string, * selectInitial: boolean, * handleWideResults: boolean}} + * ``` * * Null if the provider wishes to end the hinting session. Otherwise, a * response object, possibly deferred, that provides 1. a sorted array @@ -196,8 +206,9 @@ * of prefix matching, or can provide its own emphasis if it wishes to use * a more sophisticated matching algorithm. * - * + * ```js * __CodeHintProvider.insertHint(hint)__ + * ``` * * The method by which a provider inserts a hint into the editor context * associated with the current session. The provider may assume that the @@ -209,17 +220,17 @@ * explicit hinting request, which may result in a new hinting session * being opened with some provider, but not necessarily the current one. * - * param {string} hint + * param {String} hint * The hint to be inserted into the editor context for the current session. * - * return {boolean} + * return {Boolean} * Indicates whether the manager should follow hint insertion with an * explicit hint request. * * * __CodeHintProvider.insertHintOnTab__ * - * type {?boolean} insertHintOnTab + * type {Boolean} insertHintOnTab * Indicates whether the CodeHintManager should request that the provider of * the current session insert the currently selected hint on tab key events, * or if instead a tab character should be inserted into the editor. If omitted,