src/JSUtils/ScopeManager.js
function _maybeReset(session, document, force) {
        var newTernModule;
        // if we're in the middle of a reset, don't have to check
        // the new module will be online soon
        if (!resettingDeferred) {

            // We don't reset if the debugging flag is set
            // because it's easier to debug if the module isn't
            // getting reset all the time.
            if (currentModule.resetForced || force || (!config.noReset && ++_hintCount > MAX_HINTS)) {
                if (config.debug) {
                    console.debug("Resetting tern module");
                }

                resettingDeferred = new $.Deferred();
                newTernModule = new TernModule();
                newTernModule.handleEditorChange(session, document, null);
                newTernModule.whenReady(function () {
                    // reset the old module
                    currentModule.resetModule();
                    currentModule = newTernModule;
                    resettingDeferred.resolve(currentModule);
                    // all done reseting
                    resettingDeferred = null;
                });
                _hintCount = 0;
            } else {
                var d = new $.Deferred();
                d.resolve(currentModule);
                return d.promise();
            }
        }

        return resettingDeferred.promise();
    }
function _maybeReset(session, document, force) {
        var newTernModule;
        // if we're in the middle of a reset, don't have to check
        // the new module will be online soon
        if (!resettingDeferred) {

            // We don't reset if the debugging flag is set
            // because it's easier to debug if the module isn't
            // getting reset all the time.
            if (currentModule.resetForced || force || (!config.noReset && ++_hintCount > MAX_HINTS)) {
                if (config.debug) {
                    console.debug("Resetting tern module");
                }

                resettingDeferred = new $.Deferred();
                newTernModule = new TernModule();
                newTernModule.handleEditorChange(session, document, null);
                newTernModule.whenReady(function () {
                    // reset the old module
                    currentModule.resetModule();
                    currentModule = newTernModule;
                    resettingDeferred.resolve(currentModule);
                    // all done reseting
                    resettingDeferred = null;
                });
                _hintCount = 0;
            } else {
                var d = new $.Deferred();
                d.resolve(currentModule);
                return d.promise();
            }
        }

        return resettingDeferred.promise();
    }
function _maybeReset ( session , document , force ) { var newTernModule ; // if we're in the middle of a reset, don't have to check // the new module will be online soon if ( ! resettingDeferred ) { // We don't reset if the debugging flag is set // because it's easier to debug if the module isn't // getting reset all the time. if ( currentModule . resetForced || force || ( ! config . noReset && ++ _hintCount > MAX_HINTS ) ) { if ( config . debug ) { console . debug ( "Resetting tern module" ) ; } resettingDeferred = new $ . Deferred ( ) ; newTernModule = new TernModule ( ) ; newTernModule . handleEditorChange ( session , document , null ) ; newTernModule . whenReady ( function ( ) { // reset the old module currentModule . resetModule ( ) ; currentModule = newTernModule ; resettingDeferred . resolve ( currentModule ) ; // all done reseting resettingDeferred = null ; } ) ; _hintCount = 0 ; } else { var d = new $ . Deferred ( ) ; d . resolve ( currentModule ) ; return d . promise ( ) ; } } return resettingDeferred . promise ( ) ; }
reset the tern module, if necessary.

During debugging, you can turn this automatic resetting behavior off
by running this in the console:
brackets._configureJSCodeHints({ noReset: true })

This function is also used in unit testing with the "force" flag to
reset the module for each test to start with a clean environment.

@param {Session} session
@param {Document} document
@param {boolean} force true to force a reset regardless of how long since the last one
@return {Promise} Promise resolved when the module is ready.
The new (or current, if there was no reset) module is passed to the callback.
reset the tern module if necessary .