Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Replace .isResolved & .isRejected with .state #3665

Merged
merged 3 commits into from
Apr 30, 2013
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/editor/CodeHintManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ define(function (require, exports, module) {
if (sessionEditor) {
if (sessionEditor === editor &&
(hintList.isOpen() ||
(deferredHints && !deferredHints.isResolved() && !deferredHints.isRejected()))) {
(deferredHints && deferredHints.state() === "pending"))) {
return true;
} else {
// the editor has changed
Expand Down
2 changes: 1 addition & 1 deletion src/extensibility/Package.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ define(function (require, exports, module) {
*/
function cancelDownload(downloadId) {
// TODO: if we're still waiting on the NodeConnection, how do we cancel?
console.assert(_nodeConnectionDeferred.isResolved());
console.assert(_nodeConnectionDeferred.state() === "resolved");
_nodeConnectionDeferred.done(function (connection) {
connection.domains.extensionManager.abortDownload(downloadId);
});
Expand Down
8 changes: 3 additions & 5 deletions src/extensions/default/HTMLCodeHints/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ define(function (require, exports, module) {
self.cachedHints.queryDir = queryDir;
self.cachedHints.docDir = docDir;

if (!self.cachedHints.deferred.isRejected()) {
if (self.cachedHints.deferred.state() !== "rejected") {
var currentDeferred = self.cachedHints.deferred;
// Since we've cached the results, the next call to _getUrlList should be synchronous.
// If it isn't, we've got a problem and should reject both the current deferred
Expand All @@ -296,13 +296,11 @@ define(function (require, exports, module) {
if (syncResults instanceof Array) {
currentDeferred.resolveWith(self, [syncResults]);
} else {
if (currentDeferred && !currentDeferred.isResolved() && !currentDeferred.isRejected()) {
if (currentDeferred && currentDeferred.state() === "pending") {
currentDeferred.reject();
}

if (self.cachedHints.deferred &&
!self.cachedHints.deferred.isResolved() &&
!self.cachedHints.deferred.isRejected()) {
if (self.cachedHints.deferred && self.cachedHints.deferred.state() === "pending") {
self.cachedHints.deferred.reject();
self.cachedHints.deferred = null;
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/NodeConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ define(function (require, exports, module) {
setDeferredTimeout(deferred, CONNECTION_TIMEOUT);

brackets.app.getNodeState(function (err, nodePort) {
if (!err && nodePort && !deferred.isRejected()) {
if (!err && nodePort && deferred.state() !== "rejected") {
port = nodePort;
ws = new WebSocket("ws://localhost:" + port);

Expand Down
4 changes: 2 additions & 2 deletions test/perf/OpenFile-perf-files/brackets-concat.js
Original file line number Diff line number Diff line change
Expand Up @@ -20365,7 +20365,7 @@ define('LiveDevelopment/Inspector/Inspector',['require','exports','module'],func
_connectDeferred = deferred;
var promise = getAvailableSockets();
promise.done(function onGetAvailableSockets(response) {
if (deferred.isRejected()) {
if (deferred.state() === "rejected") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert changes in brackets-concat. We're trying to keep this file as-is for benchmarking over time.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jasonsanjose Do you think we should rename that file so it's more clear it shouldn't be modified? This gotcha seems to come up fairly regularly...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

brackets-concat-do-not-edit? :) You'd think being under the top level /test folder would be enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, just not always sure what needs to get changed to not break functionality (even in test environment).

return;
}
var i, page;
Expand Down Expand Up @@ -58619,7 +58619,7 @@ define('LiveDevelopment/Inspector/Inspector',['require','exports','module'],func
_connectDeferred = deferred;
var promise = getAvailableSockets();
promise.done(function onGetAvailableSockets(response) {
if (deferred.isRejected()) {
if (deferred.state() === "rejected") {
return;
}
var i, page;
Expand Down
2 changes: 1 addition & 1 deletion test/spec/LanguageManager-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ define(function (require, exports, module) {
language = lang;
});

expect(promise.isResolved()).toBeTruthy();
expect(promise.state() === "resolved").toBeTruthy();

validateLanguage(def, language);
});
Expand Down
20 changes: 9 additions & 11 deletions test/spec/NodeConnection-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ define(function (require, exports, module) {
waitsFor(
function () {
return connectDeferred &&
connectDeferred.isResolved() &&
connectDeferred.state() === "resolved" &&
connection.connected();
},
"The NodeConnection should connect",
Expand Down Expand Up @@ -93,7 +93,7 @@ define(function (require, exports, module) {
});
waitsFor(
function () {
return loadDeferred && loadDeferred.isResolved();
return loadDeferred && loadDeferred.state() === "resolved";
},
"The load should complete",
CONNECTION_TIMEOUT
Expand Down Expand Up @@ -127,15 +127,13 @@ define(function (require, exports, module) {
);
waitsFor(
function () {
return loadDeferred &&
(loadDeferred.isRejected() ||
loadDeferred.isResolved());
return loadDeferred && loadDeferred.state() !== "pending";
},
CONNECTION_TIMEOUT
);
runs(
function () {
expect(loadDeferred.isRejected()).toBe(true);
expect(loadDeferred.state() === "rejected").toBe(true);
expect(connection.connected()).toBe(true);
expect(connection._port).toBe(port);
}
Expand All @@ -157,7 +155,7 @@ define(function (require, exports, module) {
waitsFor(
function () {
return commandDeferred &&
commandDeferred.isResolved() &&
commandDeferred.state() === "resolved" &&
result;
},
CONNECTION_TIMEOUT
Expand All @@ -182,7 +180,7 @@ define(function (require, exports, module) {
waitsFor(
function () {
return commandDeferred &&
commandDeferred.isResolved() &&
commandDeferred.state() === "resolved" &&
result;
},
CONNECTION_TIMEOUT
Expand Down Expand Up @@ -230,7 +228,7 @@ define(function (require, exports, module) {
waitsFor(
function () {
return commandDeferred &&
commandDeferred.isRejected() &&
commandDeferred.state() === "rejected" &&
result;
},
CONNECTION_TIMEOUT
Expand All @@ -249,7 +247,7 @@ define(function (require, exports, module) {
waitsFor(
function () {
return commandDeferred &&
commandDeferred.isResolved() &&
commandDeferred.state() === "resolved" &&
result;
},
CONNECTION_TIMEOUT
Expand All @@ -276,7 +274,7 @@ define(function (require, exports, module) {
waitsFor(
function () {
return commandDeferred &&
commandDeferred.isResolved() &&
commandDeferred.state() === "resolved" &&
result;
},
CONNECTION_TIMEOUT
Expand Down