| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 List libraryList; | 5 List libraryList; |
| 6 InputElement searchInput; | 6 InputElement searchInput; |
| 7 DivElement dropdown; | 7 DivElement dropdown; |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * Update the search drop down based on the current search text. | 10 * Update the search drop down based on the current search text. |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 String libraryName = library[NAME]; | 85 String libraryName = library[NAME]; |
| 86 if (library.containsKey(TYPES)) { | 86 if (library.containsKey(TYPES)) { |
| 87 for (Map<String,Dynamic> type in library[TYPES]) { | 87 for (Map<String,Dynamic> type in library[TYPES]) { |
| 88 String typeName = type[NAME]; | 88 String typeName = type[NAME]; |
| 89 if (type.containsKey(MEMBERS)) { | 89 if (type.containsKey(MEMBERS)) { |
| 90 for (Map<String,Dynamic> member in type[MEMBERS]) { | 90 for (Map<String,Dynamic> member in type[MEMBERS]) { |
| 91 StringMatch memberMatch = obtainMatch(searchText, member[NAME]); | 91 StringMatch memberMatch = obtainMatch(searchText, member[NAME]); |
| 92 if (memberMatch != null) { | 92 if (memberMatch != null) { |
| 93 results.add(new Result(memberMatch, member[KIND], | 93 results.add(new Result(memberMatch, member[KIND], |
| 94 getTypeMemberUrl(libraryName, typeName, member), | 94 getTypeMemberUrl(libraryName, typeName, member), |
| 95 library: libraryName, type: typeName, args: type[ARGS])); | 95 library: libraryName, type: typeName, args: type[ARGS], |
| 96 noargs: member[NO_PARAMS])); |
| 96 } | 97 } |
| 97 } | 98 } |
| 98 } | 99 } |
| 99 } | 100 } |
| 100 } | 101 } |
| 101 } | 102 } |
| 102 } | 103 } |
| 103 | 104 |
| 104 void matchAllMembersInType(List<Result> results, | 105 void matchAllMembersInType(List<Result> results, |
| 105 String typeText, String memberText) { | 106 String typeText, String memberText) { |
| 106 var searchText = new SearchText(typeText); | 107 var searchText = new SearchText(typeText); |
| 107 var emptyText = new SearchText(memberText); | 108 var emptyText = new SearchText(memberText); |
| 108 for (Map<String,Dynamic> library in libraryList) { | 109 for (Map<String,Dynamic> library in libraryList) { |
| 109 String libraryName = library[NAME]; | 110 String libraryName = library[NAME]; |
| 110 if (library.containsKey(TYPES)) { | 111 if (library.containsKey(TYPES)) { |
| 111 for (Map<String,Dynamic> type in library[TYPES]) { | 112 for (Map<String,Dynamic> type in library[TYPES]) { |
| 112 String typeName = type[NAME]; | 113 String typeName = type[NAME]; |
| 113 StringMatch typeMatch = obtainMatch(searchText, typeName); | 114 StringMatch typeMatch = obtainMatch(searchText, typeName); |
| 114 if (typeMatch != null) { | 115 if (typeMatch != null) { |
| 115 if (type.containsKey(MEMBERS)) { | 116 if (type.containsKey(MEMBERS)) { |
| 116 for (Map<String,Dynamic> member in type[MEMBERS]) { | 117 for (Map<String,Dynamic> member in type[MEMBERS]) { |
| 117 StringMatch memberMatch = obtainMatch(emptyText, | 118 StringMatch memberMatch = obtainMatch(emptyText, |
| 118 member[NAME]); | 119 member[NAME]); |
| 119 results.add(new Result(memberMatch, member[KIND], | 120 results.add(new Result(memberMatch, member[KIND], |
| 120 getTypeMemberUrl(libraryName, typeName, member), | 121 getTypeMemberUrl(libraryName, typeName, member), |
| 121 library: libraryName, prefix: typeMatch)); | 122 library: libraryName, prefix: typeMatch, |
| 123 noargs: member[NO_PARAMS])); |
| 122 } | 124 } |
| 123 } | 125 } |
| 124 } | 126 } |
| 125 } | 127 } |
| 126 } | 128 } |
| 127 } | 129 } |
| 128 } | 130 } |
| 129 | 131 |
| 130 void matchMembersInType(List<Result> results, | 132 void matchMembersInType(List<Result> results, |
| 131 String text, String typeText, String memberText) { | 133 String text, String typeText, String memberText) { |
| 132 var searchText = new SearchText(text); | 134 var searchText = new SearchText(text); |
| 133 var typeSearchText = new SearchText(typeText); | 135 var typeSearchText = new SearchText(typeText); |
| 134 var memberSearchText = new SearchText(memberText); | 136 var memberSearchText = new SearchText(memberText); |
| 135 for (Map<String,Dynamic> library in libraryList) { | 137 for (Map<String,Dynamic> library in libraryList) { |
| 136 String libraryName = library[NAME]; | 138 String libraryName = library[NAME]; |
| 137 if (library.containsKey(TYPES)) { | 139 if (library.containsKey(TYPES)) { |
| 138 for (Map<String,Dynamic> type in library[TYPES]) { | 140 for (Map<String,Dynamic> type in library[TYPES]) { |
| 139 String typeName = type[NAME]; | 141 String typeName = type[NAME]; |
| 140 StringMatch typeMatch = obtainMatch(typeSearchText, typeName); | 142 StringMatch typeMatch = obtainMatch(typeSearchText, typeName); |
| 141 if (typeMatch != null) { | 143 if (typeMatch != null) { |
| 142 if (type.containsKey(MEMBERS)) { | 144 if (type.containsKey(MEMBERS)) { |
| 143 for (Map<String,Dynamic> member in type[MEMBERS]) { | 145 for (Map<String,Dynamic> member in type[MEMBERS]) { |
| 144 // Check for constructor match. | 146 // Check for constructor match. |
| 145 StringMatch constructorMatch = obtainMatch(searchText, | 147 StringMatch constructorMatch = obtainMatch(searchText, |
| 146 member[NAME]); | 148 member[NAME]); |
| 147 if (constructorMatch != null) { | 149 if (constructorMatch != null) { |
| 148 results.add(new Result(constructorMatch, member[KIND], | 150 results.add(new Result(constructorMatch, member[KIND], |
| 149 getTypeMemberUrl(libraryName, typeName, member), | 151 getTypeMemberUrl(libraryName, typeName, member), |
| 150 library: libraryName)); | 152 library: libraryName, noargs: member[NO_PARAMS])); |
| 151 } else { | 153 } else { |
| 152 // Try member match. | 154 // Try member match. |
| 153 StringMatch memberMatch = obtainMatch(memberSearchText, | 155 StringMatch memberMatch = obtainMatch(memberSearchText, |
| 154 member[NAME]); | 156 member[NAME]); |
| 155 if (memberMatch != null) { | 157 if (memberMatch != null) { |
| 156 results.add(new Result(memberMatch, member[KIND], | 158 results.add(new Result(memberMatch, member[KIND], |
| 157 getTypeMemberUrl(libraryName, typeName, member), | 159 getTypeMemberUrl(libraryName, typeName, member), |
| 158 library: libraryName, prefix: typeMatch, | 160 library: libraryName, prefix: typeMatch, |
| 159 args: type[ARGS])); | 161 args: type[ARGS], noargs: member[NO_PARAMS])); |
| 160 } | 162 } |
| 161 } | 163 } |
| 162 } | 164 } |
| 163 } | 165 } |
| 164 } | 166 } |
| 165 } | 167 } |
| 166 } | 168 } |
| 167 } | 169 } |
| 168 } | 170 } |
| 169 | 171 |
| 170 void matchLibrary(List<Result> results, SearchText searchText, Map library) { | 172 void matchLibrary(List<Result> results, SearchText searchText, Map library) { |
| 171 String libraryName = library[NAME]; | 173 String libraryName = library[NAME]; |
| 172 StringMatch libraryMatch = obtainMatch(searchText, libraryName); | 174 StringMatch libraryMatch = obtainMatch(searchText, libraryName); |
| 173 if (libraryMatch != null) { | 175 if (libraryMatch != null) { |
| 174 results.add(new Result(libraryMatch, LIBRARY, | 176 results.add(new Result(libraryMatch, LIBRARY, |
| 175 getLibraryUrl(libraryName))); | 177 getLibraryUrl(libraryName))); |
| 176 } | 178 } |
| 177 } | 179 } |
| 178 | 180 |
| 179 void matchLibraryMembers(List<Result> results, SearchText searchText, | 181 void matchLibraryMembers(List<Result> results, SearchText searchText, |
| 180 Map library) { | 182 Map library) { |
| 181 if (library.containsKey(MEMBERS)) { | 183 if (library.containsKey(MEMBERS)) { |
| 182 String libraryName = library[NAME]; | 184 String libraryName = library[NAME]; |
| 183 for (Map<String,Dynamic> member in library[MEMBERS]) { | 185 for (Map<String,Dynamic> member in library[MEMBERS]) { |
| 184 StringMatch memberMatch = obtainMatch(searchText, member[NAME]); | 186 StringMatch memberMatch = obtainMatch(searchText, member[NAME]); |
| 185 if (memberMatch != null) { | 187 if (memberMatch != null) { |
| 186 results.add(new Result(memberMatch, member[KIND], | 188 results.add(new Result(memberMatch, member[KIND], |
| 187 getLibraryMemberUrl(libraryName, member), | 189 getLibraryMemberUrl(libraryName, member), |
| 188 library: libraryName)); | 190 library: libraryName, noargs: member[NO_PARAMS]))
; |
| 189 } | 191 } |
| 190 } | 192 } |
| 191 } | 193 } |
| 192 } | 194 } |
| 193 | 195 |
| 194 void matchTypes(List<Result> results, SearchText searchText, | 196 void matchTypes(List<Result> results, SearchText searchText, |
| 195 Map library) { | 197 Map library) { |
| 196 if (library.containsKey(TYPES)) { | 198 if (library.containsKey(TYPES)) { |
| 197 String libraryName = library[NAME]; | 199 String libraryName = library[NAME]; |
| 198 for (Map<String,Dynamic> type in library[TYPES]) { | 200 for (Map<String,Dynamic> type in library[TYPES]) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 216 | 218 |
| 217 void matchTypeMembers(List<Result> results, SearchText searchText, | 219 void matchTypeMembers(List<Result> results, SearchText searchText, |
| 218 String libraryName, Map type) { | 220 String libraryName, Map type) { |
| 219 if (type.containsKey(MEMBERS)) { | 221 if (type.containsKey(MEMBERS)) { |
| 220 String typeName = type[NAME]; | 222 String typeName = type[NAME]; |
| 221 for (Map<String,Dynamic> member in type[MEMBERS]) { | 223 for (Map<String,Dynamic> member in type[MEMBERS]) { |
| 222 StringMatch memberMatch = obtainMatch(searchText, member[NAME]); | 224 StringMatch memberMatch = obtainMatch(searchText, member[NAME]); |
| 223 if (memberMatch != null) { | 225 if (memberMatch != null) { |
| 224 results.add(new Result(memberMatch, member[KIND], | 226 results.add(new Result(memberMatch, member[KIND], |
| 225 getTypeMemberUrl(libraryName, typeName, member), | 227 getTypeMemberUrl(libraryName, typeName, member), |
| 226 library: libraryName, type: typeName, args: type[ARGS])); | 228 library: libraryName, type: typeName, args: type[ARGS], |
| 229 noargs: member[NO_PARAMS])); |
| 227 } | 230 } |
| 228 } | 231 } |
| 229 } | 232 } |
| 230 } | 233 } |
| 231 | 234 |
| 232 String currentSearchText; | 235 String currentSearchText; |
| 233 Result _currentResult; | 236 Result _currentResult; |
| 234 List<Result> currentResults = const <Result>[]; | 237 List<Result> currentResults = const <Result>[]; |
| 235 | 238 |
| 236 void updateResults(String searchText, List<Result> results) { | 239 void updateResults(String searchText, List<Result> results) { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 dropdown = query('#drop-down'); | 338 dropdown = query('#drop-down'); |
| 336 | 339 |
| 337 searchInput.on.keyDown.add(handleUpDown); | 340 searchInput.on.keyDown.add(handleUpDown); |
| 338 searchInput.on.keyUp.add(updateDropDown); | 341 searchInput.on.keyUp.add(updateDropDown); |
| 339 searchInput.on.change.add(updateDropDown); | 342 searchInput.on.change.add(updateDropDown); |
| 340 searchInput.on.reset.add(updateDropDown); | 343 searchInput.on.reset.add(updateDropDown); |
| 341 searchInput.on.focus.add((event) => showDropDown()); | 344 searchInput.on.focus.add((event) => showDropDown()); |
| 342 searchInput.on.blur.add((event) => hideDropDown()); | 345 searchInput.on.blur.add((event) => hideDropDown()); |
| 343 window.on.keyDown.add(shortcutHandler); | 346 window.on.keyDown.add(shortcutHandler); |
| 344 } | 347 } |
| OLD | NEW |