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

Commit 23a3e91

Browse files
committed
Code review fixes:
* Use .hasClass() instead of .is() where possible * More succinct math operators in DropdownEventHandler._tryToSelect() * Document language-change events * Improve some more JS code hints docs
1 parent 6e6c618 commit 23a3e91

File tree

5 files changed

+20
-10
lines changed

5 files changed

+20
-10
lines changed

src/document/Document.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ define(function (require, exports, module) {
6565
*
6666
* __deleted__ -- When the file for this document has been deleted. All views onto the document should
6767
* be closed. The document will no longer be editable or dispatch "change" events.
68+
*
69+
* __languageChanged__ -- When the value of getLanguage() has changed. 2nd argument is the old value,
70+
* 3rd argument is the new value.
6871
*
6972
* @constructor
7073
* @param {!File} file Need not lie within the project.

src/extensions/default/JavaScriptCodeHints/ScopeManager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1137,7 +1137,7 @@ define(function (require, exports, module) {
11371137
* Called each time a new editor becomes active.
11381138
*
11391139
* @param {Session} session - the active hinting session
1140-
* @param {Document} document - the document of the editor that has changed
1140+
* @param {!Document} document - the document of the editor that has changed
11411141
* @param {?Document} previousDocument - the document of the editor is changing from
11421142
*/
11431143
function handleEditorChange(session, document, previousDocument) {

src/extensions/default/JavaScriptCodeHints/main.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ define(function (require, exports, module) {
563563
* When the editor is changed, reset the hinting session and cached
564564
* information, and reject any pending deferred requests.
565565
*
566-
* @param {Editor} editor - editor context to be initialized.
566+
* @param {!Editor} editor - editor context to be initialized.
567567
* @param {?Editor} previousEditor - the previous editor.
568568
*/
569569
function initializeSession(editor, previousEditor) {
@@ -575,10 +575,10 @@ define(function (require, exports, module) {
575575
}
576576

577577
/*
578-
* Install editor change listeners
578+
* Connects to the given editor, creating a new Session & adding listeners
579579
*
580-
* @param {Editor} editor - editor context on which to listen for
581-
* changes
580+
* @param {?Editor} editor - editor context on which to listen for
581+
* changes. If null, 'session' is cleared.
582582
* @param {?Editor} previousEditor - the previous editor
583583
*/
584584
function installEditorListeners(editor, previousEditor) {

src/language/LanguageManager.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@
120120
* isBinary: true
121121
* });
122122
*
123+
*
124+
* LanguageManager dispatches two events:
125+
*
126+
* - languageAdded -- When any new Language is added. 2nd arg is the new Language.
127+
* - languageModified -- When the attributes of a Language change, or when the Language gains or loses
128+
* file extension / filename mappings. 2nd arg is the modified Language.
123129
*/
124130
define(function (require, exports, module) {
125131
"use strict";

src/utils/DropdownEventHandler.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ define(function (require, exports, module) {
171171
* @param {boolean=} noWrap Clip out of range index values instead of wrapping. Default false (wrap).
172172
*/
173173
DropdownEventHandler.prototype._tryToSelect = function (index, direction, noWrap) {
174-
// Wrap around if index out of bounds (>= len or < 0)
174+
// Fix up 'index' if out of bounds (>= len or < 0)
175175
var len = this.$items.length;
176176
if (noWrap) {
177177
// Clip to stay in range (and set direction so we don't wrap in the recursion case either)
@@ -183,9 +183,10 @@ define(function (require, exports, module) {
183183
direction = -1;
184184
}
185185
} else {
186-
index = index % len;
186+
// Wrap around to keep index in bounds
187+
index %= len;
187188
if (index < 0) {
188-
index = len + index;
189+
index += len;
189190
}
190191
}
191192

@@ -240,7 +241,7 @@ define(function (require, exports, module) {
240241
if (!this.selectionCallback || !this.$list || !$link) {
241242
return;
242243
}
243-
if ($link.is(".disabled")) {
244+
if ($link.hasClass("disabled")) {
244245
return;
245246
}
246247

@@ -296,7 +297,7 @@ define(function (require, exports, module) {
296297

297298
// Only set selected if enabled & in view
298299
// (dividers are already screened out since they don't have an "a" tag in them)
299-
if (!$link.is(".disabled")) {
300+
if (!$link.hasClass("disabled")) {
300301
if (elementOffset.top < viewOffset.top + self.$list.height() && viewOffset.top <= elementOffset.top) {
301302
self._setSelectedIndex(self.$items.index($item), false);
302303
}

0 commit comments

Comments
 (0)