ScopeManager
Import :
const ScopeManager = brackets.getModule("JSUtils/ScopeManager")
getBuiltins() ⇒ Array.<string>
An array of library names that contain JavaScript builtins definitions.
Kind: global function
Returns: Array.<string>
- - array of library names.
postMessage()
Send a message to the tern module - if the module is being initialized, the message will not be posted until initialization is complete
Kind: global function
addPendingRequest(file, offset, type) ⇒ jQuery.Promise
Add a pending request waiting for the tern-module to complete. If file is a detected exclusion, then reject request.
Kind: global function
Returns: jQuery.Promise
- - the promise for the request
Param | Type | Description |
---|---|---|
file | string | the name of the file |
offset | Object | the offset into the file the request is for |
type | string | the type of request |
getPendingRequest(file, offset, type) ⇒ jQuery.Deferred
Get any pending $.Deferred object waiting on the specified file and request type
Kind: global function
Returns: jQuery.Deferred
- - the $.Deferred for the request
Param | Type | Description |
---|---|---|
file | string | the file |
offset | Object | the offset into the file the request is for |
type | string | the type of request |
getResolvedPath(file) ⇒ string
Kind: global function
Returns: string
- returns the path we resolved when we tried to parse the file, or undefined
Param | Type | Description |
---|---|---|
file | string | a relative path |
filterText(the) ⇒ string
check to see if the text we are sending to Tern is too long.
Kind: global function
Returns: string
- the text, or the empty text if the original was too long
Param | Type | Description |
---|---|---|
the | string | text to check |
requestJumptoDef(session, document, offset) ⇒ jQuery.Promise
Request Jump-To-Definition from Tern.
Kind: global function
Returns: jQuery.Promise
- - The promise will not complete until tern
has completed.
Param | Type | Description |
---|---|---|
session | session | the session |
document | Document | the document |
offset | Object | the offset into the document |
getTernHints(fileInfo, offset, isProperty) ⇒ jQuery.Promise
Get a Promise for the completions from TernJS, for the file & offset passed in.
Kind: global function
Returns: jQuery.Promise
- - a promise that will resolve to an array of completions when
it is done
Param | Type | Description |
---|---|---|
fileInfo | Object | - type of update, name of file, and the text of the update. For "full" updates, the whole text of the file is present. For "part" updates, the changed portion of the text. For "empty" updates, the file has not been modified and the text is empty. |
offset | Object | the offset in the file the hints should be calculate at |
isProperty | boolean | true if getting a property hint, otherwise getting an identifier hint. |
requestGuesses(session, document) ⇒ jQuery.Promise
Get a Promise for all of the known properties from TernJS, for the directory and file. The properties will be used as guesses in tern.
Kind: global function
Returns: jQuery.Promise
- - The promise will not complete until the tern
request has completed.
Param | Type | Description |
---|---|---|
session | Session | the active hinting session |
document | Document | the document for which scope info is desired |
TernModule()
Encapsulate all the logic to talk to the tern module. This will create a new instance of a TernModule, which the rest of the hinting code can use to talk to the tern node domain, without worrying about initialization, priming the pump, etc.
Kind: global function
TernModule.getResolvedPath(file) ⇒ string
Kind: inner method of TernModule
Returns: string
- returns the path we resolved when we tried to parse the file, or undefined
Param | Type | Description |
---|---|---|
file | string | a relative path |
TernModule.postMessage()
Send a message to the tern node domain - if the module is being initialized, the message will not be posted until initialization is complete
Kind: inner method of TernModule
TernModule.handleEditorChange(session, document, previousDocument)
Called each time a new editor becomes active.
Kind: inner method of TernModule
Param | Type | Description |
---|---|---|
session | Session | the active hinting session (TODO: currently unused by doEditorChange()) |
document | Document | the document of the editor that has changed |
previousDocument | Document | the document of the editor is changing from |
requestParameterHint(session, functionOffset) ⇒ jQuery.Promise
Request a parameter hint from Tern.
Kind: global function
Returns: jQuery.Promise
- - The promise will not complete until the
hint has completed.
Param | Type | Description |
---|---|---|
session | Session | the active hinting session |
functionOffset | Object | the offset of the function call. |
requestHints(session, document) ⇒ jQuery.Promise
Request hints from Tern.
Note that successive calls to getScope may return the same objects, so clients that wish to modify those objects (e.g., by annotating them based on some temporary context) should copy them first. See, e.g., Session.getHints().
Kind: global function
Returns: jQuery.Promise
- - The promise will not complete until the tern
hints have completed.
Param | Type | Description |
---|---|---|
session | Session | the active hinting session |
document | Document | the document for which scope info is desired |
handleFileChange(changeList)
Called each time the file associated with the active editor changes. Marks the file as being dirty.
Kind: global function
Param | Type | Description |
---|---|---|
changeList | Object | An object representing the change range with from and to properties, each containing line and ch numbers. |
handleEditorChange(session, document, previousDocument)
Called each time a new editor becomes active.
Kind: global function
Param | Type | Description |
---|---|---|
session | Session | the active hinting session |
document | Document | the document of the editor that has changed |
previousDocument | Document | the document of the editor is changing from |
handleProjectClose()
Do some cleanup when a project is closed. Clean up previous analysis data from the module
Kind: global function
handleProjectOpen([projectRootPath])
Read in project preferences when a new project is opened. Look in the project root directory for a preference file.
Kind: global function
Param | Type | Description |
---|---|---|
[projectRootPath] | string | new project root path(optional). Only needed for unit tests. |