OLD | NEW |
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 */ | 7 */ |
8 WebInspector.DocumentationURLProvider = function() | 8 WebInspector.DocumentationURLProvider = function() |
9 { | 9 { |
10 this._gapFromIndex = 0; | 10 this._gapFromIndex = 0; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 * @return {string} | 67 * @return {string} |
68 */ | 68 */ |
69 searchItem: function() | 69 searchItem: function() |
70 { | 70 { |
71 return this._searchItem; | 71 return this._searchItem; |
72 } | 72 } |
73 } | 73 } |
74 | 74 |
75 /** | 75 /** |
76 * @constructor | 76 * @constructor |
77 * FIXME: source parameter is not annotated property due to crbug.com/407097 | 77 * FIXME: source parameter is not annotated properly due to crbug.com/407097 |
78 * @param {*} source | 78 * @param {*} source |
79 * @param {string} url | 79 * @param {string} url |
80 * @param {string} name | 80 * @param {string} name |
81 */ | 81 */ |
82 WebInspector.DocumentationURLProvider.DocumentationSource = function(source, url
, name) | 82 WebInspector.DocumentationURLProvider.DocumentationSource = function(source, url
, name) |
83 { | 83 { |
84 this._source = source; | 84 this._source = source; |
85 this._url = url; | 85 this._url = url; |
86 this._name = name; | 86 this._name = name; |
87 } | 87 } |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 if (this._state === WebInspector.DocumentationURLProvider.DownloadStates
.Finished) | 165 if (this._state === WebInspector.DocumentationURLProvider.DownloadStates
.Finished) |
166 return this._articleList.get(searchTerm) || []; | 166 return this._articleList.get(searchTerm) || []; |
167 // If download of available articles list is not finished yet, use appro
ximate method. | 167 // If download of available articles list is not finished yet, use appro
ximate method. |
168 if (this._state === WebInspector.DocumentationURLProvider.DownloadStates
.NotStarted) | 168 if (this._state === WebInspector.DocumentationURLProvider.DownloadStates
.NotStarted) |
169 this._loadArticleList(); | 169 this._loadArticleList(); |
170 | 170 |
171 var descriptors = []; | 171 var descriptors = []; |
172 var sources = WebInspector.DocumentationURLProvider._sources; | 172 var sources = WebInspector.DocumentationURLProvider._sources; |
173 var propertyName = searchTerm.toUpperCase() === searchTerm ? "constants"
: searchTerm; | 173 var propertyName = searchTerm.toUpperCase() === searchTerm ? "constants"
: searchTerm; |
174 for (var i = 0; i < sources.length; ++i) { | 174 for (var i = 0; i < sources.length; ++i) { |
175 if (!sources[i].source().hasOwnProperty(propertyName)) | 175 if (!sources[i].source().hasOwnProperty(searchTerm) || this._inherit
edFromFunction(sources[i].source(), searchTerm)) |
176 continue; | 176 continue; |
177 descriptors.push(new WebInspector.DocumentationURLProvider.ItemDescr
iptor(sources[i], propertyName)); | 177 descriptors.push(new WebInspector.DocumentationURLProvider.ItemDescr
iptor(sources[i], propertyName)); |
178 } | 178 } |
179 return descriptors; | 179 return descriptors; |
180 }, | 180 }, |
181 | 181 |
182 _loadArticleList: function() | 182 _loadArticleList: function() |
183 { | 183 { |
184 this._state = WebInspector.DocumentationURLProvider.DownloadStates.InPro
gress; | 184 this._state = WebInspector.DocumentationURLProvider.DownloadStates.InPro
gress; |
185 | 185 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 }, | 226 }, |
227 | 227 |
228 /** | 228 /** |
229 * @param {string} itemPath | 229 * @param {string} itemPath |
230 */ | 230 */ |
231 _addDescriptorToList: function(itemPath) | 231 _addDescriptorToList: function(itemPath) |
232 { | 232 { |
233 var lastSlashIndex = itemPath.lastIndexOf("/"); | 233 var lastSlashIndex = itemPath.lastIndexOf("/"); |
234 if (lastSlashIndex === -1) | 234 if (lastSlashIndex === -1) |
235 return; | 235 return; |
| 236 var sourceName = itemPath.substring(0, lastSlashIndex + 1); |
236 // There are some properties which have several words in their name. | 237 // There are some properties which have several words in their name. |
237 // In article list they are written through gap, while in URL they are w
ritten through underscore. | 238 // In article list they are written through gap, while in URL they are w
ritten through underscore. |
238 // We are creating URL for current property, so we have to replace all t
he gaps with underscores. | 239 // We are creating URL for current property, so we have to replace all t
he gaps with underscores. |
239 var correctedItemPath = itemPath.replace(" ", "_"); | 240 var propertyName = itemPath.substring(lastSlashIndex + 1).replace(" ", "
_"); |
240 var sourceName = correctedItemPath.substring(0, lastSlashIndex + 1); | |
241 var propertyName = correctedItemPath.substring(lastSlashIndex + 1); | |
242 var sources = WebInspector.DocumentationURLProvider._sources; | 241 var sources = WebInspector.DocumentationURLProvider._sources; |
243 for (var i = 0; i < sources.length; ++i) { | 242 for (var i = 0; i < sources.length; ++i) { |
244 if (sources[i].url() !== sourceName || !sources[i].source().hasOwnPr
operty(propertyName)) | 243 if (sources[i].url() !== sourceName || !sources[i].source().hasOwnPr
operty(propertyName) || this._inheritedFromFunction(sources[i].source(), propert
yName)) |
245 continue; | 244 continue; |
246 var descriptors = this._articleList.get(propertyName) || []; | 245 var descriptors = this._articleList.get(propertyName) || []; |
247 descriptors.push(new WebInspector.DocumentationURLProvider.ItemDescr
iptor(sources[i], propertyName)); | 246 descriptors.push(new WebInspector.DocumentationURLProvider.ItemDescr
iptor(sources[i], propertyName)); |
248 this._articleList.set(propertyName, descriptors); | 247 this._articleList.set(propertyName, descriptors); |
249 } | 248 } |
| 249 }, |
| 250 |
| 251 /** |
| 252 * FIXME: object parameter is not annotated properly due to crbug.com/407097 |
| 253 * @param {*} object |
| 254 * @param {string} propertyName |
| 255 * @return {boolean} |
| 256 */ |
| 257 _inheritedFromFunction: function(object, propertyName) |
| 258 { |
| 259 return (object instanceof Function && object.hasOwnProperty(propertyName
) && Function.hasOwnProperty(propertyName)); |
250 } | 260 } |
251 } | 261 } |
OLD | NEW |