| 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)?funct
ion\*?\s/; |
| 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.source + "([^)]*)"); |
| 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 matched = func.description.match(WebInspector.ObjectPropertiesSectio
n._functionPrefixSource); |
| 1211 if (matched) { |
| 1212 var prefix = createElementWithClass("span", "object-value-function-p
refix"); |
| 1213 prefix.textContent = matched[0]; |
| 1214 element.appendChild(prefix); |
| 1215 } |
| 1216 |
| 1207 if (linkify && response && response.location) { | 1217 if (linkify && response && response.location) { |
| 1208 var anchor = createElement("span"); | 1218 var anchor = createElement("span"); |
| 1209 element.classList.add("linkified"); | 1219 element.classList.add("linkified"); |
| 1210 element.appendChild(anchor); | 1220 element.appendChild(anchor); |
| 1211 element.addEventListener("click", WebInspector.Revealer.reveal.bind(
WebInspector.Revealer, response.location, undefined)); | 1221 element.addEventListener("click", WebInspector.Revealer.reveal.bind(
WebInspector.Revealer, response.location, undefined)); |
| 1212 element = anchor; | 1222 element = anchor; |
| 1213 } | 1223 } |
| 1214 | 1224 |
| 1215 var text = func.description.substring(0, 200); | 1225 var text = func.description.substring(0, 200); |
| 1216 if (includePreview) { | 1226 if (includePreview) { |
| 1217 element.textContent = text.replace(/^function /, "") + (func.descrip
tion.length > 200 ? "\u2026" : ""); | 1227 element.createTextChild(text.replace(WebInspector.ObjectPropertiesSe
ction._functionPrefixSource, "") + (func.description.length > 200 ? "\u2026" : "
")); |
| 1218 return; | 1228 return; |
| 1219 } | 1229 } |
| 1220 | 1230 |
| 1221 // Now parse description and get the real params and title. | 1231 // Now parse description and get the real params and title. |
| 1222 self.runtime.extension(WebInspector.TokenizerFactory).instance().then(pr
ocessTokens); | 1232 self.runtime.extension(WebInspector.TokenizerFactory).instance().then(pr
ocessTokens); |
| 1223 | 1233 |
| 1224 var params = null; | 1234 var params = null; |
| 1225 var functionName = response ? response.functionName : ""; | 1235 var functionName = response ? response.functionName : ""; |
| 1226 | 1236 |
| 1227 /** | 1237 /** |
| 1228 * @param {!WebInspector.TokenizerFactory} tokenizerFactory | 1238 * @param {!WebInspector.TokenizerFactory} tokenizerFactory |
| 1229 */ | 1239 */ |
| 1230 function processTokens(tokenizerFactory) | 1240 function processTokens(tokenizerFactory) |
| 1231 { | 1241 { |
| 1232 var tokenize = tokenizerFactory.createTokenizer("text/javascript"); | 1242 var tokenize = tokenizerFactory.createTokenizer("text/javascript"); |
| 1233 tokenize(text, processToken); | 1243 tokenize(text, processToken); |
| 1234 element.textContent = (functionName || "anonymous") + "(" + (params
|| []).join(", ") + ")"; | 1244 element.createTextChild((functionName || "anonymous") + "(" + (param
s || []).join(", ") + ")"); |
| 1235 } | 1245 } |
| 1236 | 1246 |
| 1237 var doneProcessing = false; | 1247 var doneProcessing = false; |
| 1238 | 1248 |
| 1239 /** | 1249 /** |
| 1240 * @param {string} token | 1250 * @param {string} token |
| 1241 * @param {?string} tokenType | 1251 * @param {?string} tokenType |
| 1242 * @param {number} column | 1252 * @param {number} column |
| 1243 * @param {number} newColumn | 1253 * @param {number} newColumn |
| 1244 */ | 1254 */ |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1350 | 1360 |
| 1351 result = currentName + (result ? "." + result : ""); | 1361 result = currentName + (result ? "." + result : ""); |
| 1352 current = current.parent; | 1362 current = current.parent; |
| 1353 } | 1363 } |
| 1354 var treeOutlineId = treeElement.treeOutline[WebInspector.ObjectPropertie
sSectionExpandController._treeOutlineId]; | 1364 var treeOutlineId = treeElement.treeOutline[WebInspector.ObjectPropertie
sSectionExpandController._treeOutlineId]; |
| 1355 result = treeOutlineId + (result ? ":" + result : ""); | 1365 result = treeOutlineId + (result ? ":" + result : ""); |
| 1356 treeElement[WebInspector.ObjectPropertiesSectionExpandController._cached
PathSymbol] = result; | 1366 treeElement[WebInspector.ObjectPropertiesSectionExpandController._cached
PathSymbol] = result; |
| 1357 return result; | 1367 return result; |
| 1358 } | 1368 } |
| 1359 } | 1369 } |
| OLD | NEW |