OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 import 'package:analysis_server/src/services/index2/index2.dart'; | 5 import 'package:analysis_server/src/services/index2/index2.dart'; |
6 import 'package:analyzer/dart/ast/ast.dart'; | 6 import 'package:analyzer/dart/ast/ast.dart'; |
7 import 'package:analyzer/dart/element/element.dart'; | 7 import 'package:analyzer/dart/element/element.dart'; |
8 import 'package:analyzer/src/generated/source.dart'; | 8 import 'package:analyzer/src/generated/source.dart'; |
9 import 'package:analyzer/src/summary/idl.dart'; | 9 import 'package:analyzer/src/summary/idl.dart'; |
10 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 10 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 * Assert that the given list of [locations] has a [Location] corresponding | 152 * Assert that the given list of [locations] has a [Location] corresponding |
153 * to the [element]. | 153 * to the [element]. |
154 */ | 154 */ |
155 void _assertHasDefinedName(List<Location> locations, Element element) { | 155 void _assertHasDefinedName(List<Location> locations, Element element) { |
156 String libraryUri = element.library.source.uri.toString(); | 156 String libraryUri = element.library.source.uri.toString(); |
157 String unitUri = element.source.uri.toString(); | 157 String unitUri = element.source.uri.toString(); |
158 for (Location location in locations) { | 158 for (Location location in locations) { |
159 if (location.libraryUri == libraryUri && | 159 if (location.libraryUri == libraryUri && |
160 location.unitUri == unitUri && | 160 location.unitUri == unitUri && |
161 location.offset == element.nameOffset && | 161 location.offset == element.nameOffset && |
162 location.length == 0) { | 162 location.length == element.nameLength) { |
163 return; | 163 return; |
164 } | 164 } |
165 } | 165 } |
166 fail('No declaration of $element at ${element.nameOffset} in\n' | 166 fail('No declaration of $element at ${element.nameOffset} in\n' |
167 '${locations.join('\n')}'); | 167 '${locations.join('\n')}'); |
168 } | 168 } |
169 | 169 |
170 void _indexTestUnit(String code) { | 170 void _indexTestUnit(String code) { |
171 resolveTestUnit(code); | 171 resolveTestUnit(code); |
172 index.indexUnit(testUnit); | 172 index.indexUnit(testUnit); |
173 } | 173 } |
174 | 174 |
175 Source _indexUnit(String path, String code) { | 175 Source _indexUnit(String path, String code) { |
176 Source source = addSource(path, code); | 176 Source source = addSource(path, code); |
177 CompilationUnit unit = resolveLibraryUnit(source); | 177 CompilationUnit unit = resolveLibraryUnit(source); |
178 index.indexUnit(unit); | 178 index.indexUnit(unit); |
179 return source; | 179 return source; |
180 } | 180 } |
181 } | 181 } |
OLD | NEW |