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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
155 "javascript/" | 155 "javascript/" |
156 ]; | 156 ]; |
157 | 157 |
158 WebInspector.DocumentationURLProvider.prototype = { | 158 WebInspector.DocumentationURLProvider.prototype = { |
159 /** | 159 /** |
160 * @param {string} searchTerm | 160 * @param {string} searchTerm |
161 * @return {!Array.<!WebInspector.DocumentationURLProvider.ItemDescriptor>} | 161 * @return {!Array.<!WebInspector.DocumentationURLProvider.ItemDescriptor>} |
162 */ | 162 */ |
163 itemDescriptors: function(searchTerm) | 163 itemDescriptors: function(searchTerm) |
164 { | 164 { |
165 if (this._state === WebInspector.DocumentationURLProvider.DownloadStates .Finished) | 165 if (this._state === WebInspector.DocumentationURLProvider.DownloadStates .Finished) { |
166 return this._articleList.get(searchTerm) || []; | 166 if (searchTerm.toUpperCase() !== searchTerm) |
167 return this._articleList.get(searchTerm) || []; | |
168 } | |
167 // If download of available articles list is not finished yet, use appro ximate method. | 169 // If download of available articles list is not finished yet, use appro ximate method. |
168 if (this._state === WebInspector.DocumentationURLProvider.DownloadStates .NotStarted) | 170 if (this._state === WebInspector.DocumentationURLProvider.DownloadStates .NotStarted) |
169 this._loadArticleList(); | 171 this._loadArticleList(); |
170 | 172 |
171 var descriptors = []; | 173 var descriptors = []; |
172 var sources = WebInspector.DocumentationURLProvider._sources; | 174 var sources = WebInspector.DocumentationURLProvider._sources; |
173 var propertyName = searchTerm.toUpperCase() === searchTerm ? "constants" : searchTerm; | 175 var propertyName = searchTerm.toUpperCase() === searchTerm ? "constants" : searchTerm; |
174 for (var i = 0; i < sources.length; ++i) { | 176 for (var i = 0; i < sources.length; ++i) { |
175 if (!sources[i].source().hasOwnProperty(propertyName)) | 177 if (!sources[i].source().hasOwnProperty(searchTerm) || this._inherit edFromFunction(sources[i].source(), searchTerm)) |
176 continue; | 178 continue; |
177 descriptors.push(new WebInspector.DocumentationURLProvider.ItemDescr iptor(sources[i], propertyName)); | 179 descriptors.push(new WebInspector.DocumentationURLProvider.ItemDescr iptor(sources[i], propertyName)); |
178 } | 180 } |
179 return descriptors; | 181 return descriptors; |
180 }, | 182 }, |
181 | 183 |
182 _loadArticleList: function() | 184 _loadArticleList: function() |
183 { | 185 { |
184 this._state = WebInspector.DocumentationURLProvider.DownloadStates.InPro gress; | 186 this._state = WebInspector.DocumentationURLProvider.DownloadStates.InPro gress; |
185 | 187 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
233 var lastSlashIndex = itemPath.lastIndexOf("/"); | 235 var lastSlashIndex = itemPath.lastIndexOf("/"); |
234 if (lastSlashIndex === -1) | 236 if (lastSlashIndex === -1) |
235 return; | 237 return; |
236 var sourceName = itemPath.substring(0, lastSlashIndex + 1); | 238 var sourceName = itemPath.substring(0, lastSlashIndex + 1); |
237 // There are some properties which have several words in their name. | 239 // There are some properties which have several words in their name. |
238 // In article list they are written through gap, while in URL they are w ritten through underscore. | 240 // In article list they are written through gap, while in URL they are w ritten through underscore. |
239 // We are creating URL for current property, so we have to replace all t he gaps with underscores. | 241 // We are creating URL for current property, so we have to replace all t he gaps with underscores. |
240 var propertyName = itemPath.substring(lastSlashIndex + 1).replace(" ", " _"); | 242 var propertyName = itemPath.substring(lastSlashIndex + 1).replace(" ", " _"); |
241 var sources = WebInspector.DocumentationURLProvider._sources; | 243 var sources = WebInspector.DocumentationURLProvider._sources; |
242 for (var i = 0; i < sources.length; ++i) { | 244 for (var i = 0; i < sources.length; ++i) { |
243 if (sources[i].url() !== sourceName || !sources[i].source().hasOwnPr operty(propertyName)) | 245 if (sources[i].url() !== sourceName || !sources[i].source().hasOwnPr operty(propertyName) || this._inheritedFromFunction(sources[i].source(), propert yName)) |
244 continue; | 246 continue; |
245 var descriptors = this._articleList.get(propertyName) || []; | 247 var descriptors = this._articleList.get(propertyName) || []; |
246 descriptors.push(new WebInspector.DocumentationURLProvider.ItemDescr iptor(sources[i], propertyName)); | 248 descriptors.push(new WebInspector.DocumentationURLProvider.ItemDescr iptor(sources[i], propertyName)); |
247 this._articleList.set(propertyName, descriptors); | 249 this._articleList.set(propertyName, descriptors); |
248 } | 250 } |
251 }, | |
252 | |
253 /** | |
254 * FIXME: object parameter is not annotated property due to crbug.com/407097 | |
apavlov
2014/09/05 11:32:14
Typo: property->properly
semeny
2014/09/05 13:30:19
Done.
| |
255 * @param {*} object | |
256 * @param {string} propertyName | |
257 * @return {boolean} | |
258 */ | |
259 _inheritedFromFunction: function(object, propertyName) | |
260 { | |
261 return (object instanceof Function && object.hasOwnProperty(propertyName ) && Function.hasOwnProperty(propertyName)); | |
249 } | 262 } |
250 } | 263 } |
OLD | NEW |