mirror of
https://github.com/RustyRaptor/brackets.git
synced 2026-12-04 00:15:22 -07:00
Update tern and acorn to latest - fixes a number of bugs.
Modified some of the expected output for unittests as tern was updated to produce arguably better results, particularly for jump-to-def. Changed the jump to def logic so that it doesn't stomp on all the pending requests, and instead plays nicely with the other request types.
This commit is contained in:
1 parent
104ff29c51
commit
dfb35c30f5
5 files changed
+84
-85
No files matched your search
@@ -346,6 +346,56 @@ define(function (require, exports, module) {
|
||||
return numInitialFiles !== numResolvedFiles;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a pending request waiting for the tern-worker to complete.
|
||||
*
|
||||
* @param {string} file - the name of the file
|
||||
* @param {number} offset - the offset into the file the request is for
|
||||
* @param {string} type - the type of request
|
||||
* @return {jQuery.Promise} - the promise for the request
|
||||
*/
|
||||
function addPendingRequest(file, offset, type) {
|
||||
var requests,
|
||||
key = file + "@" + offset,
|
||||
$deferredRequest;
|
||||
if (CollectionUtils.hasProperty(pendingTernRequests, key)) {
|
||||
requests = pendingTernRequests[key];
|
||||
} else {
|
||||
requests = {};
|
||||
pendingTernRequests[key] = requests;
|
||||
}
|
||||
|
||||
if (CollectionUtils.hasProperty(requests, type)) {
|
||||
$deferredRequest = requests[type];
|
||||
} else {
|
||||
requests[type] = $deferredRequest = $.Deferred();
|
||||
}
|
||||
return $deferredRequest.promise();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get any pending $.Deferred object waiting on the specified file and request type
|
||||
* @param {string} file - the file
|
||||
* @param {number} offset - the offset in the file the request was at
|
||||
* @param {string} type - the type of request
|
||||
* @return {jQuery.Deferred} - the $.Deferred for the request
|
||||
*/
|
||||
function getPendingRequest(file, offset, type) {
|
||||
var key = file + "@" + offset;
|
||||
if (CollectionUtils.hasProperty(pendingTernRequests, key)) {
|
||||
var requests = pendingTernRequests[key],
|
||||
requestType = requests[type];
|
||||
|
||||
delete pendingTernRequests[key][type];
|
||||
|
||||
if (!Object.keys(requests).length) {
|
||||
delete pendingTernRequests[key];
|
||||
}
|
||||
|
||||
return requestType;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Promise for the definition from TernJS, for the file & offset passed in.
|
||||
* @return {jQuery.Promise} - a promise that will resolve to definition when
|
||||
@@ -360,9 +410,7 @@ define(function (require, exports, module) {
|
||||
text: text
|
||||
});
|
||||
|
||||
var $deferredJump = $.Deferred();
|
||||
pendingTernRequests[file] = $deferredJump;
|
||||
return $deferredJump.promise();
|
||||
return addPendingRequest(file, offset, HintUtils.TERN_JUMPTODEF_MSG);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -393,43 +441,18 @@ define(function (require, exports, module) {
|
||||
*/
|
||||
function handleJumptoDef(response) {
|
||||
|
||||
var file = response.file;
|
||||
var $deferredJump = pendingTernRequests[file];
|
||||
var file = response.file,
|
||||
offset = response.offset;
|
||||
|
||||
pendingTernRequests[file] = null;
|
||||
var $deferredJump = getPendingRequest(file, offset, HintUtils.TERN_JUMPTODEF_MSG);
|
||||
|
||||
// pendingTernRequests[file] = null;
|
||||
|
||||
if ($deferredJump) {
|
||||
$deferredJump.resolveWith(null, [response]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a pending request waiting for the tern-worker to complete.
|
||||
*
|
||||
* @param {string} file - the name of the file
|
||||
* @param {number} offset - the offset into the file the request is for
|
||||
* @param {string} type - the type of request
|
||||
* @return {jQuery.Promise} - the promise for the request
|
||||
*/
|
||||
function addPendingRequest(file, offset, type) {
|
||||
var requests,
|
||||
key = file + "@" + offset,
|
||||
$deferredRequest;
|
||||
if (CollectionUtils.hasProperty(pendingTernRequests, key)) {
|
||||
requests = pendingTernRequests[key];
|
||||
} else {
|
||||
requests = {};
|
||||
pendingTernRequests[key] = requests;
|
||||
}
|
||||
|
||||
if (CollectionUtils.hasProperty(requests, type)) {
|
||||
$deferredRequest = requests[type];
|
||||
} else {
|
||||
requests[type] = $deferredRequest = $.Deferred();
|
||||
}
|
||||
return $deferredRequest.promise();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Promise for the completions from TernJS, for the file & offset passed in.
|
||||
* @param {string} dir - the directory the file is in
|
||||
@@ -529,29 +552,6 @@ define(function (require, exports, module) {
|
||||
return {promise: $deferredHints.promise()};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get any pending $.Deferred object waiting on the specified file and request type
|
||||
* @param {string} file - the file
|
||||
* @param {number} offset - the offset in the file the request was at
|
||||
* @param {string} type - the type of request
|
||||
* @return {jQuery.Deferred} - the $.Deferred for the request
|
||||
*/
|
||||
function getPendingRequest(file, offset, type) {
|
||||
var key = file + "@" + offset;
|
||||
if (CollectionUtils.hasProperty(pendingTernRequests, key)) {
|
||||
var requests = pendingTernRequests[key],
|
||||
requestType = requests[type];
|
||||
|
||||
delete pendingTernRequests[key][type];
|
||||
|
||||
if (!Object.keys(requests).length) {
|
||||
delete pendingTernRequests[key];
|
||||
}
|
||||
|
||||
return requestType;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the response from the tern web worker when
|
||||
* it responds with the list of completions
|
||||
@@ -714,6 +714,7 @@ define(function (require, exports, module) {
|
||||
return resolvedFiles[newFile] !== undefined;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Do the work to initialize a code hinting session.
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user