Merge branch 'master' into html-hint-bug

Conflicts:
	src/extensions/default/JavaScriptCodeHints/ScopeManager.js
This commit is contained in:
Erik Tierney committed 2013-05-14 11:09:51 -04:00
commit a637bd0575
84 files changed
+2397 -1516

No files matched your search

@@ -232,7 +232,7 @@ define(function (require, exports, module) {
* @param {function(Array.<string>)} successCallback - callback with
* array of file path names.
*/
function getFilesInDirectory(dir, successCallback) {
function getFilesInDirectory(dir, successCallback, errorCallback) {
var files = []; // file names without paths.
/**
@@ -250,8 +250,7 @@ define(function (require, exports, module) {
function fileCallback(path) {
files.push(path);
}
forEachFileInDirectory(dir, doneCallback, fileCallback);
forEachFileInDirectory(dir, doneCallback, fileCallback, null, errorCallback);
}
/**
@@ -716,14 +715,13 @@ define(function (require, exports, module) {
}
/**
* Called each time a new editor becomes active. Refreshes the outer scopes
* of the given file as well as of the other files in the given directory.
* Do the work to initialize a code hinting session.
*
* @param {Session} session - the active hinting session
* @param {Document} document - the document of the editor that has changed
* @param {boolean} shouldPrimePump - true if the pump should be primed.
*/
function handleEditorChange(session, document, shouldPrimePump) {
function doEditorChange(session, document, shouldPrimePump) {
var path = document.file.fullPath,
split = HintUtils.splitPath(path),
dir = split.dir,
@@ -782,9 +780,28 @@ define(function (require, exports, module) {
addFilesDeferred.resolveWith(null, [_ternWorker]);
}
}, function () {
addFilesDeferred.resolveWith(null);
});
}
/**
* Called each time a new editor becomes active.
*
* @param {Session} session - the active hinting session
* @param {Document} document - the document of the editor that has changed
* @param {boolean} shouldPrimePump - true if the pump should be primed.
*/
function handleEditorChange(session, document, shouldPrimePump) {
if (addFilesPromise === null) {
doEditorChange(session, document, shouldPrimePump);
} else {
addFilesPromise.done(function () {
doEditorChange(session, document, shouldPrimePump);
});
}
}
_ternWorker.addEventListener("message", function (e) {
var response = e.data,
type = response.type;
@@ -27,7 +27,9 @@
define(function (require, exports, module) {
"use strict";
var Editor = brackets.getModule("editor/Editor").Editor,
var Commands = brackets.getModule("command/Commands"),
CommandManager = brackets.getModule("command/CommandManager"),
Editor = brackets.getModule("editor/Editor").Editor,
EditorManager = brackets.getModule("editor/EditorManager"),
FileUtils = brackets.getModule("file/FileUtils"),
DocumentManager = brackets.getModule("document/DocumentManager"),
@@ -41,6 +43,12 @@ define(function (require, exports, module) {
testDoc = null,
testEditor;
CommandManager.register("test-file-open", Commands.FILE_OPEN, function (fileInfo) {
// Register a command for FILE_OPEN, which the jump to def code will call
return DocumentManager.getDocumentForPath(fileInfo.fullPath).done(function (doc) {
DocumentManager.setCurrentDocument(doc);
});
});
/**
* Returns an Editor suitable for use in isolation, given a Document. (Unlike
* SpecRunnerUtils.createMockEditor(), which is given text and creates the Document
@@ -58,6 +66,8 @@ define(function (require, exports, module) {
// create Editor instance
var editor = new Editor(doc, true, $editorHolder.get(0));
EditorManager._notifyActiveEditorChanged(editor);
return editor;
}
@@ -289,21 +299,24 @@ define(function (require, exports, module) {
* @param {Function} callback - the callback to apply once the editor has changed position
*/
function _waitForJump(oldLocation, callback) {
var cursor = null;
waitsFor(function () {
var cursor = testEditor.getCursorPos();
var activeEditor = EditorManager.getActiveEditor();
cursor = activeEditor.getCursorPos();
return (cursor.line !== oldLocation.line) ||
(cursor.ch !== oldLocation.ch);
}, "Expected jump did not occur", 3000);
runs(function () { callback(testEditor.getCursorPos()); });
runs(function () { callback(cursor); });
}
/**
* Trigger a jump to definition, and verify that the editor jumped to
* the expected location.
*
* @param {{line:number, ch:number}} expectedLocation - the location the editor should
* jump to.
* @param {{line:number, ch:number, file:string}} expectedLocation - the
* line, column, and optionally the new file the editor should jump to. If the
* editor is expected to stay in the same file, then file may be omitted.
*/
function editorJumped(expectedLocation) {
var oldLocation = testEditor.getCursorPos();
@@ -314,6 +327,10 @@ define(function (require, exports, module) {
_waitForJump(oldLocation, function (newCursor) {
expect(newCursor.line).toBe(expectedLocation.line);
expect(newCursor.ch).toBe(expectedLocation.ch);
if (expectedLocation.file) {
var activeEditor = EditorManager.getActiveEditor();
expect(activeEditor.document.file.name).toBe(expectedLocation.file);
}
});
}
@@ -980,13 +997,12 @@ define(function (require, exports, module) {
});
});
// bug: the issue: timeout due to file.open command not found
xit("should jump to the definition in new module file", function () {
var start = { line: 38, ch: 21 };
it("should jump to the definition in new module file", function () {
var start = { line: 40, ch: 22 };
testEditor.setCursorPos(start);
runs(function () {
editorJumped({line: 4, ch: 34}); //jump to another file
editorJumped({line: 4, ch: 34, file: "MyModule.js"}); //jump to another file
});
});