mirror of
https://github.com/RustyRaptor/brackets.git
synced 2026-12-04 00:15:22 -07:00
Initial integration into core.
This commit is contained in:
1 parent
8a56ceeb91
commit
045f34654b
51 files changed
+798
-720
No files matched your search
@@ -36,12 +36,11 @@ define(function (require, exports, module) {
|
||||
|
||||
var DocumentManager = brackets.getModule("document/DocumentManager"),
|
||||
LanguageManager = brackets.getModule("language/LanguageManager"),
|
||||
NativeFileSystem = brackets.getModule("file/NativeFileSystem").NativeFileSystem,
|
||||
FileSystem = brackets.getModule("filesystem/FileSystem"),
|
||||
ProjectManager = brackets.getModule("project/ProjectManager"),
|
||||
CollectionUtils = brackets.getModule("utils/CollectionUtils"),
|
||||
ExtensionUtils = brackets.getModule("utils/ExtensionUtils"),
|
||||
FileUtils = brackets.getModule("file/FileUtils"),
|
||||
FileIndexManager = brackets.getModule("project/FileIndexManager"),
|
||||
HintUtils = require("HintUtils"),
|
||||
MessageIds = require("MessageIds"),
|
||||
Preferences = require("Preferences");
|
||||
@@ -80,15 +79,11 @@ define(function (require, exports, module) {
|
||||
library;
|
||||
|
||||
files.forEach(function (i) {
|
||||
NativeFileSystem.resolveNativeFileSystemPath(path + i, function (fileEntry) {
|
||||
FileUtils.readAsText(fileEntry).done(function (text) {
|
||||
library = JSON.parse(text);
|
||||
builtinLibraryNames.push(library["!name"]);
|
||||
ternEnvironment.push(library);
|
||||
}).fail(function (error) {
|
||||
console.log("failed to read tern config file " + i);
|
||||
});
|
||||
}, function (error) {
|
||||
FileUtils.readAsText(path + i).done(function (text) {
|
||||
library = JSON.parse(text);
|
||||
builtinLibraryNames.push(library["!name"]);
|
||||
ternEnvironment.push(library);
|
||||
}).fail(function (error) {
|
||||
console.log("failed to read tern config file " + i);
|
||||
});
|
||||
});
|
||||
@@ -117,33 +112,28 @@ define(function (require, exports, module) {
|
||||
// Normally there is a project root, but for unit tests we need to
|
||||
// pass in a project root.
|
||||
if (pr) {
|
||||
projectRootPath = pr.fullPath;
|
||||
projectRootPath = pr.getPath();
|
||||
} else if (!projectRootPath) {
|
||||
console.log("initPreferences: projectRootPath has no value");
|
||||
}
|
||||
|
||||
var path = projectRootPath + Preferences.FILE_NAME;
|
||||
|
||||
NativeFileSystem.resolveNativeFileSystemPath(path, function (fileEntry) {
|
||||
FileUtils.readAsText(fileEntry).done(function (text) {
|
||||
var configObj = null;
|
||||
try {
|
||||
configObj = JSON.parse(text);
|
||||
} catch (e) {
|
||||
// continue with null configObj which will result in
|
||||
// default settings.
|
||||
console.log("Error parsing preference file: " + path);
|
||||
if (e instanceof SyntaxError) {
|
||||
console.log(e.message);
|
||||
}
|
||||
FileUtils.readAsText(path).done(function (text) {
|
||||
var configObj = null;
|
||||
try {
|
||||
configObj = JSON.parse(text);
|
||||
} catch (e) {
|
||||
// continue with null configObj which will result in
|
||||
// default settings.
|
||||
console.log("Error parsing preference file: " + path);
|
||||
if (e instanceof SyntaxError) {
|
||||
console.log(e.message);
|
||||
}
|
||||
preferences = new Preferences(configObj);
|
||||
deferredPreferences.resolve();
|
||||
}).fail(function (error) {
|
||||
preferences = new Preferences();
|
||||
deferredPreferences.resolve();
|
||||
});
|
||||
}, function (error) {
|
||||
}
|
||||
preferences = new Preferences(configObj);
|
||||
deferredPreferences.resolve();
|
||||
}).fail(function (error) {
|
||||
preferences = new Preferences();
|
||||
deferredPreferences.resolve();
|
||||
});
|
||||
@@ -183,18 +173,17 @@ define(function (require, exports, module) {
|
||||
* @param {!function(string)=} errorCallback - Callback for errors (optional).
|
||||
*/
|
||||
function forEachFileInDirectory(dir, doneCallback, fileCallback, directoryCallback, errorCallback) {
|
||||
var files = [];
|
||||
var directory = FileSystem.getDirectoryForPath(dir),
|
||||
files = [];
|
||||
|
||||
NativeFileSystem.resolveNativeFileSystemPath(dir, function (dirEntry) {
|
||||
var reader = dirEntry.createReader();
|
||||
|
||||
reader.readEntries(function (entries) {
|
||||
entries.slice(0, preferences.getMaxFileCount()).forEach(function (entry) {
|
||||
var path = entry.fullPath,
|
||||
FileSystem.getDirectoryContents(directory)
|
||||
.done(function (contents) {
|
||||
contents.slice(0, preferences.getMaxFileCount()).forEach(function (entry) {
|
||||
var path = entry.getPath(),
|
||||
split = HintUtils.splitPath(path),
|
||||
file = split.file;
|
||||
|
||||
if (fileCallback && entry.isFile) {
|
||||
if (fileCallback && entry.isFile()) {
|
||||
|
||||
if (file.indexOf(".") > 0) { // ignore .dotfiles
|
||||
var languageID = LanguageManager.getLanguageForPath(path).getId();
|
||||
@@ -202,26 +191,21 @@ define(function (require, exports, module) {
|
||||
fileCallback(path);
|
||||
}
|
||||
}
|
||||
} else if (directoryCallback && entry.isDirectory) {
|
||||
} else if (directoryCallback && entry.isDirectory()) {
|
||||
var dirName = HintUtils.splitPath(split.dir).file;
|
||||
if (dirName.indexOf(".") !== 0) { // ignore .dotfiles
|
||||
directoryCallback(entry.fullPath);
|
||||
directoryCallback(entry.getPath());
|
||||
}
|
||||
}
|
||||
});
|
||||
doneCallback();
|
||||
}, function (err) {
|
||||
})
|
||||
.fail(function (err) {
|
||||
if (errorCallback) {
|
||||
errorCallback(err);
|
||||
}
|
||||
console.log("Unable to refresh directory: " + err);
|
||||
console.log("Directory \"%s\" does not exist", dir);
|
||||
});
|
||||
}, function (err) {
|
||||
if (errorCallback) {
|
||||
errorCallback(err);
|
||||
}
|
||||
console.log("Directory \"%s\" does not exist", dir);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -410,7 +394,7 @@ define(function (require, exports, module) {
|
||||
* has completed.
|
||||
*/
|
||||
function requestJumptoDef(session, document, offset) {
|
||||
var path = document.file.fullPath,
|
||||
var path = document.file.getPath(),
|
||||
fileInfo = {type: MessageIds.TERN_FILE_INFO_TYPE_FULL,
|
||||
name: path,
|
||||
offsetLines: 0,
|
||||
@@ -554,7 +538,7 @@ define(function (require, exports, module) {
|
||||
to = {line: endLine, ch: endCh};
|
||||
|
||||
return {type: MessageIds.TERN_FILE_INFO_TYPE_PART,
|
||||
name: document.file.fullPath,
|
||||
name: document.file.getPath(),
|
||||
offsetLines: from.line,
|
||||
text: document.getRange(from, to)};
|
||||
}
|
||||
@@ -572,7 +556,7 @@ define(function (require, exports, module) {
|
||||
var start = session.getCursor(),
|
||||
end = start,
|
||||
document = session.editor.document,
|
||||
path = document.file.fullPath,
|
||||
path = document.file.getPath(),
|
||||
isHtmlFile = LanguageManager.getLanguageForPath(path).getId() === "html",
|
||||
result;
|
||||
|
||||
@@ -782,7 +766,7 @@ define(function (require, exports, module) {
|
||||
* @return {jQuery.Promise} - the promise for the request
|
||||
*/
|
||||
function updateTernFile(document) {
|
||||
var path = document.file.fullPath;
|
||||
var path = document.file.getPath();
|
||||
|
||||
_postMessageByPass({
|
||||
type : MessageIds.TERN_UPDATE_FILE_MSG,
|
||||
@@ -838,29 +822,28 @@ define(function (require, exports, module) {
|
||||
function findNameInProject() {
|
||||
// check for any files in project that end with the right path.
|
||||
var fileName = HintUtils.splitPath(name).file;
|
||||
FileIndexManager.getFilenameMatches("all", fileName)
|
||||
.done(function (files) {
|
||||
var file;
|
||||
files = files.filter(function (file) {
|
||||
var pos = file.fullPath.length - name.length;
|
||||
return pos === file.fullPath.lastIndexOf(name);
|
||||
});
|
||||
|
||||
if (files.length === 1) {
|
||||
file = files[0];
|
||||
}
|
||||
if (file) {
|
||||
getDocText(file.fullPath).fail(function () {
|
||||
replyWith(name, "");
|
||||
});
|
||||
} else {
|
||||
replyWith(name, "");
|
||||
}
|
||||
|
||||
})
|
||||
.fail(function () {
|
||||
|
||||
var files = FileSystem.getFileList(function (file) {
|
||||
return file.getName() === fileName;
|
||||
});
|
||||
|
||||
var file;
|
||||
files = files.filter(function (file) {
|
||||
var pos = file.getPath().length - name.length;
|
||||
return pos === file.getPath().lastIndexOf(name);
|
||||
});
|
||||
|
||||
if (files.length === 1) {
|
||||
file = files[0];
|
||||
}
|
||||
if (file) {
|
||||
getDocText(file.getPath()).fail(function () {
|
||||
replyWith(name, "");
|
||||
});
|
||||
} else {
|
||||
replyWith(name, "");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
getDocText(name).fail(function () {
|
||||
@@ -1104,7 +1087,7 @@ define(function (require, exports, module) {
|
||||
* @param {Document} previousDocument - the document the editor has changed from
|
||||
*/
|
||||
function doEditorChange(session, document, previousDocument) {
|
||||
var path = document.file.fullPath,
|
||||
var path = document.file.getPath(),
|
||||
split = HintUtils.splitPath(path),
|
||||
dir = split.dir,
|
||||
files = [],
|
||||
@@ -1115,7 +1098,7 @@ define(function (require, exports, module) {
|
||||
|
||||
documentChanges = null;
|
||||
addFilesPromise = addFilesDeferred.promise();
|
||||
pr = ProjectManager.getProjectRoot() ? ProjectManager.getProjectRoot().fullPath : null;
|
||||
pr = ProjectManager.getProjectRoot() ? ProjectManager.getProjectRoot().getPath() : null;
|
||||
|
||||
// avoid re-initializing tern if possible.
|
||||
if (canSkipTernInitialization(path)) {
|
||||
|
||||
@@ -43,7 +43,7 @@ define(function (require, exports, module) {
|
||||
*/
|
||||
function Session(editor) {
|
||||
this.editor = editor;
|
||||
this.path = editor.document.file.fullPath;
|
||||
this.path = editor.document.file.getPath();
|
||||
this.ternHints = [];
|
||||
this.ternGuesses = null;
|
||||
this.fnType = null;
|
||||
@@ -593,7 +593,7 @@ define(function (require, exports, module) {
|
||||
* @return {string} - the "javascript" text that can be sent to Tern.
|
||||
*/
|
||||
Session.prototype.getJavascriptText = function () {
|
||||
if (LanguageManager.getLanguageForPath(this.editor.document.file.fullPath).getId() === "html") {
|
||||
if (LanguageManager.getLanguageForPath(this.editor.document.file.getPath()).getId() === "html") {
|
||||
// HTML file - need to send back only the bodies of the
|
||||
// <script> tags
|
||||
var text = "",
|
||||
|
||||
@@ -272,7 +272,7 @@ define(function (require, exports, module) {
|
||||
* @return {boolean} - true if the document is a html file
|
||||
*/
|
||||
function isHTMLFile(document) {
|
||||
var languageID = LanguageManager.getLanguageForPath(document.file.fullPath).getId();
|
||||
var languageID = LanguageManager.getLanguageForPath(document.file.getPath()).getId();
|
||||
return languageID === "html";
|
||||
}
|
||||
|
||||
@@ -547,7 +547,7 @@ define(function (require, exports, module) {
|
||||
// always clean up cached scope and hint info
|
||||
resetCachedHintContext();
|
||||
|
||||
if (editor && HintUtils.isSupportedLanguage(LanguageManager.getLanguageForPath(editor.document.file.fullPath).getId())) {
|
||||
if (editor && HintUtils.isSupportedLanguage(LanguageManager.getLanguageForPath(editor.document.file.getPath()).getId())) {
|
||||
initializeSession(editor, previousEditor);
|
||||
$(editor)
|
||||
.on(HintUtils.eventName("change"), function (event, editor, changeList) {
|
||||
|
||||
@@ -33,7 +33,6 @@ define(function (require, exports, module) {
|
||||
Editor = brackets.getModule("editor/Editor").Editor,
|
||||
EditorManager = brackets.getModule("editor/EditorManager"),
|
||||
FileUtils = brackets.getModule("file/FileUtils"),
|
||||
NativeFileSystem = brackets.getModule("file/NativeFileSystem").NativeFileSystem,
|
||||
SpecRunnerUtils = brackets.getModule("spec/SpecRunnerUtils"),
|
||||
UnitTestReporter = brackets.getModule("test/UnitTestReporter"),
|
||||
JSCodeHints = require("main"),
|
||||
@@ -50,7 +49,7 @@ define(function (require, exports, module) {
|
||||
|
||||
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) {
|
||||
return DocumentManager.getDocumentForPath(fileInfo.getPath()).done(function (doc) {
|
||||
DocumentManager.setCurrentDocument(doc);
|
||||
});
|
||||
});
|
||||
@@ -332,7 +331,7 @@ define(function (require, exports, module) {
|
||||
expect(newCursor.ch).toBe(expectedLocation.ch);
|
||||
if (expectedLocation.file) {
|
||||
var activeEditor = EditorManager.getActiveEditor();
|
||||
expect(activeEditor.document.file.name).toBe(expectedLocation.file);
|
||||
expect(activeEditor.document.file.getName()).toBe(expectedLocation.file);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1373,23 +1372,18 @@ define(function (require, exports, module) {
|
||||
function getPreferences(path) {
|
||||
preferences = null;
|
||||
|
||||
NativeFileSystem.resolveNativeFileSystemPath(path, function (fileEntry) {
|
||||
FileUtils.readAsText(fileEntry).done(function (text) {
|
||||
var configObj = null;
|
||||
try {
|
||||
configObj = JSON.parse(text);
|
||||
} catch (e) {
|
||||
// continue with null configObj
|
||||
console.log(e);
|
||||
}
|
||||
preferences = new Preferences(configObj);
|
||||
}).fail(function (error) {
|
||||
preferences = new Preferences();
|
||||
});
|
||||
}, function (error) {
|
||||
FileUtils.readAsText(path).done(function (text) {
|
||||
var configObj = null;
|
||||
try {
|
||||
configObj = JSON.parse(text);
|
||||
} catch (e) {
|
||||
// continue with null configObj
|
||||
console.log(e);
|
||||
}
|
||||
preferences = new Preferences(configObj);
|
||||
}).fail(function (error) {
|
||||
preferences = new Preferences();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// Test preferences file with no entries. Preferences should contain
|
||||
|
||||
Reference in new issue
Block a user