Skip to content

Commit f988136

Browse files
scheglovCommit Queue
authored andcommitted
Elements. Migrate lib/src/computer/import_elements_computer.dart
Change-Id: I116786925a2a462f15cd757cb51e8da3ecdb247f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/399204 Reviewed-by: Phil Quitslund <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent 7811f8d commit f988136

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

pkg/analysis_server/analyzer_use_new_elements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ lib/src/cider/fixes.dart
44
lib/src/cider/rename.dart
55
lib/src/computer/computer_call_hierarchy.dart
66
lib/src/computer/computer_documentation.dart
7-
lib/src/computer/import_elements_computer.dart
87
lib/src/domains/analysis/implemented_dart.dart
98
lib/src/domains/analysis/occurrences_dart.dart
109
lib/src/handler/legacy/completion_get_suggestions2.dart

pkg/analysis_server/lib/src/computer/import_elements_computer.dart

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import 'package:analysis_server/protocol/protocol_generated.dart';
66
import 'package:analyzer/dart/analysis/results.dart';
77
import 'package:analyzer/dart/ast/ast.dart';
8-
import 'package:analyzer/dart/element/element.dart';
8+
import 'package:analyzer/dart/element/element2.dart';
99
import 'package:analyzer/file_system/file_system.dart';
1010
import 'package:analyzer/source/file_source.dart';
1111
import 'package:analyzer/source/source.dart';
@@ -37,7 +37,7 @@ class ImportElementsComputer {
3737
var filteredImportedElements = _filterImportedElements(
3838
importedElementsList,
3939
);
40-
var libraryElement = libraryResult.libraryElement;
40+
var libraryElement = libraryResult.libraryElement2;
4141
var uriConverter = libraryResult.session.uriConverter;
4242
var existingImports = <ImportDirective>[];
4343
for (var directive in unit.directives) {
@@ -342,7 +342,7 @@ class ImportElementsComputer {
342342
/// Computes the best URI to import [what] into [from].
343343
///
344344
/// Copied from DartFileEditBuilderImpl.
345-
String _getLibrarySourceUri(LibraryElement from, Source what) {
345+
String _getLibrarySourceUri(LibraryElement2 from, Source what) {
346346
var whatPath = what.fullName;
347347
// check if an absolute URI (such as 'dart:' or 'package:')
348348
var whatUri = what.uri;
@@ -352,38 +352,38 @@ class ImportElementsComputer {
352352
}
353353
// compute a relative URI
354354
var context = resourceProvider.pathContext;
355-
var fromFolder = context.dirname(from.source.fullName);
355+
var fromFolder = context.dirname(from.firstFragment.source.fullName);
356356
var relativeFile = context.relative(whatPath, from: fromFolder);
357357
return context.split(relativeFile).join('/');
358358
}
359359

360360
bool _hasElement(String prefix, String name) {
361-
var scope = libraryResult.libraryElement.definingCompilationUnit.scope;
361+
var scope = libraryResult.libraryElement2.firstFragment.scope;
362362

363363
if (prefix.isNotEmpty) {
364-
var prefixElement = scope.lookup(prefix).getter;
365-
if (prefixElement is PrefixElement) {
364+
var prefixElement = scope.lookup(prefix).getter2;
365+
if (prefixElement is PrefixElement2) {
366366
scope = prefixElement.scope;
367367
} else {
368368
return false;
369369
}
370370
}
371371

372372
var lookupResult = scope.lookup(name);
373-
return lookupResult.getter != null || lookupResult.setter != null;
373+
return lookupResult.getter2 != null || lookupResult.setter2 != null;
374374
}
375375

376376
/// Return `true` if the given [import] matches the given specification of
377377
/// [importedElements]. They will match if they import the same library using
378378
/// the same prefix.
379379
bool _matches(ImportDirective import, ImportedElements importedElements) {
380-
var importElement = import.element;
381-
if (importElement == null) {
380+
var libraryImport = import.libraryImport;
381+
if (libraryImport == null) {
382382
return false;
383383
}
384-
var library = importElement.importedLibrary;
384+
var library = libraryImport.importedLibrary2;
385385
return library != null &&
386-
library.source.fullName == importedElements.path &&
386+
library.firstFragment.source.fullName == importedElements.path &&
387387
(import.prefix?.name ?? '') == importedElements.prefix;
388388
}
389389
}

0 commit comments

Comments
 (0)