Version 2.14.0-308.0.dev
Merge commit 'dcec42f0b56fdcfc9237192f9b3758e82a5be2dc' into 'dev'
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 7687b1d..66ade81 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -109,14 +109,14 @@
utils = imp.load_source('utils',
os.path.join(local_root, 'tools', 'utils.py'))
- prebuilt_dartfmt = os.path.join(utils.CheckedInSdkPath(), 'bin', 'dartfmt')
+ dart = os.path.join(utils.CheckedInSdkPath(), 'bin', 'dart')
windows = utils.GuessOS() == 'win32'
if windows:
- prebuilt_dartfmt += '.bat'
+ dart += '.exe'
- if not os.path.isfile(prebuilt_dartfmt):
- print('WARNING: dartfmt not found: %s' % (prebuilt_dartfmt))
+ if not os.path.isfile(dart):
+ print('WARNING: dart not found: %s' % (dart))
return []
def HasFormatErrors(filename=None, contents=None):
@@ -129,9 +129,17 @@
if '//#' in contents:
return False
- args = [prebuilt_dartfmt, '--set-exit-if-changed']
+ args = [
+ dart,
+ 'format',
+ '--set-exit-if-changed',
+ ]
if not contents:
- args += [filename, '-n']
+ args += [
+ '--output=none',
+ '--summary=none',
+ filename,
+ ]
process = subprocess.Popen(
args, stdout=subprocess.PIPE, stdin=subprocess.PIPE)
@@ -143,7 +151,7 @@
# parsed and formatted. Don't treat those as errors.
return process.returncode == 1
- unformatted_files = _CheckFormat(input_api, "dartfmt", ".dart", windows,
+ unformatted_files = _CheckFormat(input_api, "dart format", ".dart", windows,
HasFormatErrors)
if unformatted_files:
diff --git a/benchmarks/SDKArtifactSizes/dart/SDKArtifactSizes.dart b/benchmarks/SDKArtifactSizes/dart/SDKArtifactSizes.dart
index 1130ac6..ece1bcc 100644
--- a/benchmarks/SDKArtifactSizes/dart/SDKArtifactSizes.dart
+++ b/benchmarks/SDKArtifactSizes/dart/SDKArtifactSizes.dart
@@ -34,8 +34,13 @@
];
Future<void> reportArtifactSize(String path, String name) async {
- final size = await File(path).length();
- print('SDKArtifactSizes.$name(CodeSize): $size');
+ try {
+ final size = await File(path).length();
+ print('SDKArtifactSizes.$name(CodeSize): $size');
+ } on FileSystemException {
+ // Report dummy data for artifacts that don't exist for specific platforms.
+ print('SDKArtifactSizes.$name(CodeSize): 0');
+ }
}
Future<void> main() async {
diff --git a/benchmarks/SDKArtifactSizes/dart2/SDKArtifactSizes.dart b/benchmarks/SDKArtifactSizes/dart2/SDKArtifactSizes.dart
index 1130ac6..ece1bcc 100644
--- a/benchmarks/SDKArtifactSizes/dart2/SDKArtifactSizes.dart
+++ b/benchmarks/SDKArtifactSizes/dart2/SDKArtifactSizes.dart
@@ -34,8 +34,13 @@
];
Future<void> reportArtifactSize(String path, String name) async {
- final size = await File(path).length();
- print('SDKArtifactSizes.$name(CodeSize): $size');
+ try {
+ final size = await File(path).length();
+ print('SDKArtifactSizes.$name(CodeSize): $size');
+ } on FileSystemException {
+ // Report dummy data for artifacts that don't exist for specific platforms.
+ print('SDKArtifactSizes.$name(CodeSize): 0');
+ }
}
Future<void> main() async {
diff --git a/pkg/analysis_server/lib/src/analysis_server_abstract.dart b/pkg/analysis_server/lib/src/analysis_server_abstract.dart
index 616bf9d..6a351b1 100644
--- a/pkg/analysis_server/lib/src/analysis_server_abstract.dart
+++ b/pkg/analysis_server/lib/src/analysis_server_abstract.dart
@@ -380,7 +380,7 @@
}
var session = getAnalysisDriver(path)?.currentSession;
- var result = session?.getParsedUnit2(path);
+ var result = session?.getParsedUnit(path);
return result is ParsedUnitResult ? result : null;
}
diff --git a/pkg/analysis_server/lib/src/lsp/handlers/handler_completion_resolve.dart b/pkg/analysis_server/lib/src/lsp/handlers/handler_completion_resolve.dart
index 1463107..30935d6 100644
--- a/pkg/analysis_server/lib/src/lsp/handlers/handler_completion_resolve.dart
+++ b/pkg/analysis_server/lib/src/lsp/handlers/handler_completion_resolve.dart
@@ -111,7 +111,7 @@
analyzer.LibraryElement requestedLibraryElement;
{
- final result = await session.getLibraryByUri2(library.uriStr);
+ final result = await session.getLibraryByUri(library.uriStr);
if (result is LibraryElementResult) {
requestedLibraryElement = result.element;
} else {
diff --git a/pkg/analysis_server/lib/src/services/correction/bulk_fix_processor.dart b/pkg/analysis_server/lib/src/services/correction/bulk_fix_processor.dart
index 097765f..e2539fa 100644
--- a/pkg/analysis_server/lib/src/services/correction/bulk_fix_processor.dart
+++ b/pkg/analysis_server/lib/src/services/correction/bulk_fix_processor.dart
@@ -172,7 +172,7 @@
file_paths.isGenerated(path)) {
continue;
}
- var library = await context.currentSession.getResolvedLibrary2(path);
+ var library = await context.currentSession.getResolvedLibrary(path);
if (library is ResolvedLibraryResult) {
await _fixErrorsInLibrary(library);
}
@@ -269,7 +269,7 @@
/// library associated with the analysis [result].
Future<void> _fixErrorsInLibrary(ResolvedLibraryResult result) async {
var analysisOptions = result.session.analysisContext.analysisOptions;
- for (var unitResult in result.units!) {
+ for (var unitResult in result.units) {
var overrideSet = _readOverrideSet(unitResult);
for (var error in unitResult.errors) {
var processor = ErrorProcessor.getProcessor(analysisOptions, error);
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/create_method.dart b/pkg/analysis_server/lib/src/services/correction/dart/create_method.dart
index 2f320ef..9009561 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/create_method.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/create_method.dart
@@ -154,7 +154,7 @@
// use different utils
var targetPath = targetClassElement.source.fullName;
var targetResolveResult =
- await resolvedResult.session.getResolvedUnit2(targetPath);
+ await resolvedResult.session.getResolvedUnit(targetPath);
if (targetResolveResult is! ResolvedUnitResult) {
return;
}
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/import_library.dart b/pkg/analysis_server/lib/src/services/correction/dart/import_library.dart
index 69137bf..00b0dd7d 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/import_library.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/import_library.dart
@@ -450,7 +450,7 @@
@override
Future<void> compute(ChangeBuilder builder) async {
- var result = await sessionHelper.session.getLibraryByUri2(uri.toString());
+ var result = await sessionHelper.session.getLibraryByUri(uri.toString());
if (result is LibraryElementResult) {
var library = result.element;
if (library
diff --git a/pkg/analysis_server/lib/src/services/correction/util.dart b/pkg/analysis_server/lib/src/services/correction/util.dart
index 7259632..57ffe36 100644
--- a/pkg/analysis_server/lib/src/services/correction/util.dart
+++ b/pkg/analysis_server/lib/src/services/correction/util.dart
@@ -37,7 +37,7 @@
LibraryElement targetLibrary, Set<Source> libraries) async {
var libraryPath = targetLibrary.source.fullName;
- var resolveResult = await session.getResolvedUnit2(libraryPath);
+ var resolveResult = await session.getResolvedUnit(libraryPath);
if (resolveResult is! ResolvedUnitResult) {
return;
}
diff --git a/pkg/analysis_server/lib/src/services/refactoring/move_file.dart b/pkg/analysis_server/lib/src/services/refactoring/move_file.dart
index 1fcf8cb..1c259a4 100644
--- a/pkg/analysis_server/lib/src/services/refactoring/move_file.dart
+++ b/pkg/analysis_server/lib/src/services/refactoring/move_file.dart
@@ -85,12 +85,12 @@
if (element == libraryElement.definingCompilationUnit) {
// Handle part-of directives in this library
var libraryResult = await driver.currentSession
- .getResolvedLibraryByElement2(libraryElement);
+ .getResolvedLibraryByElement(libraryElement);
if (libraryResult is! ResolvedLibraryResult) {
return changeBuilder.sourceChange;
}
- var definingUnitResult = libraryResult.units!.first;
- for (var result in libraryResult.units!) {
+ var definingUnitResult = libraryResult.units.first;
+ for (var result in libraryResult.units) {
if (result.isPart) {
var partOfs = result.unit!.directives
.whereType<PartOfDirective>()
diff --git a/pkg/analysis_server/lib/src/services/refactoring/rename_import.dart b/pkg/analysis_server/lib/src/services/refactoring/rename_import.dart
index 2dfbd42..4042b04 100644
--- a/pkg/analysis_server/lib/src/services/refactoring/rename_import.dart
+++ b/pkg/analysis_server/lib/src/services/refactoring/rename_import.dart
@@ -108,7 +108,7 @@
ImportDirective? _findNode() {
var library = element.library;
var path = library.source.fullName;
- var unitResult = session.getParsedUnit2(path);
+ var unitResult = session.getParsedUnit(path);
if (unitResult is! ParsedUnitResult) {
return null;
}
@@ -122,7 +122,7 @@
/// it. Otherwise return `null`.
SimpleIdentifier? _getInterpolationIdentifier(SourceReference reference) {
var source = reference.element.source!;
- var unitResult = session.getParsedUnit2(source.fullName);
+ var unitResult = session.getParsedUnit(source.fullName);
if (unitResult is! ParsedUnitResult) {
return null;
}
diff --git a/pkg/analysis_server/test/abstract_context.dart b/pkg/analysis_server/test/abstract_context.dart
index f628981..fb9d441 100644
--- a/pkg/analysis_server/test/abstract_context.dart
+++ b/pkg/analysis_server/test/abstract_context.dart
@@ -90,7 +90,7 @@
var analysisContext = contextFor(testPackageRootPath);
var files = analysisContext.contextRoot.analyzedFiles().toList();
for (var path in files) {
- await analysisContext.currentSession.getResolvedUnit2(path);
+ await analysisContext.currentSession.getResolvedUnit(path);
}
}
@@ -172,7 +172,7 @@
Future<ResolvedUnitResult> resolveFile(String path) async {
path = convertPath(path);
var session = contextFor(path).currentSession;
- return await session.getResolvedUnit2(path) as ResolvedUnitResult;
+ return await session.getResolvedUnit(path) as ResolvedUnitResult;
}
@mustCallSuper
diff --git a/pkg/analysis_server/test/abstract_single_unit.dart b/pkg/analysis_server/test/abstract_single_unit.dart
index e479d9c..5323a57 100644
--- a/pkg/analysis_server/test/abstract_single_unit.dart
+++ b/pkg/analysis_server/test/abstract_single_unit.dart
@@ -70,7 +70,7 @@
}
Future<void> resolveTestFile() async {
- var result = await session.getResolvedUnit2(testFile) as ResolvedUnitResult;
+ var result = await session.getResolvedUnit(testFile) as ResolvedUnitResult;
testAnalysisResult = result;
testCode = result.content!;
testUnit = result.unit!;
diff --git a/pkg/analysis_server/test/services/completion/dart/completion_contributor_util.dart b/pkg/analysis_server/test/services/completion/dart/completion_contributor_util.dart
index 0a651c2..546faf8 100644
--- a/pkg/analysis_server/test/services/completion/dart/completion_contributor_util.dart
+++ b/pkg/analysis_server/test/services/completion/dart/completion_contributor_util.dart
@@ -536,7 +536,7 @@
DartCompletionRequest request);
Future computeSuggestions({int times = 200}) async {
- result = await session.getResolvedUnit2(testFile) as ResolvedUnitResult;
+ result = await session.getResolvedUnit(testFile) as ResolvedUnitResult;
var baseRequest = CompletionRequestImpl(
result, completionOffset, CompletionPerformance());
diff --git a/pkg/analysis_server/test/services/completion/dart/completion_manager_test.dart b/pkg/analysis_server/test/services/completion/dart/completion_manager_test.dart
index 4dd13ee..257fb5b 100644
--- a/pkg/analysis_server/test/services/completion/dart/completion_manager_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/completion_manager_test.dart
@@ -50,7 +50,7 @@
// Build the request
var baseRequest = CompletionRequestImpl(
- await session.getResolvedUnit2(testFile) as ResolvedUnitResult,
+ await session.getResolvedUnit(testFile) as ResolvedUnitResult,
completionOffset,
CompletionPerformance());
await baseRequest.performance.runRequestOperation((performance) async {
diff --git a/pkg/analysis_server/test/services/correction/organize_directives_test.dart b/pkg/analysis_server/test/services/correction/organize_directives_test.dart
index a147a80..8681ccb 100644
--- a/pkg/analysis_server/test/services/correction/organize_directives_test.dart
+++ b/pkg/analysis_server/test/services/correction/organize_directives_test.dart
@@ -582,7 +582,7 @@
Future<void> _computeUnitAndErrors(String code) async {
addTestSource(code);
- var result = await session.getResolvedUnit2(testFile) as ResolvedUnitResult;
+ var result = await session.getResolvedUnit(testFile) as ResolvedUnitResult;
testUnit = result.unit!;
testErrors = result.errors;
}
diff --git a/pkg/analysis_server/test/services/correction/sort_members_test.dart b/pkg/analysis_server/test/services/correction/sort_members_test.dart
index a766800..e434168 100644
--- a/pkg/analysis_server/test/services/correction/sort_members_test.dart
+++ b/pkg/analysis_server/test/services/correction/sort_members_test.dart
@@ -925,7 +925,7 @@
Future<void> _parseTestUnit(String code) async {
addTestSource(code);
- var result = session.getParsedUnit2(testFile) as ParsedUnitResult;
+ var result = session.getParsedUnit(testFile) as ParsedUnitResult;
testUnit = result.unit;
}
}
diff --git a/pkg/analysis_server/test/services/refactoring/move_file_test.dart b/pkg/analysis_server/test/services/refactoring/move_file_test.dart
index ad4b7ef..5094b24 100644
--- a/pkg/analysis_server/test/services/refactoring/move_file_test.dart
+++ b/pkg/analysis_server/test/services/refactoring/move_file_test.dart
@@ -67,7 +67,7 @@
// testAnalysisResult manually here, the path is referenced through the
// referenced File object to run on Windows:
testAnalysisResult =
- await session.getResolvedUnit2(file.path) as ResolvedUnitResult;
+ await session.getResolvedUnit(file.path) as ResolvedUnitResult;
_createRefactoring('/home/test/lib/222/new_name.dart', oldFile: file.path);
await _assertSuccessfulRefactoring();
@@ -90,7 +90,7 @@
// testAnalysisResult manually here, the path is referenced through the
// referenced File object to run on Windows:
testAnalysisResult =
- await session.getResolvedUnit2(file.path) as ResolvedUnitResult;
+ await session.getResolvedUnit(file.path) as ResolvedUnitResult;
_createRefactoring('/home/test0/test1/test3/lib/111/name.dart',
oldFile: file.path);
@@ -114,7 +114,7 @@
// testAnalysisResult manually here, the path is referenced through the
// referenced File object to run on Windows:
testAnalysisResult =
- await session.getResolvedUnit2(file.path) as ResolvedUnitResult;
+ await session.getResolvedUnit(file.path) as ResolvedUnitResult;
_createRefactoring('/home/test0/test1/test2/test3/lib/111/name.dart',
oldFile: file.path);
@@ -138,7 +138,7 @@
// testAnalysisResult manually here, the path is referenced through the
// referenced File object to run on Windows:
testAnalysisResult =
- await session.getResolvedUnit2(file.path) as ResolvedUnitResult;
+ await session.getResolvedUnit(file.path) as ResolvedUnitResult;
_createRefactoring('/home/test0/test1/lib/111/name.dart',
oldFile: file.path);
@@ -160,7 +160,7 @@
// testAnalysisResult manually here, the path is referenced through the
// referenced File object to run on Windows:
testAnalysisResult =
- await session.getResolvedUnit2(file.path) as ResolvedUnitResult;
+ await session.getResolvedUnit(file.path) as ResolvedUnitResult;
_createRefactoring('/home/test/lib/222/new_name.dart', oldFile: file.path);
await _assertSuccessfulRefactoring();
@@ -181,7 +181,7 @@
// testAnalysisResult manually here, the path is referenced through the
// referenced File object to run on Windows:
testAnalysisResult =
- await session.getResolvedUnit2(file.path) as ResolvedUnitResult;
+ await session.getResolvedUnit(file.path) as ResolvedUnitResult;
_createRefactoring('/home/test/lib/new_name.dart', oldFile: file.path);
await _assertSuccessfulRefactoring();
diff --git a/pkg/analysis_server/test/src/computer/closing_labels_computer_test.dart b/pkg/analysis_server/test/src/computer/closing_labels_computer_test.dart
index 37057d0..5e39f9a 100644
--- a/pkg/analysis_server/test/src/computer/closing_labels_computer_test.dart
+++ b/pkg/analysis_server/test/src/computer/closing_labels_computer_test.dart
@@ -398,7 +398,7 @@
Future<List<ClosingLabel>> _computeElements(String sourceContent) async {
newFile(sourcePath, content: sourceContent);
var result =
- await session.getResolvedUnit2(sourcePath) as ResolvedUnitResult;
+ await session.getResolvedUnit(sourcePath) as ResolvedUnitResult;
var computer = DartUnitClosingLabelsComputer(result.lineInfo, result.unit!);
return computer.compute();
}
diff --git a/pkg/analysis_server/test/src/computer/folding_computer_test.dart b/pkg/analysis_server/test/src/computer/folding_computer_test.dart
index 62e7ad9..e6084a0 100644
--- a/pkg/analysis_server/test/src/computer/folding_computer_test.dart
+++ b/pkg/analysis_server/test/src/computer/folding_computer_test.dart
@@ -582,7 +582,7 @@
Future<List<FoldingRegion>> _computeRegions(String sourceContent) async {
newFile(sourcePath, content: sourceContent);
var result =
- await session.getResolvedUnit2(sourcePath) as ResolvedUnitResult;
+ await session.getResolvedUnit(sourcePath) as ResolvedUnitResult;
var computer = DartUnitFoldingComputer(result.lineInfo, result.unit!);
return computer.compute();
}
diff --git a/pkg/analysis_server/test/src/computer/highlights_computer_test.dart b/pkg/analysis_server/test/src/computer/highlights_computer_test.dart
index 2012268..145950d 100644
--- a/pkg/analysis_server/test/src/computer/highlights_computer_test.dart
+++ b/pkg/analysis_server/test/src/computer/highlights_computer_test.dart
@@ -114,7 +114,7 @@
this.content = content;
newFile(sourcePath, content: content);
var result =
- await session.getResolvedUnit2(sourcePath) as ResolvedUnitResult;
+ await session.getResolvedUnit(sourcePath) as ResolvedUnitResult;
if (hasErrors) {
expect(result.errors, isNotEmpty);
diff --git a/pkg/analysis_server/test/src/computer/import_elements_computer_test.dart b/pkg/analysis_server/test/src/computer/import_elements_computer_test.dart
index ebdde35..fed52b7 100644
--- a/pkg/analysis_server/test/src/computer/import_elements_computer_test.dart
+++ b/pkg/analysis_server/test/src/computer/import_elements_computer_test.dart
@@ -50,7 +50,7 @@
Future<void> createBuilder(String content) async {
originalContent = content;
newFile(path, content: content);
- var result = await session.getResolvedUnit2(path) as ResolvedUnitResult;
+ var result = await session.getResolvedUnit(path) as ResolvedUnitResult;
computer = ImportElementsComputer(resourceProvider, result);
}
diff --git a/pkg/analysis_server/test/src/computer/imported_elements_computer_test.dart b/pkg/analysis_server/test/src/computer/imported_elements_computer_test.dart
index 2cd24c1..3448803 100644
--- a/pkg/analysis_server/test/src/computer/imported_elements_computer_test.dart
+++ b/pkg/analysis_server/test/src/computer/imported_elements_computer_test.dart
@@ -471,7 +471,7 @@
// TODO(brianwilkerson) Automatically extract the selection from the content.
newFile(sourcePath, content: content);
var result =
- await session.getResolvedUnit2(sourcePath) as ResolvedUnitResult;
+ await session.getResolvedUnit(sourcePath) as ResolvedUnitResult;
var computer = ImportedElementsComputer(
result.unit!, content.indexOf(selection), selection.length);
importedElements = computer.compute();
diff --git a/pkg/analysis_server/test/src/computer/outline_computer_test.dart b/pkg/analysis_server/test/src/computer/outline_computer_test.dart
index 6db141d..a005ff2 100644
--- a/pkg/analysis_server/test/src/computer/outline_computer_test.dart
+++ b/pkg/analysis_server/test/src/computer/outline_computer_test.dart
@@ -32,7 +32,7 @@
testCode = code;
newFile(testPath, content: code);
var resolveResult =
- await session.getResolvedUnit2(testPath) as ResolvedUnitResult;
+ await session.getResolvedUnit(testPath) as ResolvedUnitResult;
return DartUnitOutlineComputer(
resolveResult,
withBasicFlutter: true,
diff --git a/pkg/analysis_server/test/src/computer/selection_range_computer_test.dart b/pkg/analysis_server/test/src/computer/selection_range_computer_test.dart
index cbb6cf8..603b7b6 100644
--- a/pkg/analysis_server/test/src/computer/selection_range_computer_test.dart
+++ b/pkg/analysis_server/test/src/computer/selection_range_computer_test.dart
@@ -194,7 +194,7 @@
String sourceContent, int offset) async {
newFile(sourcePath, content: sourceContent);
var result =
- await session.getResolvedUnit2(sourcePath) as ResolvedUnitResult;
+ await session.getResolvedUnit(sourcePath) as ResolvedUnitResult;
var computer = DartSelectionRangeComputer(result.unit!, offset);
return computer.compute();
}
diff --git a/pkg/analysis_server/test/src/flutter/flutter_outline_computer_test.dart b/pkg/analysis_server/test/src/flutter/flutter_outline_computer_test.dart
index f186301..c224c12 100644
--- a/pkg/analysis_server/test/src/flutter/flutter_outline_computer_test.dart
+++ b/pkg/analysis_server/test/src/flutter/flutter_outline_computer_test.dart
@@ -517,7 +517,7 @@
testCode = code;
newFile(testPath, content: code);
resolveResult =
- await session.getResolvedUnit2(testPath) as ResolvedUnitResult;
+ await session.getResolvedUnit(testPath) as ResolvedUnitResult;
computer = FlutterOutlineComputer(resolveResult);
return computer.compute();
}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/data_driven/transform_set_manager_test.dart b/pkg/analysis_server/test/src/services/correction/fix/data_driven/transform_set_manager_test.dart
index d182ab1..42d762b 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/data_driven/transform_set_manager_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/data_driven/transform_set_manager_test.dart
@@ -36,7 +36,7 @@
var testFile = convertPath('/home/test/lib/test.dart');
addSource(testFile, '');
var result = await session.getResolvedLibraryValid(testFile);
- var sets = manager.forLibrary(result.element!);
+ var sets = manager.forLibrary(result.element);
expect(sets, hasLength(2));
}
@@ -47,7 +47,7 @@
var testFile = convertPath('/home/test/lib/test.dart');
addSource(testFile, '');
var result = await session.getResolvedLibraryValid(testFile);
- var sets = manager.forLibrary(result.element!);
+ var sets = manager.forLibrary(result.element);
expect(sets, hasLength(0));
}
@@ -70,6 +70,6 @@
extension on AnalysisSession {
Future<ResolvedLibraryResult> getResolvedLibraryValid(String path) async {
- return await getResolvedLibrary2(path) as ResolvedLibraryResult;
+ return await getResolvedLibrary(path) as ResolvedLibraryResult;
}
}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/fix_processor.dart b/pkg/analysis_server/test/src/services/correction/fix/fix_processor.dart
index 366f8d1..00f2730 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/fix_processor.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/fix_processor.dart
@@ -262,7 +262,7 @@
Future<void> addUnimportedFile(String filePath, String content) async {
addSource(filePath, content);
- var result = await session.getResolvedUnit2(convertPath(filePath));
+ var result = await session.getResolvedUnit(convertPath(filePath));
extensionCache.cacheFromResult(result as ResolvedUnitResult);
}
diff --git a/pkg/analysis_server/test/stress/completion/completion_runner.dart b/pkg/analysis_server/test/stress/completion/completion_runner.dart
index 542d8fe..8d16f86 100644
--- a/pkg/analysis_server/test/stress/completion/completion_runner.dart
+++ b/pkg/analysis_server/test/stress/completion/completion_runner.dart
@@ -80,7 +80,7 @@
}
fileCount++;
output.write('.');
- var result = await context.currentSession.getResolvedUnit2(path)
+ var result = await context.currentSession.getResolvedUnit(path)
as ResolvedUnitResult;
var content = result.content!;
var lineInfo = result.lineInfo;
@@ -94,7 +94,7 @@
content.substring(identifier.end);
resourceProvider.setOverlay(path,
content: modifiedContent, modificationStamp: stamp++);
- result = await context.currentSession.getResolvedUnit2(path)
+ result = await context.currentSession.getResolvedUnit(path)
as ResolvedUnitResult;
}
diff --git a/pkg/analysis_server/test/verify_sorted_test.dart b/pkg/analysis_server/test/verify_sorted_test.dart
index 9cf62ed..dc12ccc 100644
--- a/pkg/analysis_server/test/verify_sorted_test.dart
+++ b/pkg/analysis_server/test/verify_sorted_test.dart
@@ -134,7 +134,7 @@
}
var relativePath = pathContext.relative(path, from: testDirPath);
test(relativePath, () {
- var result = session.getParsedUnit2(path);
+ var result = session.getParsedUnit(path);
if (result is! ParsedUnitResult) {
fail('Could not parse $path');
}
diff --git a/pkg/analysis_server/tool/code_completion/code_metrics.dart b/pkg/analysis_server/tool/code_completion/code_metrics.dart
index 5ff17b9..898b393 100644
--- a/pkg/analysis_server/tool/code_completion/code_metrics.dart
+++ b/pkg/analysis_server/tool/code_completion/code_metrics.dart
@@ -1394,7 +1394,7 @@
if (file_paths.isDart(pathContext, filePath)) {
try {
var resolvedUnitResult =
- await context.currentSession.getResolvedUnit2(filePath);
+ await context.currentSession.getResolvedUnit(filePath);
//
// Check for errors that cause the file to be skipped.
//
diff --git a/pkg/analysis_server/tool/code_completion/completion_metrics.dart b/pkg/analysis_server/tool/code_completion/completion_metrics.dart
index 45d77c6..3527d19 100644
--- a/pkg/analysis_server/tool/code_completion/completion_metrics.dart
+++ b/pkg/analysis_server/tool/code_completion/completion_metrics.dart
@@ -1293,7 +1293,7 @@
for (var filePath in context.contextRoot.analyzedFiles()) {
if (file_paths.isDart(pathContext, filePath)) {
try {
- var result = await context.currentSession.getResolvedUnit2(filePath)
+ var result = await context.currentSession.getResolvedUnit(filePath)
as ResolvedUnitResult;
var analysisError = getFirstErrorOrNull(result);
@@ -1335,7 +1335,7 @@
modificationStamp: overlayModificationStamp++);
context.driver.changeFile(filePath);
resolvedUnitResult = await context.currentSession
- .getResolvedUnit2(filePath) as ResolvedUnitResult;
+ .getResolvedUnit(filePath) as ResolvedUnitResult;
}
// As this point the completion suggestions are computed,
diff --git a/pkg/analysis_server/tool/code_completion/flutter_metrics.dart b/pkg/analysis_server/tool/code_completion/flutter_metrics.dart
index ee267a5..886c484 100644
--- a/pkg/analysis_server/tool/code_completion/flutter_metrics.dart
+++ b/pkg/analysis_server/tool/code_completion/flutter_metrics.dart
@@ -207,7 +207,7 @@
if (file_paths.isDart(pathContext, filePath)) {
try {
var resolvedUnitResult =
- await context.currentSession.getResolvedUnit2(filePath);
+ await context.currentSession.getResolvedUnit(filePath);
//
// Check for errors that cause the file to be skipped.
//
diff --git a/pkg/analysis_server/tool/code_completion/implicit_type_declarations.dart b/pkg/analysis_server/tool/code_completion/implicit_type_declarations.dart
index 6b0b3c1..c2f21c9 100644
--- a/pkg/analysis_server/tool/code_completion/implicit_type_declarations.dart
+++ b/pkg/analysis_server/tool/code_completion/implicit_type_declarations.dart
@@ -184,7 +184,7 @@
if (file_paths.isDart(pathContext, filePath)) {
try {
var resolvedUnitResult =
- await context.currentSession.getResolvedUnit2(filePath);
+ await context.currentSession.getResolvedUnit(filePath);
//
// Check for errors that cause the file to be skipped.
//
diff --git a/pkg/analysis_server/tool/code_completion/relevance_metrics.dart b/pkg/analysis_server/tool/code_completion/relevance_metrics.dart
index 0975c8a..e80ba2a3 100644
--- a/pkg/analysis_server/tool/code_completion/relevance_metrics.dart
+++ b/pkg/analysis_server/tool/code_completion/relevance_metrics.dart
@@ -1940,7 +1940,7 @@
if (file_paths.isDart(pathContext, filePath)) {
try {
var resolvedUnitResult =
- await context.currentSession.getResolvedUnit2(filePath);
+ await context.currentSession.getResolvedUnit(filePath);
//
// Check for errors that cause the file to be skipped.
//
diff --git a/pkg/analysis_server/tool/code_completion/relevance_table_generator.dart b/pkg/analysis_server/tool/code_completion/relevance_table_generator.dart
index 52b219e..77359a0 100644
--- a/pkg/analysis_server/tool/code_completion/relevance_table_generator.dart
+++ b/pkg/analysis_server/tool/code_completion/relevance_table_generator.dart
@@ -1459,7 +1459,7 @@
if (file_paths.isDart(pathContext, filePath)) {
try {
var resolvedUnitResult =
- await context.currentSession.getResolvedUnit2(filePath);
+ await context.currentSession.getResolvedUnit(filePath);
//
// Check for errors that cause the file to be skipped.
//
diff --git a/pkg/analysis_server_client/test/verify_sorted_test.dart b/pkg/analysis_server_client/test/verify_sorted_test.dart
index dfa4c4a..f4f4c57 100644
--- a/pkg/analysis_server_client/test/verify_sorted_test.dart
+++ b/pkg/analysis_server_client/test/verify_sorted_test.dart
@@ -55,7 +55,7 @@
}
var relativePath = pathContext.relative(path, from: testDirPath);
test(relativePath, () {
- var result = session.getParsedUnit2(path);
+ var result = session.getParsedUnit(path);
if (result is! ParsedUnitResult) {
fail('Could not parse $path');
}
diff --git a/pkg/analyzer/CHANGELOG.md b/pkg/analyzer/CHANGELOG.md
index 665f334..69c3b4a 100644
--- a/pkg/analyzer/CHANGELOG.md
+++ b/pkg/analyzer/CHANGELOG.md
@@ -1,5 +1,9 @@
## 2.1.0
* Changed `AnalysisResult.path` to be non-nullable.
+* Changed `ParsedLibraryResult.units` to be non-nullable.
+* Changed `ResolvedLibraryResult.element` to be non-nullable.
+* Changed `ResolvedLibraryResult.units` to be non-nullable.
+* Deprecated and renamed `AnalysisSession.getXyz2()` into `getXyz()`.
## 2.0.0
* Removed deprecated `Scope.lookup2()`.
diff --git a/pkg/analyzer/example/analyze.dart b/pkg/analyzer/example/analyze.dart
index a94f27e..72acdf5 100644
--- a/pkg/analyzer/example/analyze.dart
+++ b/pkg/analyzer/example/analyze.dart
@@ -32,7 +32,7 @@
continue;
}
- final errorsResult = await context.currentSession.getErrors2(filePath);
+ final errorsResult = await context.currentSession.getErrors(filePath);
if (errorsResult is ErrorsResult) {
for (final error in errorsResult.errors) {
if (error.errorCode.type != ErrorType.TODO) {
diff --git a/pkg/analyzer/lib/dart/analysis/results.dart b/pkg/analyzer/lib/dart/analysis/results.dart
index c9230c2..550303b 100644
--- a/pkg/analyzer/lib/dart/analysis/results.dart
+++ b/pkg/analyzer/lib/dart/analysis/results.dart
@@ -162,9 +162,7 @@
abstract class ParsedLibraryResult
implements SomeParsedLibraryResult, AnalysisResult {
/// The parsed units of the library.
- ///
- /// TODO(migration): should not be null, probably empty list
- List<ParsedUnitResult>? get units;
+ List<ParsedUnitResult> get units;
/// Return the declaration of the [element], or `null` if the [element]
/// is synthetic. Throw [ArgumentError] if the [element] is not defined in
@@ -212,13 +210,13 @@
abstract class ResolvedLibraryResult
implements SomeResolvedLibraryResult, AnalysisResult {
/// The element representing this library.
- LibraryElement? get element;
+ LibraryElement get element;
/// The type provider used when resolving the library.
TypeProvider get typeProvider;
/// The resolved units of the library.
- List<ResolvedUnitResult>? get units;
+ List<ResolvedUnitResult> get units;
/// Return the declaration of the [element], or `null` if the [element]
/// is synthetic. Throw [ArgumentError] if the [element] is not defined in
diff --git a/pkg/analyzer/lib/dart/analysis/session.dart b/pkg/analyzer/lib/dart/analysis/session.dart
index 680ba37..ade0e8e 100644
--- a/pkg/analyzer/lib/dart/analysis/session.dart
+++ b/pkg/analyzer/lib/dart/analysis/session.dart
@@ -35,47 +35,105 @@
///
/// If the file cannot be analyzed by this session, then the result will have
/// a result state indicating the nature of the problem.
+ Future<SomeErrorsResult> getErrors(String path);
+
+ /// Return a future that will complete with information about the errors
+ /// contained in the file with the given absolute, normalized [path].
+ ///
+ /// If the file cannot be analyzed by this session, then the result will have
+ /// a result state indicating the nature of the problem.
+ @Deprecated('Use getErrors() instead')
Future<SomeErrorsResult> getErrors2(String path);
/// Return information about the file at the given absolute, normalized
/// [path].
+ SomeFileResult getFile(String path);
+
+ /// Return information about the file at the given absolute, normalized
+ /// [path].
+ @Deprecated('Use getFile() instead')
SomeFileResult getFile2(String path);
/// Return a future that will complete with information about the library
/// element representing the library with the given [uri].
+ Future<SomeLibraryElementResult> getLibraryByUri(String uri);
+
+ /// Return a future that will complete with information about the library
+ /// element representing the library with the given [uri].
+ @Deprecated('Use getLibraryByUri() instead')
Future<SomeLibraryElementResult> getLibraryByUri2(String uri);
/// Return information about the results of parsing units of the library file
/// with the given absolute, normalized [path].
+ SomeParsedLibraryResult getParsedLibrary(String path);
+
+ /// Return information about the results of parsing units of the library file
+ /// with the given absolute, normalized [path].
+ @Deprecated('Use getParsedLibrary() instead')
SomeParsedLibraryResult getParsedLibrary2(String path);
/// Return information about the results of parsing units of the library file
/// with the given library [element].
+ SomeParsedLibraryResult getParsedLibraryByElement(LibraryElement element);
+
+ /// Return information about the results of parsing units of the library file
+ /// with the given library [element].
+ @Deprecated('Use getParsedLibraryByElement() instead')
SomeParsedLibraryResult getParsedLibraryByElement2(LibraryElement element);
/// Return information about the results of parsing the file with the given
/// absolute, normalized [path].
+ SomeParsedUnitResult getParsedUnit(String path);
+
+ /// Return information about the results of parsing the file with the given
+ /// absolute, normalized [path].
+ @Deprecated('Use getParsedUnit() instead')
SomeParsedUnitResult getParsedUnit2(String path);
/// Return a future that will complete with information about the results of
/// resolving all of the files in the library with the given absolute,
/// normalized [path].
+ Future<SomeResolvedLibraryResult> getResolvedLibrary(String path);
+
+ /// Return a future that will complete with information about the results of
+ /// resolving all of the files in the library with the given absolute,
+ /// normalized [path].
+ @Deprecated('Use getResolvedLibrary() instead')
Future<SomeResolvedLibraryResult> getResolvedLibrary2(String path);
/// 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.
+ 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.
+ @Deprecated('Use getResolvedLibraryByElement() instead')
Future<SomeResolvedLibraryResult> getResolvedLibraryByElement2(
LibraryElement 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);
+
+ /// Return a future that will complete with information about the results of
+ /// resolving the file with the given absolute, normalized [path].
+ @Deprecated('Use getResolvedUnit() instead')
Future<SomeResolvedUnitResult> getResolvedUnit2(String path);
/// Return a future that will complete with information about the results of
/// building the element model for the file with the given absolute,
/// normalized [path].
+ Future<SomeUnitElementResult> getUnitElement(String path);
+
+ /// Return a future that will complete with information about the results of
+ /// building the element model for the file with the given absolute,
+ /// normalized [path].
+ @Deprecated('Use getUnitElement() instead')
Future<SomeUnitElementResult> getUnitElement2(String path);
}
diff --git a/pkg/analyzer/lib/dart/analysis/utilities.dart b/pkg/analyzer/lib/dart/analysis/utilities.dart
index 3fd296d..8cee120 100644
--- a/pkg/analyzer/lib/dart/analysis/utilities.dart
+++ b/pkg/analyzer/lib/dart/analysis/utilities.dart
@@ -115,7 +115,7 @@
{required String path, ResourceProvider? resourceProvider}) async {
AnalysisContext context =
_createAnalysisContext(path: path, resourceProvider: resourceProvider);
- return await context.currentSession.getResolvedUnit2(path);
+ return await context.currentSession.getResolvedUnit(path);
}
/// Return a newly create analysis context in which the file at the given [path]
diff --git a/pkg/analyzer/lib/src/dart/analysis/results.dart b/pkg/analyzer/lib/src/dart/analysis/results.dart
index 41abe8f..d13482f 100644
--- a/pkg/analyzer/lib/src/dart/analysis/results.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/results.dart
@@ -76,7 +76,7 @@
class ParsedLibraryResultImpl extends AnalysisResultImpl
implements ParsedLibraryResult {
@override
- final List<ParsedUnitResult>? units;
+ final List<ParsedUnitResult> units;
ParsedLibraryResultImpl(
AnalysisSession session, String path, Uri uri, this.units)
@@ -101,7 +101,7 @@
}
var elementPath = element.source!.fullName;
- var unitResult = units!.firstWhere(
+ var unitResult = units.firstWhere(
(r) => r.path == elementPath,
orElse: () {
var elementStr = element.getDisplayString(withNullability: true);
@@ -159,10 +159,10 @@
class ResolvedLibraryResultImpl extends AnalysisResultImpl
implements ResolvedLibraryResult {
@override
- final LibraryElement? element;
+ final LibraryElement element;
@override
- final List<ResolvedUnitResult>? units;
+ final List<ResolvedUnitResult> units;
ResolvedLibraryResultImpl(
AnalysisSession session, String path, Uri uri, this.element, this.units)
@@ -174,7 +174,7 @@
}
@override
- TypeProvider get typeProvider => element!.typeProvider;
+ TypeProvider get typeProvider => element.typeProvider;
@override
ElementDeclarationResult? getElementDeclaration(Element element) {
@@ -190,7 +190,7 @@
}
var elementPath = element.source!.fullName;
- var unitResult = units!.firstWhere(
+ var unitResult = units.firstWhere(
(r) => r.path == elementPath,
orElse: () {
var elementStr = element.getDisplayString(withNullability: true);
@@ -199,7 +199,7 @@
buffer.writeln(' is not defined in this library.');
// TODO(scheglov) https://github.com/dart-lang/sdk/issues/45430
buffer.writeln('elementPath: $elementPath');
- buffer.writeln('unitPaths: ${units!.map((e) => e.path).toList()}');
+ buffer.writeln('unitPaths: ${units.map((e) => e.path).toList()}');
throw ArgumentError('$buffer');
},
);
diff --git a/pkg/analyzer/lib/src/dart/analysis/session.dart b/pkg/analyzer/lib/src/dart/analysis/session.dart
index 288882e..5bc5a9c 100644
--- a/pkg/analyzer/lib/src/dart/analysis/session.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/session.dart
@@ -55,31 +55,55 @@
driver.AnalysisDriver getDriver() => _driver;
@override
- Future<SomeErrorsResult> getErrors2(String path) {
+ Future<SomeErrorsResult> getErrors(String path) {
_checkConsistency();
return _driver.getErrors2(path);
}
+ @Deprecated('Use getErrors() instead')
@override
- SomeFileResult getFile2(String path) {
+ Future<SomeErrorsResult> getErrors2(String path) {
+ return getErrors(path);
+ }
+
+ @override
+ SomeFileResult getFile(String path) {
_checkConsistency();
return _driver.getFileSync2(path);
}
+ @Deprecated('Use getFile() instead')
@override
- Future<SomeLibraryElementResult> getLibraryByUri2(String uri) {
+ SomeFileResult getFile2(String path) {
+ return getFile(path);
+ }
+
+ @override
+ Future<SomeLibraryElementResult> getLibraryByUri(String uri) {
_checkConsistency();
return _driver.getLibraryByUri2(uri);
}
+ @Deprecated('Use getLibraryByUri() instead')
@override
- SomeParsedLibraryResult getParsedLibrary2(String path) {
+ Future<SomeLibraryElementResult> getLibraryByUri2(String uri) {
+ return getLibraryByUri(uri);
+ }
+
+ @override
+ SomeParsedLibraryResult getParsedLibrary(String path) {
_checkConsistency();
return _driver.getParsedLibrary2(path);
}
+ @Deprecated('Use getParsedLibrary() instead')
@override
- SomeParsedLibraryResult getParsedLibraryByElement2(LibraryElement element) {
+ SomeParsedLibraryResult getParsedLibrary2(String path) {
+ return getParsedLibrary(path);
+ }
+
+ @override
+ SomeParsedLibraryResult getParsedLibraryByElement(LibraryElement element) {
_checkConsistency();
if (element.session != this) {
@@ -89,20 +113,38 @@
return _driver.getParsedLibraryByUri2(element.source.uri);
}
+ @Deprecated('Use getParsedLibraryByElement() instead')
@override
- SomeParsedUnitResult getParsedUnit2(String path) {
+ SomeParsedLibraryResult getParsedLibraryByElement2(LibraryElement element) {
+ return getParsedLibraryByElement(element);
+ }
+
+ @override
+ SomeParsedUnitResult getParsedUnit(String path) {
_checkConsistency();
return _driver.parseFileSync2(path);
}
+ @Deprecated('Use getParsedUnit() instead')
@override
- Future<SomeResolvedLibraryResult> getResolvedLibrary2(String path) {
+ SomeParsedUnitResult getParsedUnit2(String path) {
+ return getParsedUnit(path);
+ }
+
+ @override
+ Future<SomeResolvedLibraryResult> getResolvedLibrary(String path) {
_checkConsistency();
return _driver.getResolvedLibrary2(path);
}
+ @Deprecated('Use getResolvedLibrary() instead')
@override
- Future<SomeResolvedLibraryResult> getResolvedLibraryByElement2(
+ Future<SomeResolvedLibraryResult> getResolvedLibrary2(String path) {
+ return getResolvedLibrary(path);
+ }
+
+ @override
+ Future<SomeResolvedLibraryResult> getResolvedLibraryByElement(
LibraryElement element,
) {
_checkConsistency();
@@ -116,18 +158,38 @@
return _driver.getResolvedLibraryByUri2(element.source.uri);
}
+ @Deprecated('Use getResolvedLibraryByElement() instead')
@override
- Future<SomeResolvedUnitResult> getResolvedUnit2(String path) {
+ Future<SomeResolvedLibraryResult> getResolvedLibraryByElement2(
+ LibraryElement element,
+ ) {
+ return getResolvedLibraryByElement(element);
+ }
+
+ @override
+ Future<SomeResolvedUnitResult> getResolvedUnit(String path) {
_checkConsistency();
return _driver.getResult2(path);
}
+ @Deprecated('Use getResolvedUnit() instead')
@override
- Future<SomeUnitElementResult> getUnitElement2(String path) {
+ Future<SomeResolvedUnitResult> getResolvedUnit2(String path) {
+ return getResolvedUnit(path);
+ }
+
+ @override
+ Future<SomeUnitElementResult> getUnitElement(String path) {
_checkConsistency();
return _driver.getUnitElement2(path);
}
+ @Deprecated('Use getUnitElement() instead')
+ @override
+ Future<SomeUnitElementResult> getUnitElement2(String path) {
+ return getUnitElement(path);
+ }
+
/// Check to see that results from this session will be consistent, and throw
/// an [InconsistentAnalysisException] if they might not be.
void _checkConsistency() {
diff --git a/pkg/analyzer/lib/src/dart/analysis/session_helper.dart b/pkg/analyzer/lib/src/dart/analysis/session_helper.dart
index 020af5d..a7bc83a 100644
--- a/pkg/analyzer/lib/src/dart/analysis/session_helper.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/session_helper.dart
@@ -22,7 +22,7 @@
/// from the library with the given [libraryUri], or `null` if the library
/// does not export a class with such name.
Future<ClassElement?> getClass(String libraryUri, String className) async {
- var libraryResult = await session.getLibraryByUri2(libraryUri);
+ var libraryResult = await session.getLibraryByUri(libraryUri);
if (libraryResult is LibraryElementResult) {
var element = libraryResult.element.exportNamespace.get(className);
if (element is ClassElement) {
@@ -50,7 +50,7 @@
}
var unitPath = element.source!.fullName;
- return resolvedLibrary.units!.singleWhere((resolvedUnit) {
+ return resolvedLibrary.units.singleWhere((resolvedUnit) {
return resolvedUnit.path == unitPath;
});
}
@@ -60,7 +60,7 @@
/// library does not export a top-level accessor with such name.
Future<PropertyAccessorElement?> getTopLevelPropertyAccessor(
String uri, String name) async {
- var libraryResult = await session.getLibraryByUri2(uri);
+ var libraryResult = await session.getLibraryByUri(uri);
if (libraryResult is LibraryElementResult) {
var element = libraryResult.element.exportNamespace.get(name);
if (element is PropertyAccessorElement) {
@@ -74,7 +74,7 @@
Future<ResolvedLibraryResult?> _getResolvedLibrary(String path) async {
var result = _resolvedLibraries[path];
if (result == null) {
- var some = await session.getResolvedLibrary2(path);
+ var some = await session.getResolvedLibrary(path);
if (some is ResolvedLibraryResult) {
result = _resolvedLibraries[path] = some;
}
diff --git a/pkg/analyzer/lib/src/dart/micro/analysis_context.dart b/pkg/analyzer/lib/src/dart/micro/analysis_context.dart
index 4d79d83..ef663ca 100644
--- a/pkg/analyzer/lib/src/dart/micro/analysis_context.dart
+++ b/pkg/analyzer/lib/src/dart/micro/analysis_context.dart
@@ -181,18 +181,18 @@
}
@override
- Future<SomeLibraryElementResult> getLibraryByUri2(String uriStr) async {
+ Future<SomeLibraryElementResult> getLibraryByUri(String uriStr) async {
var element = analysisContext.fileResolver.getLibraryByUri(uriStr: uriStr);
return LibraryElementResultImpl(element);
}
@override
- Future<SomeResolvedLibraryResult> getResolvedLibrary2(String path) async {
+ Future<SomeResolvedLibraryResult> getResolvedLibrary(String path) async {
return analysisContext.fileResolver.resolveLibrary(path: path);
}
@override
- Future<SomeResolvedUnitResult> getResolvedUnit2(String path) async {
+ Future<SomeResolvedUnitResult> getResolvedUnit(String path) async {
return analysisContext.fileResolver.resolve(path: path);
}
diff --git a/pkg/analyzer/lib/src/dart/micro/resolve_file.dart b/pkg/analyzer/lib/src/dart/micro/resolve_file.dart
index 2608588..aa64210 100644
--- a/pkg/analyzer/lib/src/dart/micro/resolve_file.dart
+++ b/pkg/analyzer/lib/src/dart/micro/resolve_file.dart
@@ -452,14 +452,14 @@
completionPath: path,
performance: performance,
);
- var result = libraryUnit.units!
- .firstWhereOrNull((element) => element.path == path);
+ var result =
+ libraryUnit.units.firstWhereOrNull((element) => element.path == path);
// TODO(scheglov) Fix and remove.
if (result == null) {
throw StateError('''
libraryFile.path: ${libraryFile.path}
path: $path
-units: ${libraryUnit.units!.map((e) => '(${e.uri} = ${e.path})').toList()}
+units: ${libraryUnit.units.map((e) => '(${e.uri} = ${e.path})').toList()}
''');
}
return result;
diff --git a/pkg/analyzer/test/src/dart/analysis/dependency/base.dart b/pkg/analyzer/test/src/dart/analysis/dependency/base.dart
index 6570844..08f50c5 100644
--- a/pkg/analyzer/test/src/dart/analysis/dependency/base.dart
+++ b/pkg/analyzer/test/src/dart/analysis/dependency/base.dart
@@ -138,9 +138,9 @@
Future<List<CompilationUnit>> _resolveLibrary(String libraryPath) async {
var session = contextFor(libraryPath).currentSession;
- var resolvedLibrary = await session.getResolvedLibrary2(libraryPath);
+ var resolvedLibrary = await session.getResolvedLibrary(libraryPath);
resolvedLibrary as ResolvedLibraryResult;
- return resolvedLibrary.units!.map((ru) => ru.unit!).toList();
+ return resolvedLibrary.units.map((ru) => ru.unit!).toList();
}
}
diff --git a/pkg/analyzer/test/src/dart/analysis/driver_caching_test.dart b/pkg/analyzer/test/src/dart/analysis/driver_caching_test.dart
index 300536e..230b7cd 100644
--- a/pkg/analyzer/test/src/dart/analysis/driver_caching_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/driver_caching_test.dart
@@ -276,7 +276,7 @@
var testFilePathConverted = convertPath(testFilePath);
var errorsResult = await contextFor(testFilePathConverted)
.currentSession
- .getErrors2(testFilePathConverted) as ErrorsResult;
+ .getErrors(testFilePathConverted) as ErrorsResult;
return errorsResult.errors;
}
}
diff --git a/pkg/analyzer/test/src/dart/analysis/driver_test.dart b/pkg/analyzer/test/src/dart/analysis/driver_test.dart
index eef1ad3..b0c354c 100644
--- a/pkg/analyzer/test/src/dart/analysis/driver_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/driver_test.dart
@@ -1403,10 +1403,10 @@
var result = driver.getParsedLibrary2(testFile);
result as ParsedLibraryResult;
expect(result.units, hasLength(1));
- expect(result.units![0].path, testFile);
- expect(result.units![0].content, content);
- expect(result.units![0].unit, isNotNull);
- expect(result.units![0].errors, isEmpty);
+ expect(result.units[0].path, testFile);
+ expect(result.units[0].content, content);
+ expect(result.units[0].unit, isNotNull);
+ expect(result.units[0].errors, isEmpty);
}
test_getParsedLibrary2_invalidPath_notAbsolute() async {
@@ -1429,9 +1429,9 @@
result as ParsedLibraryResult;
expect(result.uri, uri);
expect(result.units, hasLength(1));
- expect(result.units![0].uri, uri);
- expect(result.units![0].path, testFile);
- expect(result.units![0].content, content);
+ expect(result.units[0].uri, uri);
+ expect(result.units[0].path, testFile);
+ expect(result.units[0].content, content);
}
test_getParsedLibraryByUri2_notLibrary() async {
@@ -1454,10 +1454,10 @@
var result = await driver.getResolvedLibrary2(testFile);
result as ResolvedLibraryResult;
expect(result.units, hasLength(1));
- expect(result.units![0].path, testFile);
- expect(result.units![0].content, content);
- expect(result.units![0].unit, isNotNull);
- expect(result.units![0].errors, isEmpty);
+ expect(result.units[0].path, testFile);
+ expect(result.units[0].content, content);
+ expect(result.units[0].unit, isNotNull);
+ expect(result.units[0].errors, isEmpty);
}
test_getResolvedLibrary2_invalidPath_notAbsolute() async {
@@ -1479,11 +1479,11 @@
var result = await driver.getResolvedLibraryByUri2(uri);
result as ResolvedLibraryResult;
expect(result.uri, uri);
- expect(result.element!.source.fullName, testFile);
+ expect(result.element.source.fullName, testFile);
expect(result.units, hasLength(1));
- expect(result.units![0].uri, uri);
- expect(result.units![0].path, testFile);
- expect(result.units![0].content, content);
+ expect(result.units[0].uri, uri);
+ expect(result.units[0].path, testFile);
+ expect(result.units[0].content, content);
}
test_getResolvedLibraryByUri2_notLibrary() async {
diff --git a/pkg/analyzer/test/src/dart/analysis/results/get_element_declaration_test.dart b/pkg/analyzer/test/src/dart/analysis/results/get_element_declaration_test.dart
index 89fdeda..a36d472 100644
--- a/pkg/analyzer/test/src/dart/analysis/results/get_element_declaration_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/results/get_element_declaration_test.dart
@@ -439,7 +439,7 @@
ParsedLibraryResult _getParsedLibrary(String path) {
var session = contextFor(path).currentSession;
- return session.getParsedLibrary2(path) as ParsedLibraryResult;
+ return session.getParsedLibrary(path) as ParsedLibraryResult;
}
}
@@ -456,6 +456,6 @@
Future<ResolvedLibraryResult> _getResolvedLibrary(String path) async {
var session = contextFor(path).currentSession;
- return await session.getResolvedLibrary2(path) as ResolvedLibraryResult;
+ return await session.getResolvedLibrary(path) as ResolvedLibraryResult;
}
}
diff --git a/pkg/analyzer/test/src/dart/analysis/session_test.dart b/pkg/analyzer/test/src/dart/analysis/session_test.dart
index 1d2f2b0..5d863b5 100644
--- a/pkg/analyzer/test/src/dart/analysis/session_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/session_test.dart
@@ -33,7 +33,7 @@
var path = convertPath('$workspaceRootPath/$relPath');
var session = contextFor(path).currentSession;
- var result = await session.getErrors2(path);
+ var result = await session.getErrors(path);
expect(result, isA<NotPathOfUriResult>());
}
@@ -57,7 +57,7 @@
var path = convertPath('$workspaceRootPath/$relPath');
var session = contextFor(path).currentSession;
- var result = session.getParsedLibrary2(path);
+ var result = session.getParsedLibrary(path);
expect(result, isA<NotPathOfUriResult>());
}
@@ -67,7 +67,7 @@
var path = convertPath('$workspaceRootPath/$relPath');
var session = contextFor(path).currentSession;
- var result = await session.getResolvedLibrary2(path);
+ var result = await session.getResolvedLibrary(path);
expect(result, isA<NotPathOfUriResult>());
}
@@ -77,7 +77,7 @@
var path = convertPath('$workspaceRootPath/$relPath');
var session = contextFor(path).currentSession;
- var result = await session.getResolvedUnit2(path);
+ var result = await session.getResolvedUnit(path);
expect(result, isA<NotPathOfUriResult>());
}
@@ -88,8 +88,7 @@
);
var session = contextFor(file.path).currentSession;
- var result =
- await session.getResolvedUnit2(file.path) as ResolvedUnitResult;
+ var result = await session.getResolvedUnit(file.path) as ResolvedUnitResult;
expect(result.state, ResultState.VALID);
expect(result.path, file.path);
expect(result.errors, isEmpty);
@@ -103,7 +102,7 @@
);
var session = contextFor(file.path).currentSession;
- var result = await session.getUnitElement2('not_absolute.dart');
+ var result = await session.getUnitElement('not_absolute.dart');
expect(result, isA<InvalidPathResult>());
}
@@ -113,7 +112,7 @@
var path = convertPath('$workspaceRootPath/$relPath');
var session = contextFor(path).currentSession;
- var result = await session.getUnitElement2(path);
+ var result = await session.getUnitElement(path);
expect(result, isA<NotPathOfUriResult>());
}
@@ -175,12 +174,12 @@
}
test_getErrors2_invalidPath_notAbsolute() async {
- var errorsResult = await session.getErrors2('not_absolute.dart');
+ var errorsResult = await session.getErrors('not_absolute.dart');
expect(errorsResult, isA<InvalidPathResult>());
}
test_getFile2_invalidPath_notAbsolute() async {
- var errorsResult = session.getFile2('not_absolute.dart');
+ var errorsResult = session.getFile('not_absolute.dart');
expect(errorsResult, isA<InvalidPathResult>());
}
@@ -216,7 +215,7 @@
}
test_getLibraryByUri2_unresolvedUri() async {
- var result = await session.getLibraryByUri2('package:foo/foo.dart');
+ var result = await session.getLibraryByUri('package:foo/foo.dart');
expect(result, isA<CannotResolveUriResult>());
}
@@ -233,7 +232,7 @@
expect(parsedLibrary.units, hasLength(1));
{
- var parsedUnit = parsedLibrary.units![0];
+ var parsedUnit = parsedLibrary.units[0];
expect(parsedUnit.session, session);
expect(parsedUnit.path, testPath);
expect(parsedUnit.uri, Uri.parse('package:test/test.dart'));
@@ -242,13 +241,13 @@
}
test_getParsedLibrary2_invalidPath_notAbsolute() async {
- var result = session.getParsedLibrary2('not_absolute.dart');
+ var result = session.getParsedLibrary('not_absolute.dart');
expect(result, isA<InvalidPathResult>());
}
test_getParsedLibrary2_notLibrary() async {
newFile(testPath, content: 'part of "a.dart";');
- expect(session.getParsedLibrary2(testPath), isA<NotLibraryButPartResult>());
+ expect(session.getParsedLibrary(testPath), isA<NotLibraryButPartResult>());
}
test_getParsedLibrary2_parts() async {
@@ -288,21 +287,21 @@
expect(parsedLibrary.units, hasLength(3));
{
- var aUnit = parsedLibrary.units![0];
+ var aUnit = parsedLibrary.units[0];
expect(aUnit.path, a);
expect(aUnit.uri, Uri.parse('package:test/a.dart'));
expect(aUnit.unit.declarations, hasLength(1));
}
{
- var bUnit = parsedLibrary.units![1];
+ var bUnit = parsedLibrary.units[1];
expect(bUnit.path, b);
expect(bUnit.uri, Uri.parse('package:test/b.dart'));
expect(bUnit.unit.declarations, hasLength(2));
}
{
- var cUnit = parsedLibrary.units![2];
+ var cUnit = parsedLibrary.units[2];
expect(cUnit.path, c);
expect(cUnit.uri, Uri.parse('package:test/c.dart'));
expect(cUnit.unit.declarations, hasLength(3));
@@ -332,7 +331,7 @@
newFile(testPath, content: '');
var resolvedUnit =
- await session.getResolvedUnit2(testPath) as ResolvedUnitResult;
+ await session.getResolvedUnit(testPath) as ResolvedUnitResult;
var typeProvider = resolvedUnit.typeProvider;
var intClass = typeProvider.intType.element;
@@ -378,15 +377,15 @@
expect(parsedLibrary.units, hasLength(3));
expect(
- parsedLibrary.units![0].path,
+ parsedLibrary.units[0].path,
convertPath('/home/test/lib/test.dart'),
);
expect(
- parsedLibrary.units![1].path,
+ parsedLibrary.units[1].path,
convertPath('/home/test/lib/a.dart'),
);
expect(
- parsedLibrary.units![2].path,
+ parsedLibrary.units[2].path,
convertPath('/home/test/lib/c.dart'),
);
}
@@ -417,7 +416,7 @@
var aaaSession =
contextCollection.contextFor(aaaContextPath).currentSession;
- var result = aaaSession.getParsedLibraryByElement2(element);
+ var result = aaaSession.getParsedLibraryByElement(element);
expect(result, isA<NotElementOfThisSessionResult>());
}
@@ -435,7 +434,7 @@
}
test_getParsedUnit2_invalidPath_notAbsolute() async {
- var result = session.getParsedUnit2('not_absolute.dart');
+ var result = session.getParsedUnit('not_absolute.dart');
expect(result, isA<InvalidPathResult>());
}
@@ -466,13 +465,13 @@
var typeProvider = resolvedLibrary.typeProvider;
expect(typeProvider.intType.element.name, 'int');
- var libraryElement = resolvedLibrary.element!;
+ var libraryElement = resolvedLibrary.element;
var aClass = libraryElement.getType('A')!;
var bClass = libraryElement.getType('B')!;
- var aUnitResult = resolvedLibrary.units![0];
+ var aUnitResult = resolvedLibrary.units[0];
expect(aUnitResult.path, a);
expect(aUnitResult.uri, Uri.parse('package:test/a.dart'));
expect(aUnitResult.content, aContent);
@@ -481,7 +480,7 @@
expect(aUnitResult.unit!.declarations, hasLength(1));
expect(aUnitResult.errors, isEmpty);
- var bUnitResult = resolvedLibrary.units![1];
+ var bUnitResult = resolvedLibrary.units[1];
expect(bUnitResult.path, b);
expect(bUnitResult.uri, Uri.parse('package:test/b.dart'));
expect(bUnitResult.content, bContent);
@@ -506,14 +505,14 @@
}
test_getResolvedLibrary2_invalidPath_notAbsolute() async {
- var result = await session.getResolvedLibrary2('not_absolute.dart');
+ var result = await session.getResolvedLibrary('not_absolute.dart');
expect(result, isA<InvalidPathResult>());
}
test_getResolvedLibrary2_notLibrary() async {
newFile(testPath, content: 'part of "a.dart";');
- var result = await session.getResolvedLibrary2(testPath);
+ var result = await session.getResolvedLibrary(testPath);
expect(result, isA<NotLibraryButPartResult>());
}
@@ -534,7 +533,7 @@
''');
var resolvedLibrary = await session.getResolvedLibraryValid(testPath);
- var unitElement = resolvedLibrary.element!.definingCompilationUnit;
+ var unitElement = resolvedLibrary.element.definingCompilationUnit;
var fooElement = unitElement.topLevelVariables[0];
expect(fooElement.name, 'foo');
@@ -563,15 +562,15 @@
expect(resolvedLibrary.units, hasLength(3));
expect(
- resolvedLibrary.units![0].path,
+ resolvedLibrary.units[0].path,
convertPath('/home/test/lib/test.dart'),
);
expect(
- resolvedLibrary.units![1].path,
+ resolvedLibrary.units[1].path,
convertPath('/home/test/lib/a.dart'),
);
expect(
- resolvedLibrary.units![2].path,
+ resolvedLibrary.units[2].path,
convertPath('/home/test/lib/c.dart'),
);
}
@@ -589,7 +588,7 @@
expect(result.path, testPath);
expect(result.uri, Uri.parse('package:test/test.dart'));
expect(result.units, hasLength(1));
- expect(result.units![0].unit!.declaredElement, isNotNull);
+ expect(result.units[0].unit!.declaredElement, isNotNull);
}
test_getResolvedLibraryByElement2_differentSession() async {
@@ -603,7 +602,7 @@
var aaaSession =
contextCollection.contextFor(aaaContextPath).currentSession;
- var result = await aaaSession.getResolvedLibraryByElement2(element);
+ var result = await aaaSession.getResolvedLibraryByElement(element);
expect(result, isA<NotElementOfThisSessionResult>());
}
@@ -614,7 +613,7 @@
''');
var unitResult =
- await session.getResolvedUnit2(testPath) as ResolvedUnitResult;
+ await session.getResolvedUnit(testPath) as ResolvedUnitResult;
expect(unitResult.session, session);
expect(unitResult.path, testPath);
expect(unitResult.uri, Uri.parse('package:test/test.dart'));
@@ -643,39 +642,39 @@
extension on AnalysisSession {
Future<UnitElementResult> getUnitElementValid(String path) async {
- return await getUnitElement2(path) as UnitElementResult;
+ return await getUnitElement(path) as UnitElementResult;
}
ParsedLibraryResult getParsedLibraryValid(String path) {
- return getParsedLibrary2(path) as ParsedLibraryResult;
+ return getParsedLibrary(path) as ParsedLibraryResult;
}
FileResult getFileValid(String path) {
- return getFile2(path) as FileResult;
+ return getFile(path) as FileResult;
}
ParsedUnitResult getParsedUnitValid(String path) {
- return getParsedUnit2(path) as ParsedUnitResult;
+ return getParsedUnit(path) as ParsedUnitResult;
}
Future<ResolvedLibraryResult> getResolvedLibraryValid(String path) async {
- return await getResolvedLibrary2(path) as ResolvedLibraryResult;
+ return await getResolvedLibrary(path) as ResolvedLibraryResult;
}
Future<LibraryElementResult> getLibraryByUriValid(String path) async {
- return await getLibraryByUri2(path) as LibraryElementResult;
+ return await getLibraryByUri(path) as LibraryElementResult;
}
Future<ResolvedLibraryResult> getResolvedLibraryByElementValid(
LibraryElement element) async {
- return await getResolvedLibraryByElement2(element) as ResolvedLibraryResult;
+ return await getResolvedLibraryByElement(element) as ResolvedLibraryResult;
}
ParsedLibraryResult getParsedLibraryByElementValid(LibraryElement element) {
- return getParsedLibraryByElement2(element) as ParsedLibraryResult;
+ return getParsedLibraryByElement(element) as ParsedLibraryResult;
}
Future<ErrorsResult> getErrorsValid(String path) async {
- return await getErrors2(path) as ErrorsResult;
+ return await getErrors(path) as ErrorsResult;
}
}
diff --git a/pkg/analyzer/test/src/dart/micro/simple_file_resolver_test.dart b/pkg/analyzer/test/src/dart/micro/simple_file_resolver_test.dart
index 2fe77d8..93122d1 100644
--- a/pkg/analyzer/test/src/dart/micro/simple_file_resolver_test.dart
+++ b/pkg/analyzer/test/src/dart/micro/simple_file_resolver_test.dart
@@ -1084,7 +1084,7 @@
var result = fileResolver.resolveLibrary(path: aPath);
expect(result.path, aPath);
- expect(result.units?.length, 2);
+ expect(result.units.length, 2);
}
test_reuse_compatibleOptions() async {
diff --git a/pkg/analyzer/test/src/dart/resolution/context_collection_resolution.dart b/pkg/analyzer/test/src/dart/resolution/context_collection_resolution.dart
index 27ec665..afc3556 100644
--- a/pkg/analyzer/test/src/dart/resolution/context_collection_resolution.dart
+++ b/pkg/analyzer/test/src/dart/resolution/context_collection_resolution.dart
@@ -190,7 +190,7 @@
Future<ResolvedUnitResult> resolveFile(String path) async {
var analysisContext = contextFor(pathForContextSelection ?? path);
var session = analysisContext.currentSession;
- return await session.getResolvedUnit2(path) as ResolvedUnitResult;
+ return await session.getResolvedUnit(path) as ResolvedUnitResult;
}
@mustCallSuper
diff --git a/pkg/analyzer/test/src/services/available_declarations_test.dart b/pkg/analyzer/test/src/services/available_declarations_test.dart
index a2e41c6..a939f53 100644
--- a/pkg/analyzer/test/src/services/available_declarations_test.dart
+++ b/pkg/analyzer/test/src/services/available_declarations_test.dart
@@ -3496,9 +3496,9 @@
newFile(a, content: 'class A {}');
newFile(b, content: 'class B {}');
newFile(c, content: 'class C {}');
- testAnalysisContext.currentSession.getFile2(a);
- testAnalysisContext.currentSession.getFile2(b);
- testAnalysisContext.currentSession.getFile2(c);
+ testAnalysisContext.currentSession.getFile(a);
+ testAnalysisContext.currentSession.getFile(b);
+ testAnalysisContext.currentSession.getFile(c);
var context = tracker.addContext(testAnalysisContext);
await _doAllTrackerWork();
diff --git a/pkg/analyzer/test/src/summary/top_level_inference_test.dart b/pkg/analyzer/test/src/summary/top_level_inference_test.dart
index b10c777..feb2509 100644
--- a/pkg/analyzer/test/src/summary/top_level_inference_test.dart
+++ b/pkg/analyzer/test/src/summary/top_level_inference_test.dart
@@ -6116,7 +6116,7 @@
var path = convertPath(testFilePath);
var analysisSession = contextFor(path).currentSession;
- var result = await analysisSession.getUnitElement2(path);
+ var result = await analysisSession.getUnitElement(path);
result as UnitElementResult;
return result.element.library;
}
diff --git a/pkg/analyzer/test/verify_diagnostics_test.dart b/pkg/analyzer/test/verify_diagnostics_test.dart
index 103c27e..4b57873 100644
--- a/pkg/analyzer/test/verify_diagnostics_test.dart
+++ b/pkg/analyzer/test/verify_diagnostics_test.dart
@@ -287,7 +287,7 @@
/// [path] and return the result.
ParsedUnitResult _parse(AnalysisContextCollection collection, String path) {
AnalysisSession session = collection.contextFor(path).currentSession;
- var result = session.getParsedUnit2(path);
+ var result = session.getParsedUnit(path);
if (result is! ParsedUnitResult) {
throw StateError('Unable to parse "$path"');
}
diff --git a/pkg/analyzer/test/verify_docs_test.dart b/pkg/analyzer/test/verify_docs_test.dart
index 8ffc750..b01d307 100644
--- a/pkg/analyzer/test/verify_docs_test.dart
+++ b/pkg/analyzer/test/verify_docs_test.dart
@@ -118,7 +118,7 @@
if (contexts.length != 1) {
fail('The snippets directory contains multiple analysis contexts.');
}
- var results = await contexts[0].currentSession.getErrors2(snippetPath);
+ var results = await contexts[0].currentSession.getErrors(snippetPath);
if (results is ErrorsResult) {
Iterable<AnalysisError> errors = results.errors.where((error) {
ErrorCode errorCode = error.errorCode;
diff --git a/pkg/analyzer/tool/diagnostics/generate.dart b/pkg/analyzer/tool/diagnostics/generate.dart
index 927bbf2..e431fb0 100644
--- a/pkg/analyzer/tool/diagnostics/generate.dart
+++ b/pkg/analyzer/tool/diagnostics/generate.dart
@@ -363,7 +363,7 @@
/// [path] and return the result.
ParsedUnitResult _parse(AnalysisContextCollection collection, String path) {
AnalysisSession session = collection.contextFor(path).currentSession;
- var result = session.getParsedUnit2(path);
+ var result = session.getParsedUnit(path);
if (result is! ParsedUnitResult) {
throw StateError('Unable to parse "$path"');
}
diff --git a/pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_core.dart b/pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_core.dart
index ab273d2..4755515 100644
--- a/pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_core.dart
+++ b/pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_core.dart
@@ -246,7 +246,7 @@
}
var session = workspace.getSession(path);
- var result = await session?.getResolvedUnit2(path);
+ var result = await session?.getResolvedUnit(path);
if (result is! ResolvedUnitResult) {
throw AnalysisException('Cannot analyze "$path"');
}
diff --git a/pkg/analyzer_plugin/lib/utilities/navigation/navigation_dart.dart b/pkg/analyzer_plugin/lib/utilities/navigation/navigation_dart.dart
index e409097a..19d5b1e 100644
--- a/pkg/analyzer_plugin/lib/utilities/navigation/navigation_dart.dart
+++ b/pkg/analyzer_plugin/lib/utilities/navigation/navigation_dart.dart
@@ -178,7 +178,7 @@
return null;
}
- var parsedLibrary = session.getParsedLibrary2(libraryPath);
+ var parsedLibrary = session.getParsedLibrary(libraryPath);
if (parsedLibrary is! ParsedLibraryResult) {
return null;
}
diff --git a/pkg/analyzer_plugin/test/src/utilities/change_builder/dart/import_library_element_test.dart b/pkg/analyzer_plugin/test/src/utilities/change_builder/dart/import_library_element_test.dart
index 5239e00..cd2eefa 100644
--- a/pkg/analyzer_plugin/test/src/utilities/change_builder/dart/import_library_element_test.dart
+++ b/pkg/analyzer_plugin/test/src/utilities/change_builder/dart/import_library_element_test.dart
@@ -469,7 +469,7 @@
newFile(path, content: initialCode);
var requestedResult =
- await session.getLibraryByUri2(uriStr) as LibraryElementResult;
+ await session.getLibraryByUri(uriStr) as LibraryElementResult;
var requestedLibrary = requestedResult.element;
var requestedElement = requestedLibrary.exportNamespace.get(name);
expect(requestedElement, isNotNull, reason: '`$name` in $uriStr');
diff --git a/pkg/analyzer_plugin/test/support/abstract_context.dart b/pkg/analyzer_plugin/test/support/abstract_context.dart
index 6bd18116..6d58ad9 100644
--- a/pkg/analyzer_plugin/test/support/abstract_context.dart
+++ b/pkg/analyzer_plugin/test/support/abstract_context.dart
@@ -98,7 +98,7 @@
Future<ResolvedUnitResult> resolveFile(String path) async {
var session = contextFor(path).currentSession;
- return await session.getResolvedUnit2(path) as ResolvedUnitResult;
+ return await session.getResolvedUnit(path) as ResolvedUnitResult;
}
void setUp() {
diff --git a/pkg/analyzer_utilities/lib/verify_tests.dart b/pkg/analyzer_utilities/lib/verify_tests.dart
index 201e88d..de1bf43 100644
--- a/pkg/analyzer_utilities/lib/verify_tests.dart
+++ b/pkg/analyzer_utilities/lib/verify_tests.dart
@@ -103,7 +103,7 @@
if (isOkForTestAllToBeMissing(directory)) {
fail('Found "test_all.dart" in $relativePath but did not expect one');
}
- var result = session.getParsedUnit2(testAllFile.path);
+ var result = session.getParsedUnit(testAllFile.path);
if (result is! ParsedUnitResult) {
fail('Could not parse ${testAllFile.path}');
}
diff --git a/pkg/nnbd_migration/lib/migration_cli.dart b/pkg/nnbd_migration/lib/migration_cli.dart
index c592edc..bcd7f99 100644
--- a/pkg/nnbd_migration/lib/migration_cli.dart
+++ b/pkg/nnbd_migration/lib/migration_cli.dart
@@ -1000,7 +1000,7 @@
bool get isPreviewServerRunning => _task?.isPreviewServerRunning ?? false;
LineInfo getLineInfo(String path) =>
- (context.currentSession.getFile2(path) as FileResult).lineInfo;
+ (context.currentSession.getFile(path) as FileResult).lineInfo;
void prepareToRerun() {
var driver = context.driver;
@@ -1015,11 +1015,11 @@
var pathsProcessed = <String?>{};
for (var path in pathsToProcess) {
if (pathsProcessed.contains(path)) continue;
- var result = await driver.getResolvedLibrary2(path);
+ var result = await driver.getResolvedLibrary(path);
// Parts will either be found in a library, below, or if the library
// isn't [isIncluded], will be picked up in the final loop.
if (result is ResolvedLibraryResult) {
- for (var unit in result.units!) {
+ for (var unit in result.units) {
if (!pathsProcessed.contains(unit.path)) {
await process(unit);
pathsProcessed.add(unit.path);
@@ -1029,7 +1029,7 @@
}
for (var path in pathsToProcess.difference(pathsProcessed)) {
- var result = await driver.getResolvedUnit2(path);
+ var result = await driver.getResolvedUnit(path);
if (result is ResolvedUnitResult) {
await process(result);
}
diff --git a/pkg/nnbd_migration/lib/src/front_end/info_builder.dart b/pkg/nnbd_migration/lib/src/front_end/info_builder.dart
index def1ec6..ecc8a99 100644
--- a/pkg/nnbd_migration/lib/src/front_end/info_builder.dart
+++ b/pkg/nnbd_migration/lib/src/front_end/info_builder.dart
@@ -96,9 +96,9 @@
for (var filePath in sources) {
progressBar.tick();
var session = driverProvider!.getAnalysisSession(filePath);
- var result = await session.getResolvedLibrary2(filePath!);
+ var result = await session.getResolvedLibrary(filePath!);
if (result is ResolvedLibraryResult) {
- for (var unitResult in result.units!) {
+ for (var unitResult in result.units) {
var sourceInfo =
sourceInfoMap[unitResult.unit!.declaredElement!.source];
// Note: there might have been no information for this unit in
diff --git a/pkg/nnbd_migration/test/abstract_context.dart b/pkg/nnbd_migration/test/abstract_context.dart
index 1b2b8a3..bd4a688 100644
--- a/pkg/nnbd_migration/test/abstract_context.dart
+++ b/pkg/nnbd_migration/test/abstract_context.dart
@@ -120,7 +120,7 @@
}
LineInfo getLineInfo(String path) =>
- (session.getFile2(path) as FileResult).lineInfo;
+ (session.getFile(path) as FileResult).lineInfo;
void setUp() {
setupResourceProvider();
diff --git a/pkg/nnbd_migration/test/abstract_single_unit.dart b/pkg/nnbd_migration/test/abstract_single_unit.dart
index dc9049a..7934ab3 100644
--- a/pkg/nnbd_migration/test/abstract_single_unit.dart
+++ b/pkg/nnbd_migration/test/abstract_single_unit.dart
@@ -38,7 +38,7 @@
Future<void> resolveTestUnit(String code) async {
addTestSource(code, testUri);
testAnalysisResult =
- await session.getResolvedUnit2(testFile) as ResolvedUnitResult;
+ await session.getResolvedUnit(testFile) as ResolvedUnitResult;
testUnit = testAnalysisResult.unit;
if (verifyNoTestUnitErrors) {
expect(testAnalysisResult.errors.where((AnalysisError error) {
diff --git a/pkg/nnbd_migration/test/api_test.dart b/pkg/nnbd_migration/test/api_test.dart
index 6d1fe57..fc4fe55 100644
--- a/pkg/nnbd_migration/test/api_test.dart
+++ b/pkg/nnbd_migration/test/api_test.dart
@@ -65,9 +65,9 @@
removeViaComments: removeViaComments,
warnOnWeakCode: warnOnWeakCode);
for (var path in input.keys) {
- var resolvedLibrary = await session.getResolvedLibrary2(path);
+ var resolvedLibrary = await session.getResolvedLibrary(path);
if (resolvedLibrary is ResolvedLibraryResult) {
- for (var unit in resolvedLibrary.units!) {
+ for (var unit in resolvedLibrary.units) {
var errors =
unit.errors.where((e) => e.severity == Severity.error).toList();
if (!allowErrors && errors.isNotEmpty) {
@@ -80,18 +80,18 @@
expect(migration.unmigratedDependencies, isEmpty);
_betweenStages();
for (var path in input.keys) {
- var resolvedLibrary = await session.getResolvedLibrary2(path);
+ var resolvedLibrary = await session.getResolvedLibrary(path);
if (resolvedLibrary is ResolvedLibraryResult) {
- for (var unit in resolvedLibrary.units!) {
+ for (var unit in resolvedLibrary.units) {
migration.processInput(unit);
}
}
}
_betweenStages();
for (var path in input.keys) {
- var resolvedLibrary = await session.getResolvedLibrary2(path);
+ var resolvedLibrary = await session.getResolvedLibrary(path);
if (resolvedLibrary is ResolvedLibraryResult) {
- for (var unit in resolvedLibrary.units!) {
+ for (var unit in resolvedLibrary.units) {
migration.finalizeInput(unit);
}
}
diff --git a/pkg/nnbd_migration/test/front_end/info_builder_test.dart b/pkg/nnbd_migration/test/front_end/info_builder_test.dart
index e4da1b7..d1c96e4 100644
--- a/pkg/nnbd_migration/test/front_end/info_builder_test.dart
+++ b/pkg/nnbd_migration/test/front_end/info_builder_test.dart
@@ -24,7 +24,7 @@
@reflectiveTest
class BuildEnclosingMemberDescriptionTest extends AbstractAnalysisTest {
Future<ResolvedUnitResult> resolveTestFile() async {
- return await session.getResolvedUnit2(testFile!) as ResolvedUnitResult;
+ return await session.getResolvedUnit(testFile!) as ResolvedUnitResult;
}
Future<void> test_classConstructor_named() async {
diff --git a/pkg/nnbd_migration/test/front_end/nnbd_migration_test_base.dart b/pkg/nnbd_migration/test/front_end/nnbd_migration_test_base.dart
index 96c987d..451a1d7 100644
--- a/pkg/nnbd_migration/test/front_end/nnbd_migration_test_base.dart
+++ b/pkg/nnbd_migration/test/front_end/nnbd_migration_test_base.dart
@@ -236,7 +236,7 @@
Future<void> _forEachPath(
void Function(ResolvedUnitResult) callback) async {
for (var testPath in testPaths) {
- var result = await driver!.currentSession.getResolvedUnit2(testPath!)
+ var result = await driver!.currentSession.getResolvedUnit(testPath!)
as ResolvedUnitResult;
callback(result);
}
diff --git a/pkg/nnbd_migration/test/instrumentation_test.dart b/pkg/nnbd_migration/test/instrumentation_test.dart
index be4ba0d..f2df090 100644
--- a/pkg/nnbd_migration/test/instrumentation_test.dart
+++ b/pkg/nnbd_migration/test/instrumentation_test.dart
@@ -149,7 +149,7 @@
removeViaComments: removeViaComments,
warnOnWeakCode: warnOnWeakCode);
var result =
- await session.getResolvedUnit2(sourcePath) as ResolvedUnitResult;
+ await session.getResolvedUnit(sourcePath) as ResolvedUnitResult;
source = result.unit!.declaredElement!.source;
findNode = FindNode(content, result.unit!);
migration.prepareInput(result);
diff --git a/pkg/nnbd_migration/tool/trial_migration.dart b/pkg/nnbd_migration/tool/trial_migration.dart
index 4422c58..982cbf7 100644
--- a/pkg/nnbd_migration/tool/trial_migration.dart
+++ b/pkg/nnbd_migration/tool/trial_migration.dart
@@ -67,12 +67,12 @@
files.addAll(localFiles);
var session = context.currentSession;
LineInfo getLineInfo(String path) =>
- (session.getFile2(path) as FileResult).lineInfo;
+ (session.getFile(path) as FileResult).lineInfo;
var migration =
NullabilityMigration(listener, getLineInfo, permissive: true);
for (var file in localFiles) {
var resolvedUnit =
- await session.getResolvedUnit2(file) as ResolvedUnitResult;
+ await session.getResolvedUnit(file) as ResolvedUnitResult;
if (!resolvedUnit.errors.any((e) => e.severity == Severity.error)) {
migration.prepareInput(resolvedUnit);
} else {
@@ -81,14 +81,14 @@
}
for (var file in localFiles) {
var resolvedUnit =
- await session.getResolvedUnit2(file) as ResolvedUnitResult;
+ await session.getResolvedUnit(file) as ResolvedUnitResult;
if (!resolvedUnit.errors.any((e) => e.severity == Severity.error)) {
migration.processInput(resolvedUnit);
}
}
for (var file in localFiles) {
var resolvedUnit =
- await session.getResolvedUnit2(file) as ResolvedUnitResult;
+ await session.getResolvedUnit(file) as ResolvedUnitResult;
if (!resolvedUnit.errors.any((e) => e.severity == Severity.error)) {
migration.finalizeInput(resolvedUnit);
}
diff --git a/pkg/scrape/example/annotation_arguments.dart b/pkg/scrape/example/annotation_arguments.dart
new file mode 100644
index 0000000..cf5da95
--- /dev/null
+++ b/pkg/scrape/example/annotation_arguments.dart
@@ -0,0 +1,81 @@
+// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+import 'package:analyzer/dart/ast/ast.dart';
+import 'package:scrape/scrape.dart';
+
+void main(List<String> arguments) {
+ Scrape()
+ ..addHistogram('Has argument list?')
+ ..addHistogram('Arguments', order: SortOrder.numeric)
+ ..addHistogram('Argument type')
+ ..addHistogram('Argument identifier')
+ ..addHistogram('Annotation')
+ ..addVisitor(() => AnnotationVisitor())
+ ..runCommandLine(arguments);
+}
+
+class AnnotationVisitor extends ScrapeVisitor {
+ @override
+ void visitAnnotation(Annotation node) {
+ record('Annotation', node.name.name);
+
+ var arguments = node.arguments;
+ if (arguments != null) {
+ record('Has argument list?', 'yes');
+ record('Arguments', arguments.arguments.length);
+ arguments.arguments.forEach(_recordArgument);
+ } else {
+ record('Has argument list?', 'no');
+ }
+
+ super.visitAnnotation(node);
+ }
+
+ void _recordArgument(AstNode? node) {
+ if (node is NamedExpression) {
+ _recordArgument(node.expression);
+ } else if (node is IfElement) {
+ _recordArgument(node.thenElement);
+ _recordArgument(node.elseElement);
+ } else if (node is ForElement) {
+ _recordArgument(node.body);
+ } else if (node is SpreadElement) {
+ _recordArgument(node.expression);
+ } else if (node is MapLiteralEntry) {
+ _recordArgument(node.key);
+ _recordArgument(node.value);
+ } else if (node is SimpleIdentifier || node is PrefixedIdentifier) {
+ record('Argument identifier', node.toString());
+ record('Argument type', 'identifier');
+ } else if (node is PrefixExpression) {
+ record('Argument type', 'unary operator');
+ } else if (node is BinaryExpression) {
+ record('Argument type', 'binary operator');
+ } else if (node is BooleanLiteral) {
+ record('Argument type', 'bool');
+ } else if (node is DoubleLiteral) {
+ record('Argument type', 'double');
+ } else if (node is IntegerLiteral) {
+ record('Argument type', 'int');
+ } else if (node is ListLiteral) {
+ record('Argument type', 'list');
+ node.elements.forEach(_recordArgument);
+ } else if (node is MethodInvocation) {
+ record('Argument type', 'method call');
+ } else if (node is NullLiteral) {
+ record('Argument type', 'null');
+ } else if (node is SetOrMapLiteral) {
+ record('Argument type', 'set or map');
+ node.elements.forEach(_recordArgument);
+ } else if (node is StringLiteral) {
+ record('Argument type', 'string');
+ } else if (node is SymbolLiteral) {
+ record('Argument type', 'symbol');
+ } else if (node == null) {
+ // Do nothing. Only happens for null else elements.
+ } else {
+ record('Argument type', node.runtimeType.toString());
+ }
+ }
+}
diff --git a/pkg/scrape/lib/src/histogram.dart b/pkg/scrape/lib/src/histogram.dart
index 74e35df..e27f137 100644
--- a/pkg/scrape/lib/src/histogram.dart
+++ b/pkg/scrape/lib/src/histogram.dart
@@ -86,14 +86,25 @@
}
}
- if (skipped > 0) print('And $skipped more less than 0.1%...');
+ if (skipped > 0) print('And $skipped more...');
// If we're counting numeric keys, show other statistics too.
if (_order == SortOrder.numeric && keys.isNotEmpty) {
var sum = keys.fold<int>(
0, (result, key) => result + (key as int) * _counts[key]!);
var average = sum / total;
- var median = _counts[keys[keys.length ~/ 2]];
+
+ // Find the median key where half the total count is below it.
+ var count = 0;
+ var median = -1;
+ for (var key in keys) {
+ count += _counts[key]!;
+ if (count >= total ~/ 2) {
+ median = key as int;
+ break;
+ }
+ }
+
print('Sum $sum, average ${average.toStringAsFixed(3)}, median $median');
}
}
diff --git a/pkg/test_runner/tool/orphan_files.dart b/pkg/test_runner/tool/orphan_files.dart
index 8d7e8f6..968458b 100644
--- a/pkg/test_runner/tool/orphan_files.dart
+++ b/pkg/test_runner/tool/orphan_files.dart
@@ -74,7 +74,7 @@
void _parseReferences(Set<String> importedPaths, String filePath) {
var absolute = Path(filePath).absolute.toNativePath();
- var parseResult = _analysisContext.currentSession.getParsedUnit2(absolute);
+ var parseResult = _analysisContext.currentSession.getParsedUnit(absolute);
var unit = (parseResult as ParsedUnitResult).unit;
void add(String importPath) {
diff --git a/runtime/bin/security_context_macos.cc b/runtime/bin/security_context_macos.cc
index 410a33b..357173d 100644
--- a/runtime/bin/security_context_macos.cc
+++ b/runtime/bin/security_context_macos.cc
@@ -162,15 +162,13 @@
ScopedCFMutableArrayRef trusted_certs(CFArrayCreateMutable(NULL, 0, NULL));
ASSERT(store != NULL);
- if (store->objs != NULL) {
- for (uintptr_t i = 0; i < sk_X509_OBJECT_num(store->objs); ++i) {
- X509* ca = sk_X509_OBJECT_value(store->objs, i)->data.x509;
- ScopedSecCertificateRef cert(CreateSecCertificateFromX509(ca));
- if (cert == NULL) {
- return ssl_verify_invalid;
- }
- CFArrayAppendValue(trusted_certs.get(), cert.release());
+ for (const X509_OBJECT* obj : X509_STORE_get0_objects(store)) {
+ X509* ca = X509_OBJECT_get0_X509(obj);
+ ScopedSecCertificateRef cert(CreateSecCertificateFromX509(ca));
+ if (cert == NULL) {
+ return ssl_verify_invalid;
}
+ CFArrayAppendValue(trusted_certs.get(), cert.release());
}
// Generate a policy for validating chains for SSL.
diff --git a/runtime/tools/dartfuzz/gen_api_table.dart b/runtime/tools/dartfuzz/gen_api_table.dart
index 869bfc3..365a50a 100644
--- a/runtime/tools/dartfuzz/gen_api_table.dart
+++ b/runtime/tools/dartfuzz/gen_api_table.dart
@@ -348,7 +348,7 @@
final libPath = session.uriConverter.uriToPath(Uri.parse(uri));
var result = await session.getResolvedLibrary2(libPath!);
if (result is ResolvedLibraryResult) {
- visitLibrary(result.element!);
+ visitLibrary(result.element);
} else {
throw StateError('Unable to resolve "$uri"');
}
diff --git a/runtime/tools/dartfuzz/gen_type_table.dart b/runtime/tools/dartfuzz/gen_type_table.dart
index ea2ac48..0f2599a 100644
--- a/runtime/tools/dartfuzz/gen_type_table.dart
+++ b/runtime/tools/dartfuzz/gen_type_table.dart
@@ -1342,7 +1342,7 @@
var libPath = session.uriConverter.uriToPath(Uri.parse(uri));
var result = await session.getResolvedLibrary2(libPath!);
if (result is ResolvedLibraryResult) {
- visitLibrary(result.element!, allTypes);
+ visitLibrary(result.element, allTypes);
} else {
throw StateError('Unable to resolve "$uri"');
}
diff --git a/runtime/vm/compiler/assembler/assembler_arm64_test.cc b/runtime/vm/compiler/assembler/assembler_arm64_test.cc
index 53d2adf..6aa5b48 100644
--- a/runtime/vm/compiler/assembler/assembler_arm64_test.cc
+++ b/runtime/vm/compiler/assembler/assembler_arm64_test.cc
@@ -4737,8 +4737,8 @@
__ mov(THR, R2);
__ ldr(HEAP_BITS, Address(THR, Thread::write_barrier_mask_offset()));
__ LslImmediate(HEAP_BITS, HEAP_BITS, 32);
- __ StoreIntoObject(R1, FieldAddress(R1, GrowableObjectArray::data_offset()),
- R0);
+ __ StoreCompressedIntoObject(
+ R1, FieldAddress(R1, GrowableObjectArray::data_offset()), R0);
RESTORES_LR_FROM_FRAME(__ Pop(LR));
__ Pop(HEAP_BITS);
__ Pop(THR);
diff --git a/runtime/vm/compiler/assembler/assembler_test.cc b/runtime/vm/compiler/assembler/assembler_test.cc
index 8488eae..16342bd 100644
--- a/runtime/vm/compiler/assembler/assembler_test.cc
+++ b/runtime/vm/compiler/assembler/assembler_test.cc
@@ -38,7 +38,8 @@
for (int i = -128; i < 128; i++) {
smi = Smi::New(i);
TEST_CODE(smi.ptr(), grow_old_array.ptr(), thread);
- EXPECT(static_cast<ArrayPtr>(smi.ptr()) == grow_old_array.data());
+ EXPECT(static_cast<CompressedObjectPtr>(smi.ptr()) ==
+ static_cast<CompressedObjectPtr>(grow_old_array.data()));
EXPECT(!thread->StoreBufferContains(grow_old_array.ptr()));
}
diff --git a/runtime/vm/compiler/assembler/assembler_x64_test.cc b/runtime/vm/compiler/assembler/assembler_x64_test.cc
index 00eeead..5745bd1 100644
--- a/runtime/vm/compiler/assembler/assembler_x64_test.cc
+++ b/runtime/vm/compiler/assembler/assembler_x64_test.cc
@@ -5309,10 +5309,10 @@
__ pushq(CODE_REG);
__ pushq(THR);
__ movq(THR, CallingConventions::kArg3Reg);
- __ StoreIntoObject(CallingConventions::kArg2Reg,
- FieldAddress(CallingConventions::kArg2Reg,
- GrowableObjectArray::data_offset()),
- CallingConventions::kArg1Reg);
+ __ StoreCompressedIntoObject(CallingConventions::kArg2Reg,
+ FieldAddress(CallingConventions::kArg2Reg,
+ GrowableObjectArray::data_offset()),
+ CallingConventions::kArg1Reg);
__ popq(THR);
__ popq(CODE_REG);
__ ret();
diff --git a/runtime/vm/compiler/runtime_api.cc b/runtime/vm/compiler/runtime_api.cc
index f711e69..e1ad228 100644
--- a/runtime/vm/compiler/runtime_api.cc
+++ b/runtime/vm/compiler/runtime_api.cc
@@ -315,8 +315,8 @@
const word kOldPageMask = dart::kOldPageMask;
static word TranslateOffsetInWordsToHost(word offset) {
- RELEASE_ASSERT((offset % kWordSize) == 0);
- return (offset / kWordSize) * dart::kWordSize;
+ RELEASE_ASSERT((offset % kCompressedWordSize) == 0);
+ return (offset / kCompressedWordSize) * dart::kCompressedWordSize;
}
bool SizeFitsInSizeTag(uword instance_size) {
diff --git a/tools/VERSION b/tools/VERSION
index 2cc3d43..8225f5d 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 14
PATCH 0
-PRERELEASE 307
+PRERELEASE 308
PRERELEASE_PATCH 0
\ No newline at end of file