Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
| 3 * Copyright (C) 2009 Joseph Pecoraro | 3 * Copyright (C) 2009 Joseph Pecoraro |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1044 WebInspector.ObjectPropertiesSection.createNameElement = function(name) | 1044 WebInspector.ObjectPropertiesSection.createNameElement = function(name) |
| 1045 { | 1045 { |
| 1046 var nameElement = createElementWithClass("span", "name"); | 1046 var nameElement = createElementWithClass("span", "name"); |
| 1047 if (/^\s|\s$|^$|\n/.test(name)) | 1047 if (/^\s|\s$|^$|\n/.test(name)) |
| 1048 nameElement.createTextChildren("\"", name.replace(/\n/g, "\u21B5"), "\"" ); | 1048 nameElement.createTextChildren("\"", name.replace(/\n/g, "\u21B5"), "\"" ); |
| 1049 else | 1049 else |
| 1050 nameElement.textContent = name; | 1050 nameElement.textContent = name; |
| 1051 return nameElement; | 1051 return nameElement; |
| 1052 } | 1052 } |
| 1053 | 1053 |
| 1054 WebInspector.ObjectPropertiesSection._functionPrefixSource = "^(?:async\\s)?func tion\\*?\\s"; | |
|
Dan Ehrenberg
2016/09/28 07:20:21
Does this path have to handle async arrow function
kozy
2016/09/28 15:32:46
I'll address arrow functions in separate CL.
lushnikov
2016/09/28 18:53:19
You can avoid double-escaping by using regex direc
kozy
2016/09/28 19:42:03
Done.
| |
| 1055 | |
| 1054 /** | 1056 /** |
| 1055 * @param {?string=} description | 1057 * @param {?string=} description |
| 1056 * @return {string} valueText | 1058 * @return {string} valueText |
| 1057 */ | 1059 */ |
| 1058 WebInspector.ObjectPropertiesSection.valueTextForFunctionDescription = function( description) | 1060 WebInspector.ObjectPropertiesSection.valueTextForFunctionDescription = function( description) |
| 1059 { | 1061 { |
| 1060 var text = description.replace(/^function [gs]et /, "function "); | 1062 var text = description.replace(/^function [gs]et /, "function "); |
| 1061 var matches = /^function\s([^)]*)/.exec(text); | 1063 var functionPrefixWithArguments = new RegExp(WebInspector.ObjectPropertiesSe ction._functionPrefixSource + "([^)]*)"); |
| 1064 var matches = functionPrefixWithArguments.exec(text); | |
| 1062 if (!matches) { | 1065 if (!matches) { |
| 1063 // process shorthand methods | 1066 // process shorthand methods |
| 1064 matches = /[^(]*(\([^)]*)/.exec(text); | 1067 matches = /[^(]*(\([^)]*)/.exec(text); |
| 1065 } | 1068 } |
| 1066 var match = matches ? matches[1] : null; | 1069 var match = matches ? matches[1] : null; |
| 1067 return match ? match.replace(/\n/g, " ") + ")" : (text || ""); | 1070 return match ? match.replace(/\n/g, " ") + ")" : (text || ""); |
| 1068 } | 1071 } |
| 1069 | 1072 |
| 1070 /** | 1073 /** |
| 1071 * @param {!WebInspector.RemoteObject} value | 1074 * @param {!WebInspector.RemoteObject} value |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1197 * @param {?WebInspector.DebuggerModel.FunctionDetails} response | 1200 * @param {?WebInspector.DebuggerModel.FunctionDetails} response |
| 1198 */ | 1201 */ |
| 1199 function didGetDetails(response) | 1202 function didGetDetails(response) |
| 1200 { | 1203 { |
| 1201 if (!response) { | 1204 if (!response) { |
| 1202 var valueText = WebInspector.ObjectPropertiesSection.valueTextForFun ctionDescription(func.description); | 1205 var valueText = WebInspector.ObjectPropertiesSection.valueTextForFun ctionDescription(func.description); |
| 1203 element.createTextChild(valueText); | 1206 element.createTextChild(valueText); |
| 1204 return; | 1207 return; |
| 1205 } | 1208 } |
| 1206 | 1209 |
| 1210 var functionPrefix = new RegExp(WebInspector.ObjectPropertiesSection._fu nctionPrefixSource); | |
| 1211 var matched = func.description.match(functionPrefix); | |
| 1212 if (matched) { | |
| 1213 var prefix = createElementWithClass("span", "function-prefix"); | |
| 1214 prefix.textContent = matched[0]; | |
| 1215 element.appendChild(prefix); | |
| 1216 } | |
| 1217 | |
| 1207 if (linkify && response && response.location) { | 1218 if (linkify && response && response.location) { |
| 1208 var anchor = createElement("span"); | 1219 var anchor = createElement("span"); |
| 1209 element.classList.add("linkified"); | 1220 element.classList.add("linkified"); |
| 1210 element.appendChild(anchor); | 1221 element.appendChild(anchor); |
| 1211 element.addEventListener("click", WebInspector.Revealer.reveal.bind( WebInspector.Revealer, response.location, undefined)); | 1222 element.addEventListener("click", WebInspector.Revealer.reveal.bind( WebInspector.Revealer, response.location, undefined)); |
| 1212 element = anchor; | 1223 element = anchor; |
| 1213 } | 1224 } |
| 1214 | 1225 |
| 1215 var text = func.description.substring(0, 200); | 1226 var text = func.description.substring(0, 200); |
| 1216 if (includePreview) { | 1227 if (includePreview) { |
| 1217 element.textContent = text.replace(/^function /, "") + (func.descrip tion.length > 200 ? "\u2026" : ""); | 1228 element.createTextChild(text.replace(functionPrefix, "") + (func.des cription.length > 200 ? "\u2026" : "")); |
| 1218 return; | 1229 return; |
| 1219 } | 1230 } |
| 1220 | 1231 |
| 1221 // Now parse description and get the real params and title. | 1232 // Now parse description and get the real params and title. |
| 1222 self.runtime.extension(WebInspector.TokenizerFactory).instance().then(pr ocessTokens); | 1233 self.runtime.extension(WebInspector.TokenizerFactory).instance().then(pr ocessTokens); |
| 1223 | 1234 |
| 1224 var params = null; | 1235 var params = null; |
| 1225 var functionName = response ? response.functionName : ""; | 1236 var functionName = response ? response.functionName : ""; |
| 1226 | 1237 |
| 1227 /** | 1238 /** |
| 1228 * @param {!WebInspector.TokenizerFactory} tokenizerFactory | 1239 * @param {!WebInspector.TokenizerFactory} tokenizerFactory |
| 1229 */ | 1240 */ |
| 1230 function processTokens(tokenizerFactory) | 1241 function processTokens(tokenizerFactory) |
| 1231 { | 1242 { |
| 1232 var tokenize = tokenizerFactory.createTokenizer("text/javascript"); | 1243 var tokenize = tokenizerFactory.createTokenizer("text/javascript"); |
| 1233 tokenize(text, processToken); | 1244 tokenize(text, processToken); |
| 1234 element.textContent = (functionName || "anonymous") + "(" + (params || []).join(", ") + ")"; | 1245 element.createTextChild((functionName || "anonymous") + "(" + (param s || []).join(", ") + ")"); |
| 1235 } | 1246 } |
| 1236 | 1247 |
| 1237 var doneProcessing = false; | 1248 var doneProcessing = false; |
| 1238 | 1249 |
| 1239 /** | 1250 /** |
| 1240 * @param {string} token | 1251 * @param {string} token |
| 1241 * @param {?string} tokenType | 1252 * @param {?string} tokenType |
| 1242 * @param {number} column | 1253 * @param {number} column |
| 1243 * @param {number} newColumn | 1254 * @param {number} newColumn |
| 1244 */ | 1255 */ |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1350 | 1361 |
| 1351 result = currentName + (result ? "." + result : ""); | 1362 result = currentName + (result ? "." + result : ""); |
| 1352 current = current.parent; | 1363 current = current.parent; |
| 1353 } | 1364 } |
| 1354 var treeOutlineId = treeElement.treeOutline[WebInspector.ObjectPropertie sSectionExpandController._treeOutlineId]; | 1365 var treeOutlineId = treeElement.treeOutline[WebInspector.ObjectPropertie sSectionExpandController._treeOutlineId]; |
| 1355 result = treeOutlineId + (result ? ":" + result : ""); | 1366 result = treeOutlineId + (result ? ":" + result : ""); |
| 1356 treeElement[WebInspector.ObjectPropertiesSectionExpandController._cached PathSymbol] = result; | 1367 treeElement[WebInspector.ObjectPropertiesSectionExpandController._cached PathSymbol] = result; |
| 1357 return result; | 1368 return result; |
| 1358 } | 1369 } |
| 1359 } | 1370 } |
| OLD | NEW |