Merge pull request #3477 from eztierney/codereview-cleanup

Cleanup for comments from pull request #3439, switch to tern hinting
This commit is contained in:
Kevin Dangoor committed 2013-04-22 06:47:48 -07:00
commit 5544fd6f38
5 files changed
+92 -39

No files matched your search

@@ -164,6 +164,23 @@ define(function (require, exports, module) {
function JSHints() {
}
/**
* determine if the cached hint information should be invalidated and re-calculated
*
* @param {Session} session - the active hinting session
* @return {boolean} - true if the hints should be recalculated
*/
JSHints.prototype.needNewHints = function (session) {
var cursor = session.getCursor(),
type = session.getType();
return !cachedHints ||
cachedLine !== cursor.line ||
type.property !== cachedType.property ||
type.context !== cachedType.context ||
type.showFunctionType !== cachedType.showFunctionType;
};
/**
* Determine whether hints are available for a given editor context
*
@@ -182,15 +199,7 @@ define(function (require, exports, module) {
type = session.getType(),
query = session.getQuery();
// Invalidate cached information if: 1) no scope exists; 2) the
// cursor has moved a line; 3) the scope is dirty; or 4) if the
// cursor has moved into a different scope. Cached information
// is also reset on editor change.
if (!cachedHints ||
cachedLine !== cursor.line ||
type.property !== cachedType.property ||
type.context !== cachedType.context ||
type.showFunctionType !== cachedType.showFunctionType) {
if (this.needNewHints(session)) {
//console.log("clear hints");
cachedLine = null;
cachedHints = null;
@@ -219,10 +228,7 @@ define(function (require, exports, module) {
// Compute fresh hints if none exist, or if the session
// type has changed since the last hint computation
if (!cachedHints ||
type.property !== cachedType.property ||
type.context !== cachedType.context ||
type.showFunctionType !== cachedType.showFunctionType || query.length === 0) {
if (this.needNewHints(session)) {
var offset = session.getOffset(),
scopeResponse = ScopeManager.requestHints(session, session.editor.document, offset),
self = this;
@@ -402,15 +408,11 @@ define(function (require, exports, module) {
if (resolvedPath) {
CommandManager.execute(Commands.FILE_OPEN, {fullPath: resolvedPath})
.done(function () {
session.editor.setCursorPos(jumpResp.start);
session.editor.setSelection(jumpResp.start, jumpResp.end);
session.editor.centerOnCursor();
session.editor.setSelection(jumpResp.start, jumpResp.end, true);
});
}
} else {
session.editor.setCursorPos(jumpResp.start);
session.editor.setSelection(jumpResp.start, jumpResp.end);
session.editor.centerOnCursor();
session.editor.setSelection(jumpResp.start, jumpResp.end, true);
}
}