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

Commit 5a026ec

Browse files
committed
Update JS code hints (including unit tests) to work with new language and
Editor APIs.
1 parent bebb6cf commit 5a026ec

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

src/extensions/default/JavaScriptCodeHints/ScopeManager.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ define(function (require, exports, module) {
3535
"use strict";
3636

3737
var DocumentManager = brackets.getModule("document/DocumentManager"),
38-
EditorUtils = brackets.getModule("editor/EditorUtils"),
38+
LanguageManager = brackets.getModule("language/LanguageManager"),
3939
FileUtils = brackets.getModule("file/FileUtils"),
4040
NativeFileSystem = brackets.getModule("file/NativeFileSystem").NativeFileSystem,
4141
ProjectManager = brackets.getModule("project/ProjectManager"),
@@ -440,7 +440,7 @@ define(function (require, exports, module) {
440440
file = split.file;
441441

442442
if (file.indexOf(".") > 1) { // ignore /.dotfiles
443-
var mode = EditorUtils.getModeFromFileExtension(entry.fullPath);
443+
var mode = LanguageManager.getLanguageForFileExtension(entry.fullPath).mode;
444444
if (mode === HintUtils.MODE_NAME) {
445445
DocumentManager.getDocumentForPath(path).done(function (document) {
446446
refreshOuterScope(dir, file, document.getText());

src/extensions/default/JavaScriptCodeHints/unittests.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,24 +41,22 @@ define(function (require, exports, module) {
4141
testEditor;
4242

4343
/**
44-
* Returns an Editor suitable for use in isolation: i.e., a Document that
45-
* will never be set as the currentDocument or added to the working set.
44+
* Returns an Editor suitable for use in isolation, given a Document. (Unlike
45+
* SpecRunnerUtils.createMockEditor(), which is given text and creates the Document
46+
* for you).
4647
*
4748
* @param {Document} doc - the document to be contained by the new Editor
48-
* @param {string} mode - the CodeMirror mode of the new Editor
4949
* @return {Editor} - the mock editor object
5050
*/
51-
function createMockEditor(doc, mode) {
52-
mode = mode || "";
53-
51+
function createMockEditor(doc) {
5452
// Initialize EditorManager
5553
var $editorHolder = $("<div id='mock-editor-holder'/>");
5654
EditorManager.setEditorHolder($editorHolder);
5755
EditorManager._init();
5856
$("body").append($editorHolder);
5957

6058
// create Editor instance
61-
var editor = new Editor(doc, true, mode, $editorHolder.get(0));
59+
var editor = new Editor(doc, true, $editorHolder.get(0));
6260

6361
return editor;
6462
}
@@ -263,7 +261,7 @@ define(function (require, exports, module) {
263261

264262
// create Editor instance (containing a CodeMirror instance)
265263
runs(function () {
266-
testEditor = createMockEditor(testDoc, "javascript");
264+
testEditor = createMockEditor(testDoc);
267265
JSCodeHints.initializeSession(testEditor);
268266
});
269267
});

0 commit comments

Comments
 (0)