mirror of
https://github.com/RustyRaptor/brackets.git
synced 2026-12-04 00:15:22 -07:00
Added Goto Definition.
This commit is contained in:
1 parent
bef501fda0
commit
af9a7f01ab
6 files changed
+153
-1
No files matched your search
@@ -29,6 +29,10 @@ define(function (require, exports, module) {
|
||||
|
||||
var CodeHintManager = brackets.getModule("editor/CodeHintManager"),
|
||||
EditorManager = brackets.getModule("editor/EditorManager"),
|
||||
Commands = brackets.getModule("command/Commands"),
|
||||
CommandManager = brackets.getModule("command/CommandManager"),
|
||||
Menus = brackets.getModule("command/Menus"),
|
||||
Strings = brackets.getModule("strings"),
|
||||
AppInit = brackets.getModule("utils/AppInit"),
|
||||
ExtensionUtils = brackets.getModule("utils/ExtensionUtils"),
|
||||
StringUtils = brackets.getModule("utils/StringUtils"),
|
||||
@@ -36,6 +40,10 @@ define(function (require, exports, module) {
|
||||
ScopeManager = require("ScopeManager"),
|
||||
Session = require("Session");
|
||||
|
||||
var KeyboardPrefs = JSON.parse(require("text!keyboard.json"));
|
||||
|
||||
var JUMPTO_DEFINITION = "navigate.jumptoDefinition";
|
||||
|
||||
var session = null, // object that encapsulates the current session state
|
||||
cachedHints = null, // sorted hints for the current hinting session
|
||||
cachedType = null, // describes the lookup type and the object context
|
||||
@@ -376,6 +384,33 @@ define(function (require, exports, module) {
|
||||
installEditorListeners(current);
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle JumptoDefiniton menu/keyboard command.
|
||||
*/
|
||||
function handleJumpToDefinition() {
|
||||
var offset = session.getOffset(),
|
||||
response = ScopeManager.requestJumptoDef(session, session.editor.document, offset);
|
||||
|
||||
if (response.hasOwnProperty("promise")) {
|
||||
response.promise.done(function (jumpResp) {
|
||||
|
||||
session.editor.setSelection(jumpResp.start, jumpResp.end);
|
||||
session.editor.setCursorPos(jumpResp.start);
|
||||
session.editor.centerOnCursor();
|
||||
|
||||
}).fail(function () {
|
||||
response.reject();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Register command handler
|
||||
CommandManager.register(Strings.CMD_JUMPTO_DEFINITION, JUMPTO_DEFINITION, handleJumpToDefinition);
|
||||
|
||||
// Add the menu item
|
||||
var menu = Menus.getMenu(Menus.AppMenuBar.NAVIGATE_MENU);
|
||||
menu.addMenuItem(JUMPTO_DEFINITION, KeyboardPrefs.jumptoDefinition, Menus.BEFORE, Commands.NAVIGATE_GOTO_DEFINITION);
|
||||
|
||||
ExtensionUtils.loadStyleSheet(module, "styles/brackets-js-hints.css");
|
||||
|
||||
// uninstall/install change listener as the active editor changes
|
||||
|
||||
Reference in new issue
Block a user