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.5k
Fix for Issue 1617: Removed all references to CodeHintManager from Editor #5421
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b9813eb
Remove all references to CodeHintManager
WebsiteDeveloper e3e9a68
Revert some whitespace changes
WebsiteDeveloper 80c862a
Fix minor nits
WebsiteDeveloper 825fb1e
Merged with master
WebsiteDeveloper 0311641
Fix one minor nit
WebsiteDeveloper 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,10 +2,10 @@ | |
| * Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved. | ||
| * | ||
| * Permission is hereby granted, free of charge, to any person obtaining a | ||
| * copy of this software and associated documentation files (the "Software"), | ||
| * to deal in the Software without restriction, including without limitation | ||
| * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
| * and/or sell copies of the Software, and to permit persons to whom the | ||
| * copy of this software and associated documentation files (the "Software"), | ||
| * to deal in the Software without restriction, including without limitation | ||
| * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
| * and/or sell copies of the Software, and to permit persons to whom the | ||
| * Software is furnished to do so, subject to the following conditions: | ||
| * | ||
| * The above copyright notice and this permission notice shall be included in | ||
|
|
@@ -14,9 +14,9 @@ | |
| * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
| * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
| * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
| * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
| * DEALINGS IN THE SOFTWARE. | ||
| * | ||
| */ | ||
|
|
@@ -98,8 +98,8 @@ | |
| * may wish to prepare to cache data suitable for the current session. In | ||
| * particular, it should keep a reference to the editor object so that it | ||
| * can access the editor in future calls to getHints and insertHints. | ||
| * | ||
| * param {Editor} editor | ||
| * | ||
| * param {Editor} editor | ||
| * A non-null editor object for the active window. | ||
| * | ||
| * param {string} implicitChar | ||
|
|
@@ -111,8 +111,8 @@ | |
| * Determines whether the current provider is able to provide hints for | ||
| * the given editor context and, in case implicitChar is non- null, | ||
| * whether it is appropriate to do so. | ||
| * | ||
| * | ||
| * | ||
| * | ||
| * # CodeHintProvider.getHints(implicitChar) | ||
| * | ||
| * The method by which a provider provides hints for the editor context | ||
|
|
@@ -185,11 +185,11 @@ | |
| * matching substrings when rendering the hint list; and 3. a boolean that | ||
| * indicates whether the first result, if one exists, should be selected | ||
| * by default in the hint list window. If match is non-null, then the | ||
| * hints should be strings. | ||
| * | ||
| * If the match is null, the manager will not | ||
| * attempt to emphasize any parts of the hints when rendering the hint | ||
| * list; instead the provider may return strings or jQuery objects for | ||
| * hints should be strings. | ||
| * | ||
| * If the match is null, the manager will not | ||
| * attempt to emphasize any parts of the hints when rendering the hint | ||
| * list; instead the provider may return strings or jQuery objects for | ||
| * which emphasis is self-contained. For example, the strings may contain | ||
| * substrings that wrapped in bold tags. In this way, the provider can | ||
| * choose to let the manager handle emphasis for the simple and common case | ||
|
|
@@ -211,16 +211,16 @@ | |
| * | ||
| * param {string} hint | ||
| * The hint to be inserted into the editor context for the current session. | ||
| * | ||
| * return {boolean} | ||
| * | ||
| * return {boolean} | ||
| * Indicates whether the manager should follow hint insertion with an | ||
| * explicit hint request. | ||
| * | ||
| * | ||
| * # CodeHintProvider.insertHintOnTab | ||
| * | ||
| * type {?boolean} insertHintOnTab | ||
| * Indicates whether the CodeHintManager should request that the provider of | ||
| * Indicates whether the CodeHintManager should request that the provider of | ||
| * the current session insert the currently selected hint on tab key events, | ||
| * or if instead a tab character should be inserted into the editor. If omitted, | ||
| * the fallback behavior is determined by the CodeHintManager. The default | ||
|
|
@@ -275,7 +275,7 @@ define(function (require, exports, module) { | |
| return b.priority - a.priority; | ||
| } | ||
|
|
||
| /** | ||
| /** | ||
| * The method by which a CodeHintProvider registers its willingness to | ||
| * providing hints for editors in a given language. | ||
| * | ||
|
|
@@ -384,12 +384,12 @@ define(function (require, exports, module) { | |
| } | ||
| } | ||
|
|
||
| /** | ||
| /** | ||
| * Is there a hinting session active for a given editor? | ||
| * | ||
| * NOTE: the sessionEditor, sessionProvider and hintList objects are | ||
| * only guaranteed to be initialized during an active session. | ||
| * | ||
| * only guaranteed to be initialized during an active session. | ||
| * | ||
| * @param {Editor} editor | ||
| * @return boolean | ||
| */ | ||
|
|
@@ -433,7 +433,7 @@ define(function (require, exports, module) { | |
| _beginSession(previousEditor); | ||
| } else if (response.hasOwnProperty("hints")) { // a synchronous response | ||
| if (hintList.isOpen()) { | ||
| // the session is open | ||
| // the session is open | ||
| hintList.update(response); | ||
| } else { | ||
| hintList.open(response); | ||
|
|
@@ -442,7 +442,7 @@ define(function (require, exports, module) { | |
| deferredHints = response; | ||
| response.done(function (hints) { | ||
| if (hintList.isOpen()) { | ||
| // the session is open | ||
| // the session is open | ||
| hintList.update(hints); | ||
| } else { | ||
| hintList.open(hints); | ||
|
|
@@ -453,7 +453,7 @@ define(function (require, exports, module) { | |
| } | ||
|
|
||
| /** | ||
| * Try to begin a new hinting session. | ||
| * Try to begin a new hinting session. | ||
| * @param {Editor} editor | ||
| */ | ||
| _beginSession = function (editor) { | ||
|
|
@@ -497,7 +497,7 @@ define(function (require, exports, module) { | |
| }; | ||
|
|
||
| /** | ||
| * Explicitly start a new session. If we have an existing session, | ||
| * Explicitly start a new session. If we have an existing session, | ||
| * then close the current one and restart a new one. | ||
| * @param {Editor} editor | ||
| */ | ||
|
|
@@ -517,7 +517,7 @@ define(function (require, exports, module) { | |
| } | ||
|
|
||
| /** | ||
| * Handles keys related to displaying, searching, and navigating the hint list. | ||
| * Handles keys related to displaying, searching, and navigating the hint list. | ||
| * This gets called before handleChange. | ||
| * | ||
| * TODO: Ideally, we'd get a more semantic event from the editor that told us | ||
|
|
@@ -528,7 +528,7 @@ define(function (require, exports, module) { | |
| * @param {Editor} editor | ||
| * @param {KeyboardEvent} event | ||
| */ | ||
| function handleKeyEvent(editor, event) { | ||
| function _handleKeyEvent(jqEvent, editor, event) { | ||
| keyDownEditor = editor; | ||
| if (event.type === "keydown") { | ||
| if (!(event.ctrlKey || event.altKey || event.metaKey) && | ||
|
|
@@ -564,15 +564,15 @@ define(function (require, exports, module) { | |
| * Called by the editor after handleKeyEvent, which is responsible for setting | ||
| * the lastChar. | ||
| */ | ||
| function handleChange(editor, changeList) { | ||
| function _handleChange(event, editor, changeList) { | ||
|
Contributor
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 add all params to JSDoc. |
||
| if (lastChar && editor === keyDownEditor) { | ||
| keyDownEditor = null; | ||
| if (_inSession(editor)) { | ||
| var charToRetest = lastChar; | ||
| _updateHintList(); | ||
|
|
||
| // _updateHintList() may end a hinting session and clear lastChar, but a | ||
| // different provider may want to start a new session with the same character. | ||
| // _updateHintList() may end a hinting session and clear lastChar, but a | ||
| // different provider may want to start a new session with the same character. | ||
| // So check whether current provider terminates the current hinting | ||
| // session. If so, then restore lastChar and restart a new session. | ||
| if (!_inSession(editor)) { | ||
|
|
@@ -618,9 +618,22 @@ define(function (require, exports, module) { | |
| return hintList; | ||
| } | ||
|
|
||
| function activeEditorChangeHandler(event, current, previous) { | ||
| $(current).on("editorChange", _handleChange); | ||
|
Contributor
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. You need to check null on current before executing these two lines. |
||
| $(current).on("keyEvent", _handleKeyEvent); | ||
|
|
||
| //Removing all old Handlers | ||
| $(previous).off("editorChange", _handleChange); | ||
|
Contributor
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. Same as above. Please wrap these two lines with |
||
| $(previous).off("keyEvent", _handleKeyEvent); | ||
| } | ||
|
|
||
| activeEditorChangeHandler(null, EditorManager.getActiveEditor(), null); | ||
|
|
||
| $(EditorManager).on("activeEditorChange", activeEditorChangeHandler); | ||
|
|
||
| // Dismiss code hints before executing any command since the command | ||
| // may make the current hinting session irrevalent after execution. | ||
| // For example, when the user hits Ctrl+K to open Quick Doc, it is | ||
| // may make the current hinting session irrevalent after execution. | ||
| // For example, when the user hits Ctrl+K to open Quick Doc, it is | ||
| // pointless to keep the hint list since the user wants to view the Quick Doc. | ||
| $(CommandManager).on("beforeExecuteCommand", _endSession); | ||
|
|
||
|
|
@@ -631,8 +644,6 @@ define(function (require, exports, module) { | |
|
|
||
| // Define public API | ||
| exports.isOpen = isOpen; | ||
| exports.handleKeyEvent = handleKeyEvent; | ||
| exports.handleChange = handleChange; | ||
| exports.registerHintProvider = registerHintProvider; | ||
| exports.hasValidExclusion = hasValidExclusion; | ||
| exports.setInsertHintOnTab = setInsertHintOnTab; | ||
|
|
||
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
Oops, something went wrong.
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.
You need to update the JSDoc above by adding the first param jqEvent. Also, please change the function to
_handleKeyEvents(plural) so that it has the same name as the one in Editor module.