mirror of
https://github.com/RustyRaptor/brackets.git
synced 2026-12-04 00:15:22 -07:00
cleanup based on codereview comments:
Update jsdoc use ExtensionUtils.getModulePath instead of manually slicing up path use FileUtils.readAsText instead of DocumentManager when we only need the text on disk Call CollectionUtils.hasProperty instead of Object.prototype.hasOwnProperty... Add comment explaining logic around finding location of called function for function type hinting remove unnecessary calls to setCursorPos remove stale comments in unittests pull out hint invalidation check into a function and remove check for query.length === 0, not necessary anymore
This commit is contained in:
1 parent
372ce5af1f
commit
10f8896d46
5 files changed
+92
-39
No files matched your search
@@ -160,6 +160,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
|
||||
*
|
||||
@@ -178,15 +195,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;
|
||||
@@ -215,10 +224,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;
|
||||
@@ -398,15 +404,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user