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

Side by Side Diff: Source/devtools/front_end/documentation/DocumentationView.js

Issue 471583003: DevTools: [Documentation] Add property token autodetection (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@sources-patch
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @constructor 6 * @constructor
7 * @extends {WebInspector.VBox} 7 * @extends {WebInspector.VBox}
8 */ 8 */
9 WebInspector.DocumentationView = function() 9 WebInspector.DocumentationView = function()
10 { 10 {
(...skipping 27 matching lines...) Expand all
38 /** 38 /**
39 * @param {!Event} event 39 * @param {!Event} event
40 * @param {!WebInspector.ContextMenu} contextMenu 40 * @param {!WebInspector.ContextMenu} contextMenu
41 * @param {!Object} target 41 * @param {!Object} target
42 */ 42 */
43 appendApplicableItems: function(event, contextMenu, target) 43 appendApplicableItems: function(event, contextMenu, target)
44 { 44 {
45 if (!(target instanceof WebInspector.CodeMirrorTextEditor)) 45 if (!(target instanceof WebInspector.CodeMirrorTextEditor))
46 return; 46 return;
47 var textEditor = /** @type {!WebInspector.CodeMirrorTextEditor} */ (targ et); 47 var textEditor = /** @type {!WebInspector.CodeMirrorTextEditor} */ (targ et);
48 var selection = textEditor.selection(); 48
49 if (!selection || selection.isEmpty() || selection.startLine !== selecti on.endLine) 49 var textPosition = textEditor.coordinatesToCursorPosition(event.x, event .y);
50 var token = textEditor.tokenAtTextPosition(textPosition.startLine, textP osition.startColumn);
51 if (!token)
50 return; 52 return;
51 var selectedText = textEditor.copyRange(selection); 53 var lineNumber = textPosition.startLine;
apavlov 2014/08/13 15:11:17 inline this
semeny 2014/08/13 15:23:27 Done.
54 var line = textEditor.line(lineNumber);
55 var tokenContent = line.substring(token.startColumn, token.endColumn + 1 );
apavlov 2014/08/13 15:11:17 tokenText is a bit shorter :)
semeny 2014/08/13 15:23:26 Done.
56
52 var urlProvider = new WebInspector.DocumentationURLProvider(); 57 var urlProvider = new WebInspector.DocumentationURLProvider();
53 var descriptors = urlProvider.itemDescriptors(selectedText); 58 var descriptors = urlProvider.itemDescriptors(tokenContent);
54 if (!descriptors.length) 59 if (!descriptors.length)
55 return; 60 return;
56 if (descriptors.length === 1) { 61 if (descriptors.length === 1) {
57 var formatString = WebInspector.useLowerCaseMenuTitles() ? "Show doc umentation for %s.%s" : "Show Documentation for %s.%s"; 62 var formatString = WebInspector.useLowerCaseMenuTitles() ? "Show doc umentation for %s.%s" : "Show Documentation for %s.%s";
58 contextMenu.appendItem(WebInspector.UIString(formatString, descripto rs[0].name, selectedText), WebInspector.DocumentationView.showDocumentationURL.b ind(null, descriptors[0].url)); 63 contextMenu.appendItem(WebInspector.UIString(formatString, descripto rs[0].name, tokenContent), WebInspector.DocumentationView.showDocumentationURL.b ind(null, descriptors[0].url));
59 return; 64 return;
60 } 65 }
61 var subMenuItem = contextMenu.appendSubMenuItem(WebInspector.UIString(We bInspector.useLowerCaseMenuTitles() ? "Show documentation for..." : "Show Docume ntation for...")); 66 var subMenuItem = contextMenu.appendSubMenuItem(WebInspector.UIString(We bInspector.useLowerCaseMenuTitles() ? "Show documentation for..." : "Show Docume ntation for..."));
62 for (var i = 0; i < descriptors.length; ++i) 67 for (var i = 0; i < descriptors.length; ++i)
63 subMenuItem.appendItem(String.sprintf("%s.%s", descriptors[i].name, selectedText), WebInspector.DocumentationView.showDocumentationURL.bind(null, de scriptors[i].url)); 68 subMenuItem.appendItem(String.sprintf("%s.%s", descriptors[i].name, tokenContent), WebInspector.DocumentationView.showDocumentationURL.bind(null, de scriptors[i].url));
64 } 69 }
65 } 70 }
OLDNEW
« 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