src/JSUtils/node/TernNodeDomain.js
function getTernHints(fileInfo, offset, isProperty) {
    var request = buildRequest(fileInfo, "completions", offset),
        i;
    //_log("request " + dir + " " + file + " " + offset /*+ " " + text */);
    try {
        ternServer.request(request, function (error, data) {
            var completions = [];
            if (error) {
                _log("Error returned from Tern 'completions' request: " + error);
            } else {
                //_log("found " + data.completions + " for " + file + "@" + offset);
                completions = data.completions.map(function (completion) {
                    return {value: completion.name, type: completion.type, depth: completion.depth,
                        guess: completion.guess, origin: completion.origin, doc: completion.doc, url: completion.url};
                });
            }

            if (completions.length > 0 || !isProperty) {
                // Post a message back to the main thread with the completions
                self.postMessage({type: MessageIds.TERN_COMPLETIONS_MSG,
                    file: _getNormalizedFilename(fileInfo.name),
                    offset: offset,
                    completions: completions
                    });
            } else {
                // if there are no completions, then get all the properties
                getTernProperties(fileInfo, offset, MessageIds.TERN_COMPLETIONS_MSG);
            }
        });
    } catch (e) {
        _reportError(e, fileInfo.name);
    }
}
function getTernHints(fileInfo, offset, isProperty) {
    var request = buildRequest(fileInfo, "completions", offset),
        i;
    //_log("request " + dir + " " + file + " " + offset /*+ " " + text */);
    try {
        ternServer.request(request, function (error, data) {
            var completions = [];
            if (error) {
                _log("Error returned from Tern 'completions' request: " + error);
            } else {
                //_log("found " + data.completions + " for " + file + "@" + offset);
                completions = data.completions.map(function (completion) {
                    return {value: completion.name, type: completion.type, depth: completion.depth,
                        guess: completion.guess, origin: completion.origin, doc: completion.doc, url: completion.url};
                });
            }

            if (completions.length > 0 || !isProperty) {
                // Post a message back to the main thread with the completions
                self.postMessage({type: MessageIds.TERN_COMPLETIONS_MSG,
                    file: _getNormalizedFilename(fileInfo.name),
                    offset: offset,
                    completions: completions
                    });
            } else {
                // if there are no completions, then get all the properties
                getTernProperties(fileInfo, offset, MessageIds.TERN_COMPLETIONS_MSG);
            }
        });
    } catch (e) {
        _reportError(e, fileInfo.name);
    }
}
function getTernHints ( fileInfo , offset , isProperty ) { var request = buildRequest ( fileInfo , "completions" , offset ) , i ; //_log("request " + dir + " " + file + " " + offset /*+ " " + text */); try { ternServer . request ( request , function ( error , data ) { var completions = [ ] ; if ( error ) { _log ( "Error returned from Tern 'completions' request: " + error ) ; } else { //_log("found " + data.completions + " for " + file + "@" + offset); completions = data . completions . map ( function ( completion ) { return { value : completion . name , type : completion . type , depth : completion . depth , guess : completion . guess , origin : completion . origin , doc : completion . doc , url : completion . url } ; } ) ; } if ( completions . length > 0 || ! isProperty ) { // Post a message back to the main thread with the completions self . postMessage ( { type : MessageIds . TERN_COMPLETIONS_MSG , file : _getNormalizedFilename ( fileInfo . name ) , offset : offset , completions : completions } ) ; } else { // if there are no completions, then get all the properties getTernProperties ( fileInfo , offset , MessageIds . TERN_COMPLETIONS_MSG ) ; } } ) ; } catch ( e ) { _reportError ( e , fileInfo . name ) ; } }
Get the completions for the given offset

@param {{type: string, name: string, offsetLines: number, text: string}} fileInfo
- 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.
@param {{line: number, ch: number}} offset -
the offset into the file where we want completions for
@param {boolean} isProperty - true if getting a property hint,
otherwise getting an identifier hint.
Get the completions for the given offset