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

Commit 9e99101

Browse files
committed
Merge pull request #3697 from jeffslofish/Issue-3676
Changed all usages of the depreciated ".className" to ".type" that were ...
2 parents a9e2771 + 0904c5d commit 9e99101

35 files changed

Lines changed: 106 additions & 998 deletions

File tree

src/LiveDevelopment/LiveDevelopment.js

Lines changed: 13 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -42,23 +42,14 @@
4242
* # STATUS
4343
*
4444
* Status updates are dispatched as `statusChange` jQuery events. The status
45-
* is passed as the first parameter and the reason for the change as the second
46-
* parameter. Currently only the "Inactive" status supports the reason parameter.
47-
* The status codes are:
45+
* codes are:
4846
*
4947
* -1: Error
5048
* 0: Inactive
5149
* 1: Connecting to the remote debugger
5250
* 2: Loading agents
5351
* 3: Active
5452
* 4: Out of sync
55-
*
56-
* The reason codes are:
57-
* - null (Unknown reason)
58-
* - "explicit_close" (LiveDevelopment.close() was called)
59-
* - "navigated_away" (The browser changed to a location outside of the project)
60-
* - "detached_target_closed" (The tab or window was closed)
61-
* - "detached_replaced_with_devtools" (The developer tools were opened in the browser)
6253
*/
6354
define(function LiveDevelopment(require, exports, module) {
6455
"use strict";
@@ -78,6 +69,7 @@ define(function LiveDevelopment(require, exports, module) {
7869
DocumentManager = require("document/DocumentManager"),
7970
EditorManager = require("editor/EditorManager"),
8071
FileUtils = require("file/FileUtils"),
72+
HTMLInstrumentation = require("language/HTMLInstrumentation"),
8173
LiveDevServerManager = require("LiveDevelopment/LiveDevServerManager"),
8274
NativeFileError = require("file/NativeFileError"),
8375
NativeApp = require("utils/NativeApp"),
@@ -142,8 +134,7 @@ define(function LiveDevelopment(require, exports, module) {
142134
var _liveDocument; // the document open for live editing.
143135
var _relatedDocuments; // CSS and JS documents that are used by the live HTML document
144136
var _serverProvider; // current LiveDevServerProvider
145-
var _closeReason; // reason why live preview was closed
146-
137+
147138
function _isHtmlFileExt(ext) {
148139
return (FileUtils.isStaticHtmlFileExt(ext) ||
149140
(ProjectManager.getBaseUrl() && FileUtils.isServerHtmlFileExt(ext)));
@@ -461,14 +452,8 @@ define(function LiveDevelopment(require, exports, module) {
461452
* @param {integer} new status
462453
*/
463454
function _setStatus(status) {
464-
// Don't send a notification when the status didn't actually change
465-
if (status === exports.status) {
466-
return;
467-
}
468-
469455
exports.status = status;
470-
var reason = status === STATUS_INACTIVE ? _closeReason : null;
471-
$(exports).triggerHandler("statusChange", [status, reason]);
456+
$(exports).triggerHandler("statusChange", status);
472457
}
473458

474459
/** Triggered by Inspector.error */
@@ -520,6 +505,13 @@ define(function LiveDevelopment(require, exports, module) {
520505
});
521506
}
522507

508+
/** Triggered by Inspector.detached */
509+
function _onDetached(event, res) {
510+
// res.reason, e.g. "replaced_with_devtools", "target_closed", "canceled_by_user"
511+
// Sample list taken from https://chromiumcodereview.appspot.com/10947037/patch/12001/13004
512+
// However, the link refers to the Chrome Extension API, it may not apply 100% to the Inspector API
513+
}
514+
523515
// WebInspector Event: Page.frameNavigated
524516
function _onFrameNavigated(event, res) {
525517
// res = {frame}
@@ -548,7 +540,6 @@ define(function LiveDevelopment(require, exports, module) {
548540
if (!url.match(baseUrlRegExp)) {
549541
// No longer in site, so terminate live dev, but don't close browser window
550542
Inspector.disconnect();
551-
_closeReason = "navigated_away";
552543
_setStatus(STATUS_INACTIVE);
553544
_serverProvider = null;
554545
}
@@ -564,22 +555,10 @@ define(function LiveDevelopment(require, exports, module) {
564555
_setStatus(STATUS_INACTIVE);
565556
}
566557

567-
function _onDetached(event, res) {
568-
// If there already is a reason for closing the session, do not overwrite it
569-
if (!_closeReason) {
570-
// Get the explanation from res.reason, e.g. "replaced_with_devtools", "target_closed", "canceled_by_user"
571-
// Examples taken from https://chromiumcodereview.appspot.com/10947037/patch/12001/13004
572-
// However, the link refers to the Chrome Extension API, it may not apply 100% to the Inspector API
573-
// Prefix with "detached_" to create a quasi-namespace for Chrome's reasons
574-
_closeReason = "detached_" + res.reason;
575-
}
576-
}
577-
578558
function reconnect() {
579559
unloadAgents();
580-
581-
_setStatus(STATUS_LOADING_AGENTS);
582560
var promises = loadAgents();
561+
_setStatus(STATUS_LOADING_AGENTS);
583562
$.when.apply(undefined, promises).done(_onLoad).fail(_onError);
584563
}
585564

@@ -591,8 +570,6 @@ define(function LiveDevelopment(require, exports, module) {
591570
var browserStarted = false;
592571
var retryCount = 0;
593572

594-
_closeReason = null;
595-
596573
function showWrongDocError() {
597574
Dialogs.showModalDialog(
598575
Dialogs.DIALOG_ID_ERROR,
@@ -746,8 +723,6 @@ define(function LiveDevelopment(require, exports, module) {
746723
* @return {jQuery.Promise} Resolves once the connection is closed
747724
*/
748725
function close() {
749-
_closeReason = "explicit_close";
750-
751726
var deferred = $.Deferred();
752727

753728
/*
@@ -861,6 +836,7 @@ define(function LiveDevelopment(require, exports, module) {
861836
$.when.apply(undefined, promises).done(_onLoad).fail(_onError);
862837
}
863838

839+
$(Inspector.Inspector).on("detached.livedev", _onDetached);
864840
$(Inspector.Page).on("frameNavigated.livedev", _onFrameNavigated);
865841

866842
waitForInterstitialPageLoad()
@@ -985,7 +961,6 @@ define(function LiveDevelopment(require, exports, module) {
985961
$(Inspector).on("connect", _onConnect)
986962
.on("disconnect", _onDisconnect)
987963
.on("error", _onError);
988-
$(Inspector.Inspector).on("detached", _onDetached);
989964
$(DocumentManager).on("currentDocumentChange", _onDocumentChange)
990965
.on("documentSaved", _onDocumentSaved)
991966
.on("dirtyFlagChange", _onDirtyFlagChange);

src/LiveDevelopment/main.js

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ define(function main(require, exports, module) {
4848
Dialogs = require("widgets/Dialogs"),
4949
UrlParams = require("utils/UrlParams").UrlParams,
5050
Strings = require("strings"),
51-
ExtensionUtils = require("utils/ExtensionUtils"),
52-
StringUtils = require("utils/StringUtils");
51+
ExtensionUtils = require("utils/ExtensionUtils");
5352

5453
var prefs;
5554
var params = new UrlParams();
@@ -132,48 +131,17 @@ define(function main(require, exports, module) {
132131
}
133132
}
134133

135-
/** Called on status change */
136-
function _showStatusChangeReason(reason) {
137-
// Destroy the previous twipsy (options are not updated otherwise)
138-
_$btnGoLive.twipsy("hide").removeData("twipsy");
139-
140-
// If there was no reason or the action was an explicit request by the user, don't show a twipsy
141-
if (!reason || reason === "explicit_close") {
142-
return;
143-
}
144-
145-
// Translate the reason
146-
var translatedReason = Strings["LIVE_DEV_" + reason.toUpperCase()];
147-
if (!translatedReason) {
148-
translatedReason = StringUtils.format(Strings.LIVE_DEV_CLOSED_UNKNOWN_REASON, reason);
149-
}
150-
151-
// Configure the twipsy
152-
var options = {
153-
placement: "left",
154-
trigger: "manual",
155-
autoHideDelay: 5000,
156-
title: function () {
157-
return translatedReason;
158-
}
159-
};
160-
161-
// Show the twipsy with the explanation
162-
_$btnGoLive.twipsy(options).twipsy("show");
163-
}
164-
165134
/** Create the menu item "Go Live" */
166135
function _setupGoLiveButton() {
167136
_$btnGoLive = $("#toolbar-go-live");
168137
_$btnGoLive.click(function onGoLive() {
169138
_handleGoLiveCommand();
170139
});
171-
$(LiveDevelopment).on("statusChange", function statusChange(event, status, reason) {
140+
$(LiveDevelopment).on("statusChange", function statusChange(event, status) {
172141
// status starts at -1 (error), so add one when looking up name and style
173142
// See the comments at the top of LiveDevelopment.js for details on the
174143
// various status codes.
175144
_setLabel(_$btnGoLive, null, _statusStyle[status + 1], _statusTooltip[status + 1]);
176-
_showStatusChangeReason(reason);
177145
if (config.autoconnect) {
178146
window.sessionStorage.setItem("live.enabled", status === 3);
179147
}

src/brackets.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ define(function (require, exports, module) {
5353
// Load dependent non-module scripts
5454
require("widgets/bootstrap-dropdown");
5555
require("widgets/bootstrap-modal");
56-
require("widgets/bootstrap-twipsy-mod");
5756
require("thirdparty/path-utils/path-utils.min");
5857
require("thirdparty/smart-auto-complete/jquery.smart_autocomplete");
5958

src/command/Menus.js

Lines changed: 22 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -91,32 +91,23 @@ define(function (require, exports, module) {
9191

9292

9393
/**
94-
* Insertion position constants
95-
* Used by addMenu(), addMenuItem(), and addSubMenu() to
96-
* specify the relative position of a newly created menu object
97-
* @enum {string}
98-
*/
99-
var BEFORE = "before",
100-
AFTER = "after",
101-
FIRST = "first",
102-
LAST = "last",
103-
FIRST_IN_SECTION = "firstInSection",
104-
LAST_IN_SECTION = "lastInSection";
105-
106-
/**
107-
* Other constants
108-
*/
94+
* Insertion position constants
95+
* Used by addMenu(), addMenuItem(), and addSubMenu() to
96+
* specify the relative position of a newly created menu object
97+
* @enum {string}
98+
*/
99+
var BEFORE = "before";
100+
var AFTER = "after";
101+
var FIRST = "first";
102+
var LAST = "last";
103+
var FIRST_IN_SECTION = "firstInSection";
104+
var LAST_IN_SECTION = "lastInSection";
105+
106+
/**
107+
* Other constants
108+
*/
109109
var DIVIDER = "---";
110-
111-
/**
112-
* Error Codes from Brackets Shell
113-
* @enum {number}
114-
*/
115-
var NO_ERROR = 0,
116-
ERR_UNKNOWN = 1,
117-
ERR_INVALID_PARAMS = 2,
118-
ERR_NOT_FOUND = 3;
119-
110+
120111
/**
121112
* Maps menuID's to Menu objects
122113
* @type {Object.<string, Menu>}
@@ -471,8 +462,7 @@ define(function (require, exports, module) {
471462
* @return {MenuItem} the newly created MenuItem
472463
*/
473464
Menu.prototype.addMenuItem = function (command, keyBindings, position, relativeID) {
474-
var menuID = this.id,
475-
id,
465+
var id,
476466
$menuItem,
477467
$link,
478468
menuItem,
@@ -557,17 +547,8 @@ define(function (require, exports, module) {
557547
}
558548

559549
brackets.app.addMenuItem(this.id, name, commandID, bindingStr, displayStr, position, relativeID, function (err) {
560-
switch (err) {
561-
case NO_ERROR:
562-
break;
563-
case ERR_INVALID_PARAMS:
564-
console.error("addMenuItem(): Invalid Parameters when adding the command " + commandID);
565-
break;
566-
case ERR_NOT_FOUND:
567-
console.error("_getRelativeMenuItem(): MenuItem with Command id " + relativeID + " not found in the Menu " + menuID);
568-
break;
569-
default:
570-
console.error("addMenuItem(); Unknown Error (" + err + ") when adding the command " + commandID);
550+
if (err) {
551+
console.error("addMenuItem() -- error: " + err + " when adding command: " + commandID);
571552
}
572553
});
573554
menuItem.isNative = true;
@@ -819,26 +800,15 @@ define(function (require, exports, module) {
819800

820801
if (!_isHTMLMenu(id)) {
821802
brackets.app.addMenu(name, id, position, relativeID, function (err) {
822-
switch (err) {
823-
case NO_ERROR:
803+
if (err) {
804+
console.error("addMenu() -- error: " + err + " when adding menu with ID: " + id);
805+
} else {
824806
// Make sure name is up to date
825807
brackets.app.setMenuTitle(id, name, function (err) {
826808
if (err) {
827809
console.error("setMenuTitle() -- error: " + err);
828810
}
829811
});
830-
break;
831-
case ERR_UNKNOWN:
832-
console.error("addMenu(): Unknown Error when adding the menu " + id);
833-
break;
834-
case ERR_INVALID_PARAMS:
835-
console.error("addMenu(): Invalid Parameters when adding the menu " + id);
836-
break;
837-
case ERR_NOT_FOUND:
838-
console.error("addMenu(): Menu with command " + relativeID + " could not be found when adding the menu " + id);
839-
break;
840-
default:
841-
console.error("addMenu(): Unknown Error (" + err + ") when adding the menu " + id);
842812
}
843813
});
844814
return menu;

src/document/DocumentManager.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -814,14 +814,6 @@ define(function (require, exports, module) {
814814
* given new text; if text == "", then the entire range is effectively deleted. If 'end' is omitted,
815815
* then the new text is inserted at that point and all existing text is preserved. Line endings will
816816
* be rewritten to match the document's current line-ending style.
817-
*
818-
* IMPORTANT NOTE: Because of #1688, do not use this in cases where you might be
819-
* operating on a linked document (like the main document for an inline editor)
820-
* during an outer CodeMirror operation (like a key event that's handled by the
821-
* editor itself). A common case of this is code hints in inline editors. In
822-
* such cases, use `editor._codeMirror.replaceRange()` instead. This should be
823-
* fixed when we migrate to use CodeMirror's native document-linking functionality.
824-
*
825817
* @param {!string} text Text to insert or replace the range with
826818
* @param {!{line:number, ch:number}} start Start of range, inclusive (if 'to' specified) or insertion point (if not)
827819
* @param {?{line:number, ch:number}} end End of range, exclusive; optional

src/editor/EditorCommandHandlers.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ define(function (require, exports, module) {
284284
var result, text, line;
285285

286286
// Move the context to the first non-empty token.
287-
if (!ctx.token.className && ctx.token.string.trim().length === 0) {
287+
if (!ctx.token.type && ctx.token.string.trim().length === 0) {
288288
result = TokenUtils.moveSkippingWhitespace(TokenUtils.moveNextToken, ctx);
289289
}
290290

@@ -300,7 +300,7 @@ define(function (require, exports, module) {
300300
}
301301

302302
// If we aren't in a block-comment.
303-
if (!result || ctx.token.className !== "comment" || ctx.token.string.match(suffixExp)) {
303+
if (!result || ctx.token.type !== "comment" || ctx.token.string.match(suffixExp)) {
304304
// Is a range of text selected? (vs just an insertion pt)
305305
var hasSelection = (sel.start.line !== sel.end.line) || (sel.start.ch !== sel.end.ch);
306306

@@ -325,12 +325,12 @@ define(function (require, exports, module) {
325325

326326
// If we are in a selection starting and ending in invalid tokens and with no content (not considering spaces),
327327
// find if we are inside a block-comment.
328-
} else if (startCtx.token.className === null && endCtx.token.className === null &&
328+
} else if (startCtx.token.type === null && endCtx.token.type === null &&
329329
!editor.posWithinRange(ctx.pos, startCtx.pos, endCtx.pos, true)) {
330330
result = TokenUtils.moveSkippingWhitespace(TokenUtils.moveNextToken, startCtx);
331331

332332
// We found a comment, find the start and end and check if the selection is inside the block-comment.
333-
if (startCtx.token.className === "comment") {
333+
if (startCtx.token.type === "comment") {
334334
prefixPos = _findCommentStart(startCtx, prefixExp);
335335
suffixPos = _findCommentEnd(startCtx, suffixExp, suffix.length);
336336

@@ -342,7 +342,7 @@ define(function (require, exports, module) {
342342
}
343343

344344
// If the start is inside a comment, find the prefix and suffix positions.
345-
} else if (ctx.token.className === "comment") {
345+
} else if (ctx.token.type === "comment") {
346346
prefixPos = _findCommentStart(ctx, prefixExp);
347347
suffixPos = _findCommentEnd(ctx, suffixExp, suffix.length);
348348

@@ -489,7 +489,7 @@ define(function (require, exports, module) {
489489
// If the selection includes a comment or is already a line selection, delegate to Block-Comment
490490
var ctx = TokenUtils.getInitialContext(editor._codeMirror, {line: selStart.line, ch: selStart.ch});
491491
var result = TokenUtils.moveSkippingWhitespace(TokenUtils.moveNextToken, ctx);
492-
var className = ctx.token.className;
492+
var className = ctx.token.type;
493493
result = result && _findNextBlockComment(ctx, selEnd, prefixExp);
494494

495495
if (className === "comment" || result || isLineSelection) {

src/extensions/default/HTMLCodeHints/unittests.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,6 @@ define(function (require, exports, module) {
153153
hintList = expectHints(HTMLCodeHints.tagHintProvider);
154154
verifyTagHints(hintList);
155155
});
156-
157-
//Test for issue #3339
158-
it("should show HTML hints after HTML Entity on same line", function () {
159-
testDocument.replaceRange("&nbsp; Test < ", { line: 8, ch: 0 });
160-
testEditor.setCursorPos({ line: 8, ch: 13 }); // cursor between < and some trailing whitespaces
161-
var hintList = expectHints(HTMLCodeHints.tagHintProvider);
162-
verifyTagHints(hintList);
163-
});
164156
});
165157

166158
describe("Attribute name hint provider", function () {

0 commit comments

Comments
 (0)