Narciso (NJ) Jaramillo
@notwebsafe
Or whatever you want!
tools/setup_for_hacking.sh "/Applications/Brackets Sprint 14.app"
tools\setup_for_hacking.bat "C:\Program Files (x86)\Brackets Sprint 14"
~/Library/Application Support/Brackets
{USER}\AppData\Roaming\Brackets
tools/restore_installed_build.sh "/Applications/Brackets Sprint 14.app"
tools\restore_installed_build.bat "C:\Program Files (x86)\Brackets Sprint 14"
describe("PreferenceStorage", function () {
it("should read initial preferences from JSON", function () {
var store = new PreferenceStorage(CLIENT_ID,
{"foo": "bar", hello: "world"});
expect(store.getValue("foo")).toBe("bar");
expect(store.getValue("hello")).toBe("world");
});
});
it("should remove a list item when a file is closed", function () {
DocumentManager.getCurrentDocument()._markClean();
// close the document
var didClose = false, gotError = false;
runs(function () {
CommandManager.execute(Commands.FILE_CLOSE)
.done(function () { didClose = true; })
.fail(function () { gotError = true; });
});
waitsFor(function () { return didClose && !gotError; },
"FILE_OPEN on file timeout", 1000);
// check there are no list items
runs(function () {
var listItems =
testWindow.$("#open-files-container > ul").children();
expect(listItems.length).toBe(1);
});
});
brackets/test/spec
brackets/test/UnitTestSuite.js
require()
for modules (private to test window)SpecRunnerUtils.createTestWindowAndRun()
testWindow.brackets.test.ModuleName
Try to build new features as extensions first
Minimize core code changes (and discuss with community)
extensions/user
main.js
file containing your main modulebrackets.getModule()
for core modulesrequire()
for your own modules and stringsExtensionUtils.loadStyleSheet()
for stylesunittests.js
for unit testsdefine(function (require, exports, module) {
"use strict";
var CommandManager = brackets.getModule("command/CommandManager"),
Menus = brackets.getModule("command/Menus");
// Function to run when the menu item is clicked
function doHelloWorld() {
window.alert("Hello, world!");
}
// Register command--can be called from menus, kbd shortcuts, etc.
var MY_COMMAND_ID = "helloworld.sayhello";
CommandManager.register("Hello World", MY_COMMAND_ID, doHelloWorld);
// Create a menu item and key binding bound to the command
var menu = Menus.getMenu(Menus.AppMenuBar.FILE_MENU);
menu.addMenuItem(MY_COMMAND_ID, "Ctrl-Alt-H");
});
Register with CodeHintManager.registerHintProvider()
{
shouldShowHintsOnKey: function (string) {
// quick shortcut check
// return true if you want to pop up hints on this key
},
getQueryInfo: function (editor, cursor) {
// return the query object to be used for hinting
// must have queryStr property--set to null if no hints
// query object can have other properties
},
search: function (query) {
// takes the query object and performs the actual search
// returns an array of matching strings
},
handleSelect: function (string, editor, cursor) {
// performs the edit based on the selected string
}
}
Register with QuickOpen.addQuickOpenPlugin()
{
name: /* plugin name */,
fileTypes: /* array of applicable types, or [] for all */,
match: function (queryStr) {
// returns true if this provider wants to handle the query
},
search: function (queryStr) {
// returns list of applicable items
// items can be strings or objects with a "label" property
},
itemFocus: function (item) {
// called when user highlights an item
},
itemSelect: function (item) {
// called when user chooses an item
},
resultFormatter: function (queryStr, item) {
// returns an <li> to display the given query and item object
},
done: function () {
// called when quick open is closed
}
}
Register with EditorManager.registerInlineEditProvider()
function myProvider(editor, pos) {
// returns either a Promise that will be resolved with an inline widget
// or null if we don't want to handle it
}
// Standard prototype chain hookup--do it however you like
function MyInlineWidget() {
InlineWidget.call(this);
// construct your widget's contents inside the $htmlContent node
}
MyInlineWidget.prototype = new InlineWidget();
MyInlineWidget.prototype.constructor = MyInlineWidget;
MyInlineWidget.prototype.parentClass = InlineWidget.prototype;
// can also implement onAdded, onClosed
If something's missing, please help us improve the docs!