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 67 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) || []; | |
loislo
2014/09/09 09:10:14
this construction looks strange
| |
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
226 }, | 228 }, |
227 | 229 |
228 /** | 230 /** |
229 * @param {string} itemPath | 231 * @param {string} itemPath |
230 */ | 232 */ |
231 _addDescriptorToList: function(itemPath) | 233 _addDescriptorToList: function(itemPath) |
232 { | 234 { |
233 var lastSlashIndex = itemPath.lastIndexOf("/"); | 235 var lastSlashIndex = itemPath.lastIndexOf("/"); |
234 if (lastSlashIndex === -1) | 236 if (lastSlashIndex === -1) |
235 return; | 237 return; |
238 var sourceName = itemPath.substring(0, lastSlashIndex + 1); | |
236 // There are some properties which have several words in their name. | 239 // 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. | 240 // 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. | 241 // We are creating URL for current property, so we have to replace all t he gaps with underscores. |
239 var correctedItemPath = itemPath.replace(" ", "_"); | 242 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; | 243 var sources = WebInspector.DocumentationURLProvider._sources; |
243 for (var i = 0; i < sources.length; ++i) { | 244 for (var i = 0; i < sources.length; ++i) { |
244 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)) |
245 continue; | 246 continue; |
246 var descriptors = this._articleList.get(propertyName) || []; | 247 var descriptors = this._articleList.get(propertyName) || []; |
247 descriptors.push(new WebInspector.DocumentationURLProvider.ItemDescr iptor(sources[i], propertyName)); | 248 descriptors.push(new WebInspector.DocumentationURLProvider.ItemDescr iptor(sources[i], propertyName)); |
248 this._articleList.set(propertyName, descriptors); | 249 this._articleList.set(propertyName, descriptors); |
249 } | 250 } |
251 }, | |
252 | |
253 /** | |
254 * FIXME: object parameter is not annotated properly due to crbug.com/407097 | |
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)); | |
250 } | 262 } |
251 } | 263 } |
OLD | NEW |