Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1828)

Unified Diff: Source/devtools/front_end/documentation/DocumentationView.js

Issue 458983002: DevTools: Omit the "Show documentation" context menu item creation for non-existent JS methods (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Minor changes Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/documentation/DocumentationView.js
diff --git a/Source/devtools/front_end/documentation/DocumentationView.js b/Source/devtools/front_end/documentation/DocumentationView.js
index 501a9d689c841e2ed282d32782d4a41c0edf822a..8078fe3914db48aeccce5d7c8d08a3aeca5546f6 100644
--- a/Source/devtools/front_end/documentation/DocumentationView.js
+++ b/Source/devtools/front_end/documentation/DocumentationView.js
@@ -50,18 +50,25 @@ WebInspector.DocumentationView.ContextMenuProvider.prototype = {
if (!(target instanceof WebInspector.CodeMirrorTextEditor))
return;
var textEditor = /** @type {!WebInspector.CodeMirrorTextEditor} */ (target);
- contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Show documentation" : "Show Documentation"), this._showDocumentation.bind(this, textEditor));
+ var selectedText = this._getSelection(textEditor);
apavlov 2014/08/11 15:04:14 Blink does not use "get" prefixes. This should be
+ if (!selectedText)
+ return;
+ var urlProvider = new WebInspector.DocumentationURLProvider();
apavlov 2014/08/11 15:04:14 Can we make it a singleton? It has no state
semeny 2014/08/11 15:34:28 Did not really understand what is wrong and what s
+ var itemPath = urlProvider.itemPath(selectedText);
+ if (!itemPath)
+ return;
+ contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Show documentation" : "Show Documentation"), WebInspector.DocumentationView.showSearchTerm.bind(null, selectedText));
},
/**
* @param {!WebInspector.CodeMirrorTextEditor} textEditor
+ * @return {?string}
*/
- _showDocumentation: function(textEditor)
+ _getSelection: function(textEditor)
lushnikov 2014/08/11 14:59:47 no need for the separate function - please, inline
semeny 2014/08/11 15:34:28 Done.
{
var selection = textEditor.selection();
- if (!selection || selection.isEmpty())
- return;
- var selectedText = textEditor.copyRange(selection);
- WebInspector.DocumentationView.showSearchTerm(selectedText);
+ if (!selection || selection.isEmpty() || selection.startLine !== selection.endLine)
apavlov 2014/08/11 15:04:14 Shouldn't this detect the word at cursor if the se
semeny 2014/08/11 15:34:28 No, only if property is selected.
+ return null;
+ return textEditor.copyRange(selection);
}
-}
+}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698