Skip to content

Commit

Permalink
Migrate bulk_fix_processor.dart
Browse files Browse the repository at this point in the history
Change-Id: I5385c0237d37ddf808609897dc846f100b11cd5e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/395703
Reviewed-by: Konstantin Shcheglov <[email protected]>
Commit-Queue: Brian Wilkerson <[email protected]>
  • Loading branch information
bwilkerson authored and Commit Queue committed Nov 16, 2024
1 parent 5c904c1 commit 73adec7
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
1 change: 0 additions & 1 deletion pkg/analysis_server/analyzer_use_new_elements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ lib/src/services/completion/dart/utilities.dart
lib/src/services/completion/dart/visibility_tracker.dart
lib/src/services/completion/postfix/postfix_completion.dart
lib/src/services/completion/statement/statement_completion.dart
lib/src/services/correction/bulk_fix_processor.dart
lib/src/services/correction/dart/add_extension_override.dart
lib/src/services/correction/dart/create_extension_member.dart
lib/src/services/correction/dart/import_library.dart
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -527,8 +527,8 @@ class BulkFixProcessor {
if (library is NotLibraryButPartResult) {
var unit = await context.currentSession.getResolvedUnit(path);
if (unit is ResolvedUnitResult) {
library = await context.currentSession.getResolvedLibraryByElement(
unit.libraryElement,
library = await context.currentSession.getResolvedLibraryByElement2(
unit.libraryElement2,
);
}
}
Expand Down
10 changes: 10 additions & 0 deletions pkg/analyzer/lib/dart/analysis/session.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import 'package:analyzer/dart/analysis/declared_variables.dart';
import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer/dart/analysis/uri_converter.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/element2.dart';
import 'package:analyzer/exception/exception.dart';
import 'package:analyzer/file_system/file_system.dart';
import 'package:meta/meta.dart';

/// A consistent view of the results of analyzing one or more files.
///
Expand Down Expand Up @@ -69,6 +71,14 @@ abstract class AnalysisSession {
Future<SomeResolvedLibraryResult> getResolvedLibraryByElement(
LibraryElement element);

/// Return a future that will complete with information about the results of
/// resolving all of the files in the library with the library [element].
///
/// Throw [ArgumentError] if the [element] was not produced by this session.
@experimental
Future<SomeResolvedLibraryResult> getResolvedLibraryByElement2(
LibraryElement2 element);

/// Return a future that will complete with information about the results of
/// resolving the file with the given absolute, normalized [path].
Future<SomeResolvedUnitResult> getResolvedUnit(String path);
Expand Down
14 changes: 14 additions & 0 deletions pkg/analyzer/lib/src/dart/analysis/session.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer/dart/analysis/session.dart';
import 'package:analyzer/dart/analysis/uri_converter.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/element2.dart';
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/src/dart/analysis/driver.dart' as driver;
import 'package:analyzer/src/dart/analysis/uri_converter.dart';
Expand Down Expand Up @@ -128,6 +129,19 @@ class AnalysisSessionImpl implements AnalysisSession {
return await _driver.getResolvedLibraryByUri(element.source.uri);
}

@override
Future<SomeResolvedLibraryResult> getResolvedLibraryByElement2(
LibraryElement2 element,
) async {
checkConsistency();

if (element.session != this) {
return NotElementOfThisSessionResult();
}

return await _driver.getResolvedLibraryByUri(element.uri);
}

@override
Future<SomeResolvedUnitResult> getResolvedUnit(String path) async {
checkConsistency();
Expand Down

0 comments on commit 73adec7

Please sign in to comment.