Skip to content

Commit 5899918

Browse files
scheglovCommit Queue
authored andcommitted
Elements. Migrate ImportAnalyzer and its tests.
Change-Id: Ief9f299769000f4fb6b23354e58c68b2579b0518 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391302 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]> Reviewed-by: Phil Quitslund <[email protected]>
1 parent f65f719 commit 5899918

File tree

5 files changed

+214
-183
lines changed

5 files changed

+214
-183
lines changed

pkg/analysis_server/analyzer_use_new_elements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,7 @@ lib/src/utilities/extensions/range_factory.dart
574574
lib/src/utilities/extensions/string.dart
575575
lib/src/utilities/extensions/yaml.dart
576576
lib/src/utilities/file_string_sink.dart
577+
lib/src/utilities/import_analyzer.dart
577578
lib/src/utilities/index_range.dart
578579
lib/src/utilities/mocks.dart
579580
lib/src/utilities/null_string_sink.dart
@@ -1454,6 +1455,7 @@ test/src/utilities/extensions/ast_test.dart
14541455
test/src/utilities/extensions/range_factory_test.dart
14551456
test/src/utilities/extensions/string_test.dart
14561457
test/src/utilities/extensions/test_all.dart
1458+
test/src/utilities/import_analyzer_test.dart
14571459
test/src/utilities/json_test.dart
14581460
test/src/utilities/profiling_test.dart
14591461
test/src/utilities/selection_test.dart

pkg/analysis_server/lib/src/services/refactoring/move_top_level_to_file.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import 'package:analyzer/dart/ast/token.dart';
1212
import 'package:analyzer/dart/element/element.dart';
1313
import 'package:analyzer/source/line_info.dart';
1414
import 'package:analyzer/source/source_range.dart';
15+
import 'package:analyzer/src/utilities/extensions/element.dart';
1516
import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart';
1617
import 'package:analyzer_plugin/utilities/change_builder/change_builder_dart.dart';
1718
import 'package:analyzer_plugin/utilities/range_factory.dart';
@@ -139,7 +140,8 @@ class MoveTopLevelToFile extends RefactoringProducer {
139140
}
140141
});
141142
var libraries = <LibraryElement, Set<Element>>{};
142-
for (var element in analyzer.movingDeclarations) {
143+
for (var element2 in analyzer.movingDeclarations) {
144+
var element = element2.asElement!;
143145
var matches = await searchEngine.searchReferences(element);
144146
for (var match in matches) {
145147
if (match.isResolved) {
@@ -190,15 +192,15 @@ class MoveTopLevelToFile extends RefactoringProducer {
190192
var element = entry.key;
191193
var imports = entry.value;
192194
for (var import in imports) {
193-
var library = import.importedLibrary;
195+
var library = import.importedLibrary2;
194196
if (library == null || library.isDartCore) {
195197
continue;
196198
}
197199
var hasShowCombinator =
198200
import.combinators.whereType<ShowElementCombinator>().isNotEmpty;
199201
builder.importLibrary(
200-
library.source.uri,
201-
prefix: import.prefix?.element.name,
202+
library.firstFragment.source.uri,
203+
prefix: import.prefix2?.element.name,
202204
showName: element.name,
203205
useShow: hasShowCombinator,
204206
);

0 commit comments

Comments
 (0)