Skip to main content

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

ParamTypeDescription
filestringthe name of the file
offsetObjectthe offset into the file the request is for
typestringthe 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

ParamTypeDescription
filestringthe file
offsetObjectthe offset into the file the request is for
typestringthe 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

ParamTypeDescription
filestringa 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

ParamTypeDescription
thestringtext 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.

ParamTypeDescription
sessionsessionthe session
documentDocumentthe document
offsetObjectthe 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

ParamTypeDescription
fileInfoObject- 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.
offsetObjectthe offset in the file the hints should be calculate at
isPropertybooleantrue 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.

ParamTypeDescription
sessionSessionthe active hinting session
documentDocumentthe 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

ParamTypeDescription
filestringa 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

ParamTypeDescription
sessionSessionthe active hinting session (TODO: currently unused by doEditorChange())
documentDocumentthe document of the editor that has changed
previousDocumentDocumentthe 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.

ParamTypeDescription
sessionSessionthe active hinting session
functionOffsetObjectthe 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.

ParamTypeDescription
sessionSessionthe active hinting session
documentDocumentthe 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

ParamTypeDescription
changeListObjectAn 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

ParamTypeDescription
sessionSessionthe active hinting session
documentDocumentthe document of the editor that has changed
previousDocumentDocumentthe 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

ParamTypeDescription
[projectRootPath]stringnew project root path(optional). Only needed for unit tests.