This repository was archived by the owner on Sep 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Fix #2902: Externalize debug menu as an extension #2942
Merged
Merged
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
1d58a34
Refactor the debug menu and commands as an extension
TomMalbran 1e6036e
Removing the Debug commands from the test file
TomMalbran 2bc1510
Changes after first review
TomMalbran 3a567b4
Fixing Tabs
TomMalbran e977879
Merge remote-tracking branch 'upstream/master' into tom/debug-extension
TomMalbran e17662a
Backed changes added to Global.js and changed handleReload
TomMalbran c674bf7
Tab fix
TomMalbran 1e509ea
Cleanning Global.js
TomMalbran 17383cd
Commands IDs moved and key binding fixed
TomMalbran File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,15 +28,21 @@ | |
define(function (require, exports, module) { | ||
"use strict"; | ||
|
||
var Commands = require("command/Commands"), | ||
CommandManager = require("command/CommandManager"), | ||
Editor = require("editor/Editor").Editor, | ||
FileUtils = require("file/FileUtils"), | ||
Strings = require("strings"), | ||
PerfUtils = require("utils/PerfUtils"), | ||
NativeApp = require("utils/NativeApp"), | ||
NativeFileSystem = require("file/NativeFileSystem").NativeFileSystem, | ||
NodeDebugUtils = require("debug/NodeDebugUtils"); | ||
var Commands = brackets.getModule("command/Commands"), | ||
CommandManager = brackets.getModule("command/CommandManager"), | ||
DocumentCommandHandlers = brackets.getModule("document/DocumentCommandHandlers"), | ||
Editor = brackets.getModule("editor/Editor").Editor, | ||
FileUtils = brackets.getModule("file/FileUtils"), | ||
Menus = brackets.getModule("command/Menus"), | ||
Strings = brackets.getModule("strings"), | ||
PerfUtils = brackets.getModule("utils/PerfUtils"), | ||
NativeApp = brackets.getModule("utils/NativeApp"), | ||
NativeFileSystem = brackets.getModule("file/NativeFileSystem").NativeFileSystem, | ||
NodeDebugUtils = require("NodeDebugUtils"); | ||
|
||
/** @const {string} Brackets Application Menu Constant */ | ||
var DEBUG_MENU = "debug-menu"; | ||
|
||
|
||
function handleShowDeveloperTools(commandData) { | ||
brackets.app.showDeveloperTools(); | ||
|
@@ -259,11 +265,13 @@ define(function (require, exports, module) { | |
); | ||
} | ||
|
||
|
||
/* Register all the command handlers */ | ||
|
||
// Show Developer Tools (optionally enabled) | ||
CommandManager.register(Strings.CMD_SHOW_DEV_TOOLS, Commands.DEBUG_SHOW_DEVELOPER_TOOLS, handleShowDeveloperTools) | ||
.setEnabled(!!brackets.app.showDeveloperTools && brackets.config.show_debug_menu); | ||
.setEnabled(!!brackets.app.showDeveloperTools); | ||
CommandManager.register(Strings.CMD_REFRESH_WINDOW, Commands.DEBUG_REFRESH_WINDOW, DocumentCommandHandlers.handleFileReload); | ||
CommandManager.register(Strings.CMD_NEW_BRACKETS_WINDOW, Commands.DEBUG_NEW_BRACKETS_WINDOW, _handleNewBracketsWindow); | ||
|
||
// Start with the "Run Tests" item disabled. It will be enabled later if the test file can be found. | ||
|
@@ -275,12 +283,31 @@ define(function (require, exports, module) { | |
|
||
|
||
// Node-related Commands | ||
CommandManager.register(Strings.CMD_ENABLE_NODE_DEBUGGER, Commands.DEBUG_ENABLE_NODE_DEBUGGER, NodeDebugUtils.enableDebugger); | ||
CommandManager.register(Strings.CMD_LOG_NODE_STATE, Commands.DEBUG_LOG_NODE_STATE, NodeDebugUtils.logNodeState); | ||
CommandManager.register(Strings.CMD_RESTART_NODE, Commands.DEBUG_RESTART_NODE, NodeDebugUtils.restartNode); | ||
CommandManager.register(Strings.CMD_ENABLE_NODE_DEBUGGER, Commands.DEBUG_ENABLE_NODE_DEBUGGER, NodeDebugUtils.enableDebugger); | ||
CommandManager.register(Strings.CMD_LOG_NODE_STATE, Commands.DEBUG_LOG_NODE_STATE, NodeDebugUtils.logNodeState); | ||
CommandManager.register(Strings.CMD_RESTART_NODE, Commands.DEBUG_RESTART_NODE, NodeDebugUtils.restartNode); | ||
|
||
_enableRunTestsMenuItem(); | ||
|
||
|
||
/* | ||
* Debug menu | ||
*/ | ||
var menu = Menus.addMenu(Strings.DEBUG_MENU, DEBUG_MENU, Menus.BEFORE, Menus.AppMenuBar.HELP_MENU); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to refactor the 2 debug keyboard shortcuts out of src/base-config/keyboard.json into this extension. |
||
menu.addMenuItem(Commands.DEBUG_SHOW_DEVELOPER_TOOLS); | ||
menu.addMenuItem(Commands.DEBUG_REFRESH_WINDOW); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can remove the KeyBindingManager calls above and pass keybindings to addMenuItem for both:
|
||
menu.addMenuItem(Commands.DEBUG_NEW_BRACKETS_WINDOW); | ||
menu.addMenuDivider(); | ||
menu.addMenuItem(Commands.DEBUG_SWITCH_LANGUAGE); | ||
menu.addMenuDivider(); | ||
menu.addMenuItem(Commands.DEBUG_RUN_UNIT_TESTS); | ||
menu.addMenuItem(Commands.DEBUG_SHOW_PERF_DATA); | ||
menu.addMenuDivider(); | ||
menu.addMenuItem(Commands.DEBUG_ENABLE_NODE_DEBUGGER); | ||
menu.addMenuItem(Commands.DEBUG_LOG_NODE_STATE); | ||
menu.addMenuItem(Commands.DEBUG_RESTART_NODE); | ||
|
||
|
||
// exposed for convenience, but not official API | ||
exports._runUnitTests = _runUnitTests; | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36815,7 +36815,7 @@ define('editor/EditorCommandHandlers',['require','exports','module','command/Com | |
/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please revert this file. This is only for performance testing and we need this snapshot to stay intact. Thanks! |
||
/*global define, $, brackets, window */ | ||
|
||
define('debug/DebugCommandHandlers',['require','exports','module','command/Commands','command/CommandManager','editor/Editor','strings','utils/PerfUtils','utils/NativeApp','file/NativeFileSystem','file/FileUtils','utils/UpdateNotification'],function (require, exports, module) { | ||
define(['require','exports','module','command/Commands','command/CommandManager','editor/Editor','strings','utils/PerfUtils','utils/NativeApp','file/NativeFileSystem','file/FileUtils','utils/UpdateNotification'],function (require, exports, module) { | ||
|
||
|
||
var Commands = require("command/Commands"), | ||
|
@@ -37941,7 +37941,7 @@ require.config({ | |
* htmlContentLoadComplete - sent when the HTML DOM is fully loaded. Modules should not touch | ||
* or modify DOM elements before this event is sent. | ||
*/ | ||
define('brackets',['require','exports','module','widgets/bootstrap-dropdown','widgets/bootstrap-modal','thirdparty/path-utils/path-utils.min','thirdparty/smart-auto-complete/jquery.smart_autocomplete','LiveDevelopment/main','project/ProjectManager','document/DocumentManager','editor/EditorManager','editor/CSSInlineEditor','language/JSUtils','project/WorkingSetView','document/DocumentCommandHandlers','project/FileViewController','project/FileSyncManager','command/KeyBindingManager','command/Commands','command/CommandManager','utils/BuildInfoUtils','editor/CodeHintManager','language/JSLintUtils','utils/PerfUtils','project/FileIndexManager','search/QuickOpen','command/Menus','file/FileUtils','text!htmlContent/main-view.html','strings','widgets/Dialogs','utils/ExtensionLoader','project/SidebarView','utils/Async','utils/UpdateNotification','utils/UrlParams','document/ChangedDocumentTracker','editor/EditorCommandHandlers','debug/DebugCommandHandlers','view/ViewCommandHandlers','search/FindInFiles','search/FindReplace','utils/ExtensionUtils','utils/ShellAPI','preferences/PreferencesManager','command/CommandManager','language/CSSUtils','LiveDevelopment/LiveDevelopment','LiveDevelopment/Inspector/Inspector','utils/NativeApp','utils/ExtensionUtils','utils/UpdateNotification'],function (require, exports, module) { | ||
define('brackets',['require','exports','module','widgets/bootstrap-dropdown','widgets/bootstrap-modal','thirdparty/path-utils/path-utils.min','thirdparty/smart-auto-complete/jquery.smart_autocomplete','LiveDevelopment/main','project/ProjectManager','document/DocumentManager','editor/EditorManager','editor/CSSInlineEditor','language/JSUtils','project/WorkingSetView','document/DocumentCommandHandlers','project/FileViewController','project/FileSyncManager','command/KeyBindingManager','command/Commands','command/CommandManager','utils/BuildInfoUtils','editor/CodeHintManager','language/JSLintUtils','utils/PerfUtils','project/FileIndexManager','search/QuickOpen','command/Menus','file/FileUtils','text!htmlContent/main-view.html','strings','widgets/Dialogs','utils/ExtensionLoader','project/SidebarView','utils/Async','utils/UpdateNotification','utils/UrlParams','document/ChangedDocumentTracker','editor/EditorCommandHandlers','view/ViewCommandHandlers','search/FindInFiles','search/FindReplace','utils/ExtensionUtils','utils/ShellAPI','preferences/PreferencesManager','command/CommandManager','language/CSSUtils','LiveDevelopment/LiveDevelopment','LiveDevelopment/Inspector/Inspector','utils/NativeApp','utils/ExtensionUtils','utils/UpdateNotification'],function (require, exports, module) { | ||
|
||
|
||
// Load dependent non-module scripts | ||
|
@@ -37994,7 +37994,6 @@ define('brackets',['require','exports','module','widgets/bootstrap-dropdown','wi | |
//Load modules that self-register and just need to get included in the main project | ||
require("document/ChangedDocumentTracker"); | ||
require("editor/EditorCommandHandlers"); | ||
require("debug/DebugCommandHandlers"); | ||
require("view/ViewCommandHandlers"); | ||
require("search/FindInFiles"); | ||
require("search/FindReplace"); | ||
|
@@ -75069,7 +75068,7 @@ define('editor/EditorCommandHandlers',['require','exports','module','command/Com | |
/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ | ||
/*global define, $, brackets, window */ | ||
|
||
define('debug/DebugCommandHandlers',['require','exports','module','command/Commands','command/CommandManager','editor/Editor','strings','utils/PerfUtils','utils/NativeApp','file/NativeFileSystem','file/FileUtils','utils/UpdateNotification'],function (require, exports, module) { | ||
define(['require','exports','module','command/Commands','command/CommandManager','editor/Editor','strings','utils/PerfUtils','utils/NativeApp','file/NativeFileSystem','file/FileUtils','utils/UpdateNotification'],function (require, exports, module) { | ||
|
||
|
||
var Commands = require("command/Commands"), | ||
|
@@ -76195,7 +76194,7 @@ require.config({ | |
* htmlContentLoadComplete - sent when the HTML DOM is fully loaded. Modules should not touch | ||
* or modify DOM elements before this event is sent. | ||
*/ | ||
define('brackets',['require','exports','module','widgets/bootstrap-dropdown','widgets/bootstrap-modal','thirdparty/path-utils/path-utils.min','thirdparty/smart-auto-complete/jquery.smart_autocomplete','LiveDevelopment/main','project/ProjectManager','document/DocumentManager','editor/EditorManager','editor/CSSInlineEditor','language/JSUtils','project/WorkingSetView','document/DocumentCommandHandlers','project/FileViewController','project/FileSyncManager','command/KeyBindingManager','command/Commands','command/CommandManager','utils/BuildInfoUtils','editor/CodeHintManager','language/JSLintUtils','utils/PerfUtils','project/FileIndexManager','search/QuickOpen','command/Menus','file/FileUtils','text!htmlContent/main-view.html','strings','widgets/Dialogs','utils/ExtensionLoader','project/SidebarView','utils/Async','utils/UpdateNotification','utils/UrlParams','document/ChangedDocumentTracker','editor/EditorCommandHandlers','debug/DebugCommandHandlers','view/ViewCommandHandlers','search/FindInFiles','search/FindReplace','utils/ExtensionUtils','utils/ShellAPI','preferences/PreferencesManager','command/CommandManager','language/CSSUtils','LiveDevelopment/LiveDevelopment','LiveDevelopment/Inspector/Inspector','utils/NativeApp','utils/ExtensionUtils','utils/UpdateNotification'],function (require, exports, module) { | ||
define('brackets',['require','exports','module','widgets/bootstrap-dropdown','widgets/bootstrap-modal','thirdparty/path-utils/path-utils.min','thirdparty/smart-auto-complete/jquery.smart_autocomplete','LiveDevelopment/main','project/ProjectManager','document/DocumentManager','editor/EditorManager','editor/CSSInlineEditor','language/JSUtils','project/WorkingSetView','document/DocumentCommandHandlers','project/FileViewController','project/FileSyncManager','command/KeyBindingManager','command/Commands','command/CommandManager','utils/BuildInfoUtils','editor/CodeHintManager','language/JSLintUtils','utils/PerfUtils','project/FileIndexManager','search/QuickOpen','command/Menus','file/FileUtils','text!htmlContent/main-view.html','strings','widgets/Dialogs','utils/ExtensionLoader','project/SidebarView','utils/Async','utils/UpdateNotification','utils/UrlParams','document/ChangedDocumentTracker','editor/EditorCommandHandlers','view/ViewCommandHandlers','search/FindInFiles','search/FindReplace','utils/ExtensionUtils','utils/ShellAPI','preferences/PreferencesManager','command/CommandManager','language/CSSUtils','LiveDevelopment/LiveDevelopment','LiveDevelopment/Inspector/Inspector','utils/NativeApp','utils/ExtensionUtils','utils/UpdateNotification'],function (require, exports, module) { | ||
|
||
|
||
// Load dependent non-module scripts | ||
|
@@ -76248,7 +76247,6 @@ define('brackets',['require','exports','module','widgets/bootstrap-dropdown','wi | |
//Load modules that self-register and just need to get included in the main project | ||
require("document/ChangedDocumentTracker"); | ||
require("editor/EditorCommandHandlers"); | ||
require("debug/DebugCommandHandlers"); | ||
require("view/ViewCommandHandlers"); | ||
require("search/FindInFiles"); | ||
require("search/FindReplace"); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like a cleaner way to do this would be to refactor
_handleWindowGoingAway
to some other module like Global.js and movehandleFileReload
to the debug extension.