Version 2.17.0-225.0.dev
Merge commit '50c5b075ecfda557fcbb753a33cc943abfe5bc83' into 'dev'
diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn
index a9e3ca4..6cfcf26 100644
--- a/build/config/compiler/BUILD.gn
+++ b/build/config/compiler/BUILD.gn
@@ -359,7 +359,10 @@
# not be compatible with newer ones. To achieve this, we insert a synthetic
# define into the compile line.
if (is_clang && (is_linux || is_mac)) {
- if (is_linux) {
+ if (is_linux && host_cpu == "arm64") {
+ toolchain_stamp_file =
+ "//buildtools/linux-arm64/clang/.versions/clang.cipd_version"
+ } else if (is_linux) {
toolchain_stamp_file =
"//buildtools/linux-x64/clang/.versions/clang.cipd_version"
} else {
diff --git a/build/toolchain/linux/BUILD.gn b/build/toolchain/linux/BUILD.gn
index 5f9bc32..05630d0 100644
--- a/build/toolchain/linux/BUILD.gn
+++ b/build/toolchain/linux/BUILD.gn
@@ -21,6 +21,14 @@
compiler_prefix = ""
}
+if (host_cpu == "arm64") {
+ rebased_clang_dir =
+ rebase_path("//buildtools/linux-arm64/clang/bin", root_build_dir)
+} else {
+ rebased_clang_dir =
+ rebase_path("//buildtools/linux-x64/clang/bin", root_build_dir)
+}
+
gcc_toolchain("arm") {
prefix = "arm-linux-gnueabihf-"
if (toolchain_prefix != "") {
@@ -42,7 +50,7 @@
}
gcc_toolchain("clang_arm") {
- prefix = rebase_path("//buildtools/linux-x64/clang/bin", root_build_dir)
+ prefix = rebased_clang_dir
cc = "${compiler_prefix}${prefix}/clang"
cxx = "${compiler_prefix}${prefix}/clang++"
@@ -78,7 +86,7 @@
}
gcc_toolchain("clang_arm64") {
- prefix = rebase_path("//buildtools/linux-x64/clang/bin", root_build_dir)
+ prefix = rebased_clang_dir
cc = "${compiler_prefix}${prefix}/clang"
cxx = "${compiler_prefix}${prefix}/clang++"
@@ -94,7 +102,7 @@
}
gcc_toolchain("clang_x86") {
- prefix = rebase_path("//buildtools/linux-x64/clang/bin", root_build_dir)
+ prefix = rebased_clang_dir
cc = "${compiler_prefix}${prefix}/clang"
cxx = "${compiler_prefix}${prefix}/clang++"
@@ -126,7 +134,7 @@
}
gcc_toolchain("clang_x64") {
- prefix = rebase_path("//buildtools/linux-x64/clang/bin", root_build_dir)
+ prefix = rebased_clang_dir
cc = "${compiler_prefix}${prefix}/clang"
cxx = "${compiler_prefix}${prefix}/clang++"
@@ -178,7 +186,7 @@
}
gcc_toolchain("clang_riscv32") {
- prefix = rebase_path("//buildtools/linux-x64/clang/bin", root_build_dir)
+ prefix = rebased_clang_dir
cc = "${compiler_prefix}${prefix}/clang"
cxx = "${compiler_prefix}${prefix}/clang++"
@@ -214,7 +222,7 @@
}
gcc_toolchain("clang_riscv64") {
- prefix = rebase_path("//buildtools/linux-x64/clang/bin", root_build_dir)
+ prefix = rebased_clang_dir
cc = "${compiler_prefix}${prefix}/clang"
cxx = "${compiler_prefix}${prefix}/clang++"
diff --git a/pkg/analysis_server/lib/src/analysis_server_abstract.dart b/pkg/analysis_server/lib/src/analysis_server_abstract.dart
index e3e804f..93f4244 100644
--- a/pkg/analysis_server/lib/src/analysis_server_abstract.dart
+++ b/pkg/analysis_server/lib/src/analysis_server_abstract.dart
@@ -420,7 +420,7 @@
return null;
}
- var result = await session.getParsedUnit2(path);
+ var result = session.getParsedUnit(path);
return result is ParsedUnitResult ? result : null;
}
diff --git a/pkg/analysis_server/lib/src/cider/assists.dart b/pkg/analysis_server/lib/src/cider/assists.dart
index ba46cce..6b51f05 100644
--- a/pkg/analysis_server/lib/src/cider/assists.dart
+++ b/pkg/analysis_server/lib/src/cider/assists.dart
@@ -21,7 +21,7 @@
Future<List<Assist>> compute(
String path, int lineNumber, int colNumber, int length) async {
var result = <Assist>[];
- var resolvedUnit = _fileResolver.resolve(path: path);
+ var resolvedUnit = await _fileResolver.resolve2(path: path);
var lineInfo = resolvedUnit.lineInfo;
var offset = lineInfo.getOffsetOfLine(lineNumber) + colNumber;
diff --git a/pkg/analysis_server/lib/src/cider/completion.dart b/pkg/analysis_server/lib/src/cider/completion.dart
index 25a8bf9..86e6d59 100644
--- a/pkg/analysis_server/lib/src/cider/completion.dart
+++ b/pkg/analysis_server/lib/src/cider/completion.dart
@@ -54,14 +54,17 @@
@visibleForTesting void Function(ResolvedUnitResult)? testResolvedUnit,
}) async {
return _performanceRoot.runAsync('completion', (performance) async {
- var resolvedUnit = performance.run('resolution', (performance) {
- return _fileResolver.resolve(
- completionLine: line,
- completionColumn: column,
- path: path,
- performance: performance,
- );
- });
+ var resolvedUnit = await performance.runAsync(
+ 'resolution',
+ (performance) async {
+ return _fileResolver.resolve2(
+ completionLine: line,
+ completionColumn: column,
+ path: path,
+ performance: performance,
+ );
+ },
+ );
if (testResolvedUnit != null) {
testResolvedUnit(resolvedUnit);
diff --git a/pkg/analysis_server/lib/src/cider/document_symbols.dart b/pkg/analysis_server/lib/src/cider/document_symbols.dart
index a1782db..48aec9f 100644
--- a/pkg/analysis_server/lib/src/cider/document_symbols.dart
+++ b/pkg/analysis_server/lib/src/cider/document_symbols.dart
@@ -15,6 +15,7 @@
CiderDocumentSymbolsComputer(this._fileResolver);
+ @Deprecated('Use compute2() instead')
List<DocumentSymbol> compute(String filePath) {
var result = <DocumentSymbol>[];
var resolvedUnit = _fileResolver.resolve(path: filePath);
@@ -35,6 +36,11 @@
return result;
}
+ Future<List<DocumentSymbol>> compute2(String filePath) async {
+ // ignore: deprecated_member_use_from_same_package
+ return compute(filePath);
+ }
+
DocumentSymbol _asDocumentSymbol(
Set<SymbolKind> supportedKinds,
LineInfo lineInfo,
diff --git a/pkg/analysis_server/lib/src/cider/fixes.dart b/pkg/analysis_server/lib/src/cider/fixes.dart
index 6b65f24..fd9efd7 100644
--- a/pkg/analysis_server/lib/src/cider/fixes.dart
+++ b/pkg/analysis_server/lib/src/cider/fixes.dart
@@ -40,7 +40,7 @@
/// Compute quick fixes for errors on the line with the [offset].
Future<List<CiderErrorFixes>> compute(String path, int lineNumber) async {
var result = <CiderErrorFixes>[];
- var resolvedUnit = _fileResolver.resolve(path: path);
+ var resolvedUnit = await _fileResolver.resolve2(path: path);
var lineInfo = resolvedUnit.lineInfo;
@@ -89,7 +89,7 @@
var files = _fileResolver.getFilesWithTopLevelDeclarations(name);
for (var file in files) {
if (file.partOfLibrary == null) {
- var libraryElement = _fileResolver.getLibraryByUri(
+ var libraryElement = await _fileResolver.getLibraryByUri2(
uriStr: file.uriStr,
);
TopLevelDeclarations.addElement(result, libraryElement, name);
diff --git a/pkg/analysis_server/lib/src/cider/rename.dart b/pkg/analysis_server/lib/src/cider/rename.dart
index 44eadad..dd17833 100644
--- a/pkg/analysis_server/lib/src/cider/rename.dart
+++ b/pkg/analysis_server/lib/src/cider/rename.dart
@@ -81,6 +81,7 @@
String get oldName => canRename.refactoringElement.element.displayName;
+ @Deprecated('Use computeRenameRanges2() instead')
RenameResponse? computeRenameRanges() {
var elements = <Element>[];
var element = canRename.refactoringElement.element;
@@ -105,6 +106,11 @@
}
return RenameResponse(matches, this, flutterWidgetRename: flutterRename);
}
+
+ Future<RenameResponse?> computeRenameRanges2() async {
+ // ignore: deprecated_member_use_from_same_package
+ return computeRenameRanges();
+ }
}
class CiderRenameComputer {
@@ -114,6 +120,7 @@
/// Check if the identifier at the [line], [column] for the file at the
/// [filePath] can be renamed.
+ @Deprecated('Use canRename2() instead')
CanRenameResponse? canRename(String filePath, int line, int column) {
var resolvedUnit = _fileResolver.resolve(path: filePath);
var lineInfo = resolvedUnit.lineInfo;
@@ -144,6 +151,14 @@
return null;
}
+ /// Check if the identifier at the [line], [column] for the file at the
+ /// [filePath] can be renamed.
+ Future<CanRenameResponse?> canRename2(
+ String filePath, int line, int column) async {
+ // ignore: deprecated_member_use_from_same_package
+ return canRename(filePath, line, column);
+ }
+
bool _canRenameElement(Element element) {
var enclosingElement = element.enclosingElement;
if (element is ConstructorElement) {
diff --git a/pkg/analysis_server/lib/src/cider/signature_help.dart b/pkg/analysis_server/lib/src/cider/signature_help.dart
index 6b3616a..4bf5e60 100644
--- a/pkg/analysis_server/lib/src/cider/signature_help.dart
+++ b/pkg/analysis_server/lib/src/cider/signature_help.dart
@@ -15,6 +15,7 @@
CiderSignatureHelpComputer(this._fileResolver);
+ @Deprecated('Use compute2() instead')
SignatureHelpResponse? compute(String filePath, int line, int column) {
var resolvedUnit = _fileResolver.resolve(path: filePath);
var lineInfo = resolvedUnit.lineInfo;
@@ -44,6 +45,12 @@
}
return null;
}
+
+ Future<SignatureHelpResponse?> compute2(
+ String filePath, int line, int column) async {
+ // ignore: deprecated_member_use_from_same_package
+ return compute(filePath, line, column);
+ }
}
class SignatureHelpResponse {
diff --git a/pkg/analysis_server/lib/src/lsp/handlers/commands/sort_members.dart b/pkg/analysis_server/lib/src/lsp/handlers/commands/sort_members.dart
index 461d11e..d10e4db 100644
--- a/pkg/analysis_server/lib/src/lsp/handlers/commands/sort_members.dart
+++ b/pkg/analysis_server/lib/src/lsp/handlers/commands/sort_members.dart
@@ -35,8 +35,8 @@
final path = arguments.single as String;
final docIdentifier = server.getVersionedDocumentIdentifier(path);
- var driver = server.getAnalysisDriver(path);
- final result = await driver?.parseFile(path);
+ var session = await server.getAnalysisSession(path);
+ final result = session?.getParsedUnit(path);
if (cancellationToken.isCancellationRequested) {
return error(ErrorCodes.RequestCancelled, 'Request was cancelled');
diff --git a/pkg/analysis_server/lib/src/lsp/handlers/handler_definition.dart b/pkg/analysis_server/lib/src/lsp/handlers/handler_definition.dart
index 4bad778..f65aa56 100644
--- a/pkg/analysis_server/lib/src/lsp/handlers/handler_definition.dart
+++ b/pkg/analysis_server/lib/src/lsp/handlers/handler_definition.dart
@@ -270,7 +270,7 @@
return null;
}
- var parsedLibrary = await session.getParsedLibrary2(libraryPath);
+ var parsedLibrary = session.getParsedLibrary(libraryPath);
if (parsedLibrary is! ParsedLibraryResult) {
return null;
}
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 32d5365..2a0bf1f 100644
--- a/pkg/analysis_server/lib/src/services/refactoring/rename_import.dart
+++ b/pkg/analysis_server/lib/src/services/refactoring/rename_import.dart
@@ -106,7 +106,7 @@
Future<ImportDirective?> _findNode() async {
var library = element.library;
var path = library.source.fullName;
- var unitResult = await session.getParsedUnit2(path);
+ var unitResult = session.getParsedUnit(path);
if (unitResult is! ParsedUnitResult) {
return null;
}
@@ -122,7 +122,7 @@
SourceReference reference,
) async {
var source = reference.element.source!;
- var unitResult = await session.getParsedUnit2(source.fullName);
+ var unitResult = session.getParsedUnit(source.fullName);
if (unitResult is! ParsedUnitResult) {
return null;
}
diff --git a/pkg/analysis_server/test/integration/linter/lint_names_test.dart b/pkg/analysis_server/test/integration/linter/lint_names_test.dart
index 20eea76..1b8e5d0 100644
--- a/pkg/analysis_server/test/integration/linter/lint_names_test.dart
+++ b/pkg/analysis_server/test/integration/linter/lint_names_test.dart
@@ -23,10 +23,10 @@
var contextCollection = AnalysisContextCollection(
includedPaths: [fixFilePath],
);
- var parseResult = await contextCollection
+ var parseResult = contextCollection
.contextFor(fixFilePath)
.currentSession
- .getParsedUnit2(fixFilePath) as ParsedUnitResult;
+ .getParsedUnit(fixFilePath) as ParsedUnitResult;
if (parseResult.errors.isNotEmpty) {
throw Exception(parseResult.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 ff4bf5f..bd2bf66 100644
--- a/pkg/analysis_server/test/services/correction/sort_members_test.dart
+++ b/pkg/analysis_server/test/services/correction/sort_members_test.dart
@@ -1512,8 +1512,7 @@
Future<void> _parseTestUnit(String code) async {
addTestSource(code);
- var result =
- await (await session).getParsedUnit2(testFile) as ParsedUnitResult;
+ var result = (await session).getParsedUnit(testFile) as ParsedUnitResult;
lineInfo = result.lineInfo;
testUnit = result.unit;
}
diff --git a/pkg/analysis_server/test/src/cider/document_symbols_test.dart b/pkg/analysis_server/test/src/cider/document_symbols_test.dart
index 07a7536..84563f3 100644
--- a/pkg/analysis_server/test/src/cider/document_symbols_test.dart
+++ b/pkg/analysis_server/test/src/cider/document_symbols_test.dart
@@ -18,8 +18,8 @@
@reflectiveTest
class CiderDocumentSymbolsComputerTest extends CiderServiceTest {
- void test_class() {
- var unitOutline = _compute('''
+ void test_class() async {
+ var unitOutline = await _compute('''
abstract class A<K, V> {
int fa, fb;
String fc;
@@ -145,10 +145,10 @@
}
}
- void test_isTest_isTestGroup() {
+ void test_isTest_isTestGroup() async {
BazelMockPackages.instance.addMeta(resourceProvider);
- var outline = _compute('''
+ var outline = await _compute('''
import 'package:meta/meta.dart';
@isTestGroup
@@ -268,11 +268,11 @@
);
}
- List<DocumentSymbol> _compute(String content) {
+ Future<List<DocumentSymbol>> _compute(String content) async {
newFile2(testPath, content);
return CiderDocumentSymbolsComputer(
fileResolver,
- ).compute(convertPath(testPath));
+ ).compute2(convertPath(testPath));
}
void _expect(DocumentSymbol outline,
diff --git a/pkg/analysis_server/test/src/cider/fixes_test.dart b/pkg/analysis_server/test/src/cider/fixes_test.dart
index 8bb64dc..0d08766 100644
--- a/pkg/analysis_server/test/src/cider/fixes_test.dart
+++ b/pkg/analysis_server/test/src/cider/fixes_test.dart
@@ -76,7 +76,7 @@
var a = newFile2('/workspace/dart/test/lib/a.dart', r'''
class Test {}
''');
- fileResolver.resolve(path: a.path);
+ await fileResolver.resolve2(path: a.path);
await _compute(r'''
void f(Test a) {}^
@@ -93,7 +93,7 @@
var a = newFile2('/workspace/dart/test/lib/a.dart', r'''
enum Test {a, b, c}
''');
- fileResolver.resolve(path: a.path);
+ await fileResolver.resolve2(path: a.path);
await _compute(r'''
void f(Test a) {}^
@@ -112,7 +112,7 @@
void foo() {}
}
''');
- fileResolver.resolve(path: a.path);
+ await fileResolver.resolve2(path: a.path);
await _compute(r'''
void f() {
@@ -133,7 +133,7 @@
var a = newFile2('/workspace/dart/test/lib/a.dart', r'''
void foo() {}
''');
- fileResolver.resolve(path: a.path);
+ await fileResolver.resolve2(path: a.path);
await _compute(r'''
void f() {
@@ -154,7 +154,7 @@
var a = newFile2('/workspace/dart/test/lib/a.dart', r'''
mixin Test {}
''');
- fileResolver.resolve(path: a.path);
+ await fileResolver.resolve2(path: a.path);
await _compute(r'''
void f(Test a) {}^
@@ -171,7 +171,7 @@
var a = newFile2('/workspace/dart/test/lib/a.dart', r'''
var a = 0;
''');
- fileResolver.resolve(path: a.path);
+ await fileResolver.resolve2(path: a.path);
await _compute(r'''
void f() {
diff --git a/pkg/analysis_server/test/src/cider/rename_test.dart b/pkg/analysis_server/test/src/cider/rename_test.dart
index 98341fb..0147ec9 100644
--- a/pkg/analysis_server/test/src/cider/rename_test.dart
+++ b/pkg/analysis_server/test/src/cider/rename_test.dart
@@ -27,8 +27,8 @@
BazelMockPackages.instance.addFlutter(resourceProvider);
}
- void test_canRename_class() {
- var refactor = _compute(r'''
+ void test_canRename_class() async {
+ var refactor = await _compute(r'''
class ^Old {}
}
''');
@@ -37,8 +37,8 @@
expect(refactor.refactoringElement.offset, _correctionContext.offset);
}
- void test_canRename_field() {
- var refactor = _compute(r'''
+ void test_canRename_field() async {
+ var refactor = await _compute(r'''
class A {
int ^bar;
void foo() {
@@ -51,8 +51,8 @@
expect(refactor.refactoringElement.offset, _correctionContext.offset);
}
- void test_canRename_field_static_private() {
- var refactor = _compute(r'''
+ void test_canRename_field_static_private() async {
+ var refactor = await _compute(r'''
class A{
static const ^_val = 1234;
}
@@ -63,8 +63,8 @@
expect(refactor.refactoringElement.offset, _correctionContext.offset);
}
- void test_canRename_function() {
- var refactor = _compute(r'''
+ void test_canRename_function() async {
+ var refactor = await _compute(r'''
void ^foo() {
}
''');
@@ -73,8 +73,8 @@
expect(refactor.refactoringElement.offset, _correctionContext.offset);
}
- void test_canRename_label() {
- var refactor = _compute(r'''
+ void test_canRename_label() async {
+ var refactor = await _compute(r'''
main() {
myLabel:
while (true) {
@@ -89,8 +89,8 @@
expect(refactor.refactoringElement.offset, _correctionContext.offset);
}
- void test_canRename_local() {
- var refactor = _compute(r'''
+ void test_canRename_local() async {
+ var refactor = await _compute(r'''
void foo() {
var ^a = 0; var b = a + 1;
}
@@ -100,8 +100,8 @@
expect(refactor.refactoringElement.offset, _correctionContext.offset);
}
- void test_canRename_method() {
- var refactor = _compute(r'''
+ void test_canRename_method() async {
+ var refactor = await _compute(r'''
extension E on int {
void ^foo() {}
}
@@ -111,8 +111,8 @@
expect(refactor.refactoringElement.offset, _correctionContext.offset);
}
- void test_canRename_operator() {
- var refactor = _compute(r'''
+ void test_canRename_operator() async {
+ var refactor = await _compute(r'''
class A{
A operator ^+(A other) => this;
}
@@ -121,8 +121,8 @@
expect(refactor, isNull);
}
- void test_canRename_parameter() {
- var refactor = _compute(r'''
+ void test_canRename_parameter() async {
+ var refactor = await _compute(r'''
void foo(int ^bar) {
var a = bar + 1;
}
@@ -133,8 +133,8 @@
expect(refactor.refactoringElement.offset, _correctionContext.offset);
}
- void test_checkName_class() {
- var result = _checkName(r'''
+ void test_checkName_class() async {
+ var result = await _checkName(r'''
class ^Old {}
''', 'New');
@@ -142,8 +142,8 @@
expect(result.oldName, 'Old');
}
- void test_checkName_function() {
- var result = _checkName(r'''
+ void test_checkName_function() async {
+ var result = await _checkName(r'''
int ^foo() => 2;
''', 'bar');
@@ -151,8 +151,8 @@
expect(result.oldName, 'foo');
}
- void test_checkName_local() {
- var result = _checkName(r'''
+ void test_checkName_local() async {
+ var result = await _checkName(r'''
void foo() {
var ^a = 0; var b = a + 1;
}
@@ -162,8 +162,8 @@
expect(result.oldName, 'a');
}
- void test_checkName_local_invalid() {
- var result = _checkName(r'''
+ void test_checkName_local_invalid() async {
+ var result = await _checkName(r'''
void foo() {
var ^a = 0; var b = a + 1;
}
@@ -173,8 +173,8 @@
expect(result.oldName, 'a');
}
- void test_checkName_parameter() {
- var result = _checkName(r'''
+ void test_checkName_parameter() async {
+ var result = await _checkName(r'''
void foo(String ^a) {
var b = a + 1;
}
@@ -184,8 +184,8 @@
expect(result.oldName, 'a');
}
- void test_checkName_topLevelVariable() {
- var result = _checkName(r'''
+ void test_checkName_topLevelVariable() async {
+ var result = await _checkName(r'''
var ^foo;
''', 'bar');
@@ -193,8 +193,8 @@
expect(result.oldName, 'foo');
}
- void test_checkName_TypeAlias() {
- var result = _checkName(r'''
+ void test_checkName_TypeAlias() async {
+ var result = await _checkName(r'''
typedef ^Foo = void Function();
''', 'Bar');
@@ -202,8 +202,8 @@
expect(result.oldName, 'Foo');
}
- void test_rename_class() {
- var result = _rename(r'''
+ void test_rename_class() async {
+ var result = await _rename(r'''
class ^Old implements Other {
Old() {}
Old.named() {}
@@ -234,8 +234,8 @@
]);
}
- void test_rename_class_flutterWidget() {
- var result = _rename(r'''
+ void test_rename_class_flutterWidget() async {
+ var result = await _rename(r'''
import 'package:flutter/material.dart';
class ^TestPage extends StatefulWidget {
@@ -268,8 +268,8 @@
]);
}
- void test_rename_field() {
- var result = _rename(r'''
+ void test_rename_field() async {
+ var result = await _rename(r'''
class A{
int get ^x => 5;
}
@@ -286,8 +286,8 @@
]);
}
- void test_rename_field_static_private() {
- var result = _rename(r'''
+ void test_rename_field_static_private() async {
+ var result = await _rename(r'''
class A{
static const ^_val = 1234;
}
@@ -304,8 +304,8 @@
]);
}
- void test_rename_function() {
- var result = _rename(r'''
+ void test_rename_function() async {
+ var result = await _rename(r'''
test() {}
^foo() {}
void f() {
@@ -324,12 +324,12 @@
]);
}
- void test_rename_function_imported() {
+ void test_rename_function_imported() async {
var a = newFile2('/workspace/dart/test/lib/a.dart', r'''
foo() {}
''');
- fileResolver.resolve(path: a.path);
- var result = _rename(r'''
+ await fileResolver.resolve2(path: a.path);
+ var result = await _rename(r'''
import 'a.dart';
void f() {
^foo();
@@ -345,8 +345,8 @@
]);
}
- void test_rename_local() {
- var result = _rename(r'''
+ void test_rename_local() async {
+ var result = await _rename(r'''
void foo() {
var ^a = 0; var b = a + 1;
}
@@ -359,8 +359,8 @@
[CharacterLocation(2, 7), CharacterLocation(2, 22)]));
}
- void test_rename_parameter() {
- var result = _rename(r'''
+ void test_rename_parameter() async {
+ var result = await _rename(r'''
void foo(String ^a) {
var b = a + 1;
}
@@ -369,8 +369,8 @@
expect(result.checkName.oldName, 'a');
}
- void test_rename_propertyAccessor() {
- var result = _rename(r'''
+ void test_rename_propertyAccessor() async {
+ var result = await _rename(r'''
get foo {}
set foo(x) {}
void f() {
@@ -389,8 +389,8 @@
]);
}
- void test_rename_typeAlias_functionType() {
- var result = _rename(r'''
+ void test_rename_typeAlias_functionType() async {
+ var result = await _rename(r'''
typedef ^F = void Function();
void f(F a) {}
''', 'bar');
@@ -401,45 +401,42 @@
]);
}
- CheckNameResponse? _checkName(String content, String newName) {
+ Future<CheckNameResponse?> _checkName(String content, String newName) async {
_updateFile(content);
- return CiderRenameComputer(
+ var canRename = await CiderRenameComputer(
fileResolver,
- )
- .canRename(
- convertPath(testPath),
- _correctionContext.line,
- _correctionContext.character,
- )
- ?.checkNewName(newName);
+ ).canRename2(
+ convertPath(testPath),
+ _correctionContext.line,
+ _correctionContext.character,
+ );
+ return canRename?.checkNewName(newName);
}
- CanRenameResponse? _compute(String content) {
+ Future<CanRenameResponse?> _compute(String content) async {
_updateFile(content);
return CiderRenameComputer(
fileResolver,
- ).canRename(
+ ).canRename2(
convertPath(testPath),
_correctionContext.line,
_correctionContext.character,
);
}
- RenameResponse? _rename(String content, String newName) {
+ Future<RenameResponse?> _rename(String content, String newName) async {
_updateFile(content);
- return CiderRenameComputer(
+ var canRename = await CiderRenameComputer(
fileResolver,
- )
- .canRename(
- convertPath(testPath),
- _correctionContext.line,
- _correctionContext.character,
- )
- ?.checkNewName(newName)
- ?.computeRenameRanges();
+ ).canRename2(
+ convertPath(testPath),
+ _correctionContext.line,
+ _correctionContext.character,
+ );
+ return canRename?.checkNewName(newName)?.computeRenameRanges2();
}
void _updateFile(String content) {
diff --git a/pkg/analysis_server/test/src/cider/signature_help_test.dart b/pkg/analysis_server/test/src/cider/signature_help_test.dart
index a5384eb..b4ea6aa 100644
--- a/pkg/analysis_server/test/src/cider/signature_help_test.dart
+++ b/pkg/analysis_server/test/src/cider/signature_help_test.dart
@@ -21,8 +21,8 @@
class CiderSignatureHelpComputerTest extends CiderServiceTest {
late _CorrectionContext _correctionContext;
- void test_noDefaultConstructor() {
- var result = _compute('''
+ void test_noDefaultConstructor() async {
+ var result = await _compute('''
class A {
A._();
}
@@ -33,7 +33,7 @@
expect(result, null);
}
- void test_params_multipleNamed() {
+ void test_params_multipleNamed() async {
final content = '''
/// Does foo.
foo(String s, {bool b = true, bool a}) {
@@ -42,7 +42,7 @@
''';
final expectedLabel = 'foo(String s, {bool b = true, bool a})';
- testSignature(
+ await testSignature(
content,
expectedLabel,
'Does foo.',
@@ -54,7 +54,7 @@
CharacterLocation(3, 7));
}
- void test_params_multipleOptional() {
+ void test_params_multipleOptional() async {
final content = '''
/// Does foo.
foo(String s, [bool b = true, bool a]) {
@@ -63,7 +63,7 @@
''';
final expectedLabel = 'foo(String s, [bool b = true, bool a])';
- testSignature(
+ await testSignature(
content,
expectedLabel,
'Does foo.',
@@ -75,7 +75,7 @@
CharacterLocation(3, 7));
}
- void test_retrigger_validLocation() {
+ void test_retrigger_validLocation() async {
final content = '''
/// Does foo.
foo(String s, {bool b = true, bool a}) {
@@ -84,7 +84,7 @@
''';
final expectedLabel = 'foo(String s, {bool b = true, bool a})';
- testSignature(
+ await testSignature(
content,
expectedLabel,
'Does foo.',
@@ -96,7 +96,7 @@
CharacterLocation(3, 7));
}
- void test_simple() {
+ void test_simple() async {
final content = '''
/// Does foo.
foo(String s, int i) {
@@ -104,7 +104,7 @@
}
''';
final expectedLabel = 'foo(String s, int i)';
- testSignature(
+ await testSignature(
content,
expectedLabel,
'Does foo.',
@@ -115,7 +115,7 @@
CharacterLocation(3, 7));
}
- void test_triggerCharacter_validLocation() {
+ void test_triggerCharacter_validLocation() async {
final content = '''
/// Does foo.
foo(String s, int i) {
@@ -124,7 +124,7 @@
''';
final expectedLabel = 'foo(String s, int i)';
- testSignature(
+ await testSignature(
content,
expectedLabel,
'Does foo.',
@@ -135,7 +135,7 @@
CharacterLocation(3, 7));
}
- void test_typeParams_class() {
+ void test_typeParams_class() async {
final content = '''
/// My Foo.
class Foo<T1, T2 extends String> {}
@@ -143,7 +143,7 @@
class Bar extends Foo<^> {}
''';
- testSignature(
+ await testSignature(
content,
'class Foo<T1, T2 extends String>',
'My Foo.',
@@ -154,7 +154,7 @@
CharacterLocation(4, 23));
}
- void test_typeParams_function() {
+ void test_typeParams_function() async {
final content = '''
/// My Foo.
void foo<T1, T2 extends String>() {
@@ -162,7 +162,7 @@
}
''';
- testSignature(
+ await testSignature(
content,
'void foo<T1, T2 extends String>()',
'My Foo.',
@@ -173,7 +173,7 @@
CharacterLocation(3, 7));
}
- void test_typeParams_method() {
+ void test_typeParams_method() async {
final content = '''
class Foo {
/// My Foo.
@@ -183,7 +183,7 @@
}
''';
- testSignature(
+ await testSignature(
content,
'void foo<T1, T2 extends String>()',
'My Foo.',
@@ -194,13 +194,13 @@
CharacterLocation(4, 9));
}
- void testSignature(
+ Future<void> testSignature(
String content,
String expectedLabel,
String expectedDoc,
List<ParameterInformation> expectedParameters,
- CharacterLocation leftParenLocation) {
- var result = _compute(content);
+ CharacterLocation leftParenLocation) async {
+ var result = await _compute(content);
var signature = result!.signatureHelp.signatures.first;
final expected =
MarkupContent(kind: MarkupKind.Markdown, value: expectedDoc);
@@ -211,12 +211,12 @@
expect(result.callStart == leftParenLocation, isTrue);
}
- SignatureHelpResponse? _compute(String content) {
+ Future<SignatureHelpResponse?> _compute(String content) async {
_updateFile(content);
return CiderSignatureHelpComputer(
fileResolver,
- ).compute(
+ ).compute2(
convertPath(testPath),
_correctionContext.line,
_correctionContext.character,
diff --git a/pkg/analysis_server/test/verify_no_solo_test.dart b/pkg/analysis_server/test/verify_no_solo_test.dart
index 5fe7b8c..32f3e1e 100644
--- a/pkg/analysis_server/test/verify_no_solo_test.dart
+++ b/pkg/analysis_server/test/verify_no_solo_test.dart
@@ -68,7 +68,7 @@
var path = child.path;
var relativePath = pathContext.relative(path, from: testDirPath);
- var result = await session.getParsedUnit2(path);
+ var result = session.getParsedUnit(path);
if (result is! ParsedUnitResult) {
fail('Could not parse $path');
}
diff --git a/pkg/analysis_server/test/verify_sorted_test.dart b/pkg/analysis_server/test/verify_sorted_test.dart
index b63109c..cb8675d 100644
--- a/pkg/analysis_server/test/verify_sorted_test.dart
+++ b/pkg/analysis_server/test/verify_sorted_test.dart
@@ -143,7 +143,7 @@
}
var relativePath = pathContext.relative(path, from: testDirPath);
test(relativePath, () async {
- var result = await session.getParsedUnit2(path);
+ var result = session.getParsedUnit(path);
if (result is! ParsedUnitResult) {
fail('Could not parse $path');
}
diff --git a/pkg/analysis_server_client/test/verify_sorted_test.dart b/pkg/analysis_server_client/test/verify_sorted_test.dart
index a4c2904..7d64d9b 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, () async {
- var result = await 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 b526767..5c1cf47 100644
--- a/pkg/analyzer/CHANGELOG.md
+++ b/pkg/analyzer/CHANGELOG.md
@@ -1,12 +1,5 @@
## 3.4.0-dev
-* Deprecated synchronous `getFile`, `getParsedLibrary`, `getParsedLibraryByElement`,
- `getParsedUnit` from `AnalysisSession`. Use corresponding `getXyz2` asynchronous
- methods instead. This change is necessary for the future work on macros.
* Deprecated `Resource.parent2`, use `parent` instead.
-* Deprecated `AnalysisDriver.getFileSync`, use `getFile` instead.
-* Deprecated `AnalysisDriver.getParsedLibrary`, use `getParsedLibrary2` instead.
-* Deprecated `AnalysisDriver.getParsedLibraryByUri`, use `getParsedLibraryByUri2` instead.
-* Deprecated `AnalysisDriver.parseFileSync`, use `parseFile` instead.
* Deprecated `astFactory`, clients should not create AST nodes manually.
* Changed `CompilationUnit.lineInfo` to be non-nullable.
* Changed `CompilationUnitElement.lineInfo` to be non-nullable.
diff --git a/pkg/analyzer/doc/tutorial/ast.md b/pkg/analyzer/doc/tutorial/ast.md
index 7f64a05..5206b39 100644
--- a/pkg/analyzer/doc/tutorial/ast.md
+++ b/pkg/analyzer/doc/tutorial/ast.md
@@ -55,7 +55,7 @@
```dart
void processFile(AnalysisSession session, String path) async {
- var result = await session.getParsedUnit2(path);
+ var result = session.getParsedUnit(path);
if (result is ParsedUnitResult) {
CompilationUnit unit = result.unit;
}
diff --git a/pkg/analyzer/lib/dart/analysis/session.dart b/pkg/analyzer/lib/dart/analysis/session.dart
index 9f7e4ff..dc14b0a 100644
--- a/pkg/analyzer/lib/dart/analysis/session.dart
+++ b/pkg/analyzer/lib/dart/analysis/session.dart
@@ -39,46 +39,24 @@
/// Return information about the file at the given absolute, normalized
/// [path].
- @Deprecated('Use getFile2() instead')
SomeFileResult getFile(String path);
- /// Return information about the file at the given absolute, normalized
- /// [path].
- Future<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 information about the results of parsing units of the library file
/// with the given absolute, normalized [path].
- @Deprecated('Use getParsedLibrary2() instead')
SomeParsedLibraryResult getParsedLibrary(String path);
/// Return information about the results of parsing units of the library file
- /// with the given absolute, normalized [path].
- Future<SomeParsedLibraryResult> getParsedLibrary2(String path);
-
- /// Return information about the results of parsing units of the library file
/// with the given library [element].
- @Deprecated('Use getParsedLibraryByElement2() instead')
SomeParsedLibraryResult getParsedLibraryByElement(LibraryElement element);
- /// Return information about the results of parsing units of the library file
- /// with the given library [element].
- Future<SomeParsedLibraryResult> getParsedLibraryByElement2(
- LibraryElement element,
- );
-
/// Return information about the results of parsing the file with the given
/// absolute, normalized [path].
- @Deprecated('Use getParsedUnit2() instead')
SomeParsedUnitResult getParsedUnit(String path);
- /// Return information about the results of parsing the file with the given
- /// absolute, normalized [path].
- Future<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].
diff --git a/pkg/analyzer/lib/src/dart/analysis/driver.dart b/pkg/analyzer/lib/src/dart/analysis/driver.dart
index 830e065..45cd4ba 100644
--- a/pkg/analyzer/lib/src/dart/analysis/driver.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/driver.dart
@@ -643,19 +643,6 @@
return getErrors(path);
}
- /// Return the [FileResult] for the Dart file with the given [path].
- ///
- /// The [path] must be absolute and normalized.
- Future<SomeFileResult> getFile(String path) async {
- if (!_isAbsolutePath(path)) {
- return InvalidPathResult();
- }
-
- FileState file = _fileTracker.getFile(path);
- return FileResultImpl(
- currentSession, path, file.uri, file.lineInfo, file.isPart);
- }
-
/// Return a [Future] that completes with the list of added files that
/// define a class member with the given [name].
Future<List<String>> getFilesDefiningClassMemberName(String name) {
@@ -679,7 +666,6 @@
/// Return the [FileResult] for the Dart file with the given [path].
///
/// The [path] must be absolute and normalized.
- @Deprecated('Use getFile() instead')
SomeFileResult getFileSync(String path) {
if (!_isAbsolutePath(path)) {
return InvalidPathResult();
@@ -695,7 +681,7 @@
/// Return the [FileResult] for the Dart file with the given [path].
///
/// The [path] must be absolute and normalized.
- @Deprecated('Use getFile() instead')
+ @Deprecated('Use getFileSync() instead')
SomeFileResult getFileSync2(String path) {
return getFileSync(path);
}
@@ -784,7 +770,6 @@
/// Return a [ParsedLibraryResult] for the library with the given [path].
///
/// The [path] must be absolute and normalized.
- @Deprecated('Use getParsedLibrary2() instead')
SomeParsedLibraryResult getParsedLibrary(String path) {
if (!_isAbsolutePath(path)) {
return InvalidPathResult();
@@ -813,39 +798,7 @@
return ParsedLibraryResultImpl(currentSession, units);
}
- /// Return a [ParsedLibraryResult] for the library with the given [path].
- ///
- /// The [path] must be absolute and normalized.
- Future<SomeParsedLibraryResult> getParsedLibrary2(String path) async {
- if (!_isAbsolutePath(path)) {
- return InvalidPathResult();
- }
-
- if (!_fsState.hasUri(path)) {
- return NotPathOfUriResult();
- }
-
- FileState file = _fsState.getFileForPath(path);
-
- if (file.isPart) {
- return NotLibraryButPartResult();
- }
-
- var units = <ParsedUnitResult>[];
- for (var unitFile in file.libraryFiles) {
- var unitPath = unitFile.path;
- var unitResult = await parseFile(unitPath);
- if (unitResult is! ParsedUnitResult) {
- return UnspecifiedInvalidResult();
- }
- units.add(unitResult);
- }
-
- return ParsedLibraryResultImpl(currentSession, units);
- }
-
/// Return a [ParsedLibraryResult] for the library with the given [uri].
- @Deprecated('Use getParsedLibraryByUri2() instead')
SomeParsedLibraryResult getParsedLibraryByUri(Uri uri) {
var fileOr = _fsState.getFileForUri(uri);
return fileOr.map(
@@ -864,25 +817,6 @@
);
}
- /// Return a [ParsedLibraryResult] for the library with the given [uri].
- Future<SomeParsedLibraryResult> getParsedLibraryByUri2(Uri uri) async {
- var fileOr = _fsState.getFileForUri(uri);
- return fileOr.map(
- (file) {
- if (file == null) {
- return CannotResolveUriResult();
- }
- if (file.isPart) {
- return NotLibraryButPartResult();
- }
- return getParsedLibrary2(file.path);
- },
- (externalLibrary) {
- return UriOfExternalLibraryResult();
- },
- );
- }
-
/// Return a [Future] that completes with a [ResolvedLibraryResult] for the
/// Dart library file with the given [path]. If the file cannot be analyzed,
/// the [Future] completes with an [InvalidResult].
@@ -1071,27 +1005,6 @@
);
}
- /// Return a [ParsedUnitResult] for the file with the given [path].
- ///
- /// The [path] must be absolute and normalized.
- ///
- /// The [path] can be any file - explicitly or implicitly analyzed, or neither.
- ///
- /// The parsing is performed in the method itself, and the result is not
- /// produced through the [results] stream (just because it is not a fully
- /// resolved unit).
- Future<SomeParsedUnitResult> parseFile(String path) async {
- if (!_isAbsolutePath(path)) {
- return InvalidPathResult();
- }
-
- FileState file = _fileTracker.getFile(path);
- RecordingErrorListener listener = RecordingErrorListener();
- CompilationUnit unit = file.parse(listener);
- return ParsedUnitResultImpl(currentSession, file.path, file.uri,
- file.content, file.lineInfo, file.isPart, unit, listener.errors);
- }
-
/// Return a [Future] that completes with a [ParsedUnitResult] for the file
/// with the given [path].
///
@@ -1102,7 +1015,7 @@
/// The parsing is performed in the method itself, and the result is not
/// produced through the [results] stream (just because it is not a fully
/// resolved unit).
- @Deprecated('Use parseFile() instead')
+ @Deprecated('Use parseFileSync() instead')
Future<SomeParsedUnitResult> parseFile2(String path) async {
return parseFileSync2(path);
}
@@ -1116,7 +1029,6 @@
/// The parsing is performed in the method itself, and the result is not
/// produced through the [results] stream (just because it is not a fully
/// resolved unit).
- @Deprecated('Use parseFile() instead')
SomeParsedUnitResult parseFileSync(String path) {
if (!_isAbsolutePath(path)) {
return InvalidPathResult();
diff --git a/pkg/analyzer/lib/src/dart/analysis/session.dart b/pkg/analyzer/lib/src/dart/analysis/session.dart
index 545417e..eccf228 100644
--- a/pkg/analyzer/lib/src/dart/analysis/session.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/session.dart
@@ -62,7 +62,6 @@
return result;
}
- @Deprecated('Use getFile2() instead')
@override
SomeFileResult getFile(String path) {
_checkConsistency();
@@ -72,14 +71,6 @@
}
@override
- Future<SomeFileResult> getFile2(String path) async {
- _checkConsistency();
- var result = await _driver.getFile(path);
- _checkConsistency();
- return result;
- }
-
- @override
Future<SomeLibraryElementResult> getLibraryByUri(String uri) async {
_checkConsistency();
var result = await _driver.getLibraryByUri(uri);
@@ -87,7 +78,6 @@
return result;
}
- @Deprecated('Use getParsedLibrary2() instead')
@override
SomeParsedLibraryResult getParsedLibrary(String path) {
_checkConsistency();
@@ -97,15 +87,6 @@
}
@override
- Future<SomeParsedLibraryResult> getParsedLibrary2(String path) async {
- _checkConsistency();
- var result = await _driver.getParsedLibrary2(path);
- _checkConsistency();
- return result;
- }
-
- @Deprecated('Use getParsedLibraryByElement2() instead')
- @override
SomeParsedLibraryResult getParsedLibraryByElement(LibraryElement element) {
_checkConsistency();
@@ -119,22 +100,6 @@
}
@override
- Future<SomeParsedLibraryResult> getParsedLibraryByElement2(
- LibraryElement element,
- ) async {
- _checkConsistency();
-
- if (element.session != this) {
- return NotElementOfThisSessionResult();
- }
-
- var result = await _driver.getParsedLibraryByUri2(element.source.uri);
- _checkConsistency();
- return result;
- }
-
- @Deprecated('Use getParsedUnit2() instead')
- @override
SomeParsedUnitResult getParsedUnit(String path) {
_checkConsistency();
var result = _driver.parseFileSync(path);
@@ -143,14 +108,6 @@
}
@override
- Future<SomeParsedUnitResult> getParsedUnit2(String path) async {
- _checkConsistency();
- var result = await _driver.parseFile(path);
- _checkConsistency();
- return result;
- }
-
- @override
Future<SomeResolvedLibraryResult> getResolvedLibrary(String path) async {
_checkConsistency();
var result = await _driver.getResolvedLibrary(path);
diff --git a/pkg/analyzer/lib/src/dart/micro/analysis_context.dart b/pkg/analyzer/lib/src/dart/micro/analysis_context.dart
index 575a6e9..715bba0 100644
--- a/pkg/analyzer/lib/src/dart/micro/analysis_context.dart
+++ b/pkg/analyzer/lib/src/dart/micro/analysis_context.dart
@@ -179,18 +179,20 @@
@override
Future<SomeLibraryElementResult> getLibraryByUri(String uriStr) async {
- var element = analysisContext.fileResolver.getLibraryByUri(uriStr: uriStr);
+ var element = await analysisContext.fileResolver.getLibraryByUri2(
+ uriStr: uriStr,
+ );
return LibraryElementResultImpl(element);
}
@override
Future<SomeResolvedLibraryResult> getResolvedLibrary(String path) async {
- return analysisContext.fileResolver.resolveLibrary(path: path);
+ return analysisContext.fileResolver.resolveLibrary2(path: path);
}
@override
Future<SomeResolvedUnitResult> getResolvedUnit(String path) async {
- return analysisContext.fileResolver.resolve(path: path);
+ return analysisContext.fileResolver.resolve2(path: path);
}
@override
diff --git a/pkg/analyzer/lib/src/dart/micro/resolve_file.dart b/pkg/analyzer/lib/src/dart/micro/resolve_file.dart
index b20ce78..ed7b814 100644
--- a/pkg/analyzer/lib/src/dart/micro/resolve_file.dart
+++ b/pkg/analyzer/lib/src/dart/micro/resolve_file.dart
@@ -180,6 +180,7 @@
/// Looks for references to the given Element. All the files currently
/// cached by the resolver are searched, generated files are ignored.
+ @Deprecated('Use findReferences2() instead')
List<CiderSearchMatch> findReferences(Element element,
{OperationPerformanceImpl? performance}) {
return logger.run('findReferences for ${element.name}', () {
@@ -220,6 +221,18 @@
});
}
+ /// Looks for references to the given Element. All the files currently
+ /// cached by the resolver are searched, generated files are ignored.
+ Future<List<CiderSearchMatch>> findReferences2(Element element,
+ {OperationPerformanceImpl? performance}) async {
+ // ignore: deprecated_member_use_from_same_package
+ return findReferences(
+ element,
+ performance: performance,
+ );
+ }
+
+ @Deprecated('Use getErrors2() instead')
ErrorsResult getErrors({
required String path,
OperationPerformanceImpl? performance,
@@ -275,6 +288,17 @@
});
}
+ Future<ErrorsResult> getErrors2({
+ required String path,
+ OperationPerformanceImpl? performance,
+ }) async {
+ // ignore: deprecated_member_use_from_same_package
+ return getErrors(
+ path: path,
+ performance: performance,
+ );
+ }
+
FileContext getFileContext({
required String path,
required OperationPerformanceImpl performance,
@@ -311,6 +335,7 @@
return fsState.getFilesWithTopLevelDeclarations(name);
}
+ @Deprecated('Use getLibraryByUri2() instead')
LibraryElement getLibraryByUri({
required String uriStr,
OperationPerformanceImpl? performance,
@@ -344,6 +369,17 @@
return libraryContext!.elementFactory.libraryOfUri2(uriStr);
}
+ Future<LibraryElement> getLibraryByUri2({
+ required String uriStr,
+ OperationPerformanceImpl? performance,
+ }) async {
+ // ignore: deprecated_member_use_from_same_package
+ return getLibraryByUri(
+ uriStr: uriStr,
+ performance: performance,
+ );
+ }
+
String getLibraryLinkedSignature({
required String path,
required OperationPerformanceImpl performance,
@@ -377,6 +413,7 @@
/// partially resynthesized data, and so prepare for loading linked summaries
/// from bytes, which will be done by [getErrors]. It is OK for it to
/// spend some more time on this.
+ @Deprecated('Use linkLibraries2() instead')
void linkLibraries({
required String path,
}) {
@@ -399,6 +436,32 @@
_resetContextObjects();
}
+ /// Ensure that libraries necessary for resolving [path] are linked.
+ ///
+ /// Libraries are linked in library cycles, from the bottom to top, so that
+ /// when we link a cycle, everything it transitively depends is ready. We
+ /// load newly linked libraries from bytes, and when we link a new library
+ /// cycle we partially resynthesize AST and elements from previously
+ /// loaded libraries.
+ ///
+ /// But when we are done linking libraries, and want to resolve just the
+ /// very top library that transitively depends on the whole dependency
+ /// tree, this library will not reference as many elements in the
+ /// dependencies as we needed for linking. Most probably it references
+ /// elements from directly imported libraries, and a couple of layers below.
+ /// So, keeping all previously resynthesized data is usually a waste.
+ ///
+ /// This method ensures that we discard the libraries context, with all its
+ /// partially resynthesized data, and so prepare for loading linked summaries
+ /// from bytes, which will be done by [getErrors2]. It is OK for it to
+ /// spend some more time on this.
+ Future<void> linkLibraries2({
+ required String path,
+ }) async {
+ // ignore: deprecated_member_use_from_same_package
+ linkLibraries(path: path);
+ }
+
/// Update the cache with list of invalidated ids and clears [removedCacheIds].
void releaseAndClearRemovedIds() {
byteStore.release(removedCacheIds);
@@ -417,6 +480,7 @@
}
/// The [completionLine] and [completionColumn] are zero based.
+ @Deprecated('Use resolve2() instead')
ResolvedUnitResult resolve({
int? completionLine,
int? completionColumn,
@@ -458,6 +522,23 @@
}
/// The [completionLine] and [completionColumn] are zero based.
+ Future<ResolvedUnitResult> resolve2({
+ int? completionLine,
+ int? completionColumn,
+ required String path,
+ OperationPerformanceImpl? performance,
+ }) async {
+ // ignore: deprecated_member_use_from_same_package
+ return resolve(
+ completionLine: completionLine,
+ completionColumn: completionColumn,
+ path: path,
+ performance: performance,
+ );
+ }
+
+ /// The [completionLine] and [completionColumn] are zero based.
+ @Deprecated('Use resolveLibrary2() instead')
ResolvedLibraryResult resolveLibrary({
int? completionLine,
int? completionColumn,
@@ -570,6 +651,24 @@
});
}
+ /// The [completionLine] and [completionColumn] are zero based.
+ Future<ResolvedLibraryResult> resolveLibrary2({
+ int? completionLine,
+ int? completionColumn,
+ String? completionPath,
+ required String path,
+ OperationPerformanceImpl? performance,
+ }) async {
+ // ignore: deprecated_member_use_from_same_package
+ return resolveLibrary(
+ completionLine: completionLine,
+ completionColumn: completionColumn,
+ completionPath: completionPath,
+ path: path,
+ performance: performance,
+ );
+ }
+
/// Make sure that [fsState], [contextObjects], and [libraryContext] are
/// created and configured with the given [fileAnalysisOptions].
///
diff --git a/pkg/analyzer/test/dart/analysis/analysis_context_test.dart b/pkg/analyzer/test/dart/analysis/analysis_context_test.dart
index 685fa7b..4ebf81d 100644
--- a/pkg/analyzer/test/dart/analysis/analysis_context_test.dart
+++ b/pkg/analyzer/test/dart/analysis/analysis_context_test.dart
@@ -28,9 +28,9 @@
// Ask for files, so that they are known.
var analysisSession = analysisContext.currentSession;
- await analysisSession.getFile2(a.path);
- await analysisSession.getFile2(b.path);
- await analysisSession.getFile2(c.path);
+ analysisSession.getFile(a.path);
+ analysisSession.getFile(b.path);
+ analysisSession.getFile(c.path);
analysisContext.changeFile(a.path);
@@ -59,10 +59,10 @@
// Ask for files, so that they are known.
var analysisSession = analysisContext.currentSession;
- await analysisSession.getFile2(a.path);
- await analysisSession.getFile2(b.path);
- await analysisSession.getFile2(c.path);
- await analysisSession.getFile2(d.path);
+ analysisSession.getFile(a.path);
+ analysisSession.getFile(b.path);
+ analysisSession.getFile(c.path);
+ analysisSession.getFile(d.path);
analysisContext.changeFile(b.path);
diff --git a/pkg/analyzer/test/src/dart/analysis/driver_test.dart b/pkg/analyzer/test/src/dart/analysis/driver_test.dart
index 1bfe413..0f775f5 100644
--- a/pkg/analyzer/test/src/dart/analysis/driver_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/driver_test.dart
@@ -1386,67 +1386,6 @@
expect(result, isA<InvalidPathResult>());
}
- test_getFile_changedFile() async {
- var a = convertPath('/test/lib/a.dart');
- var b = convertPath('/test/lib/b.dart');
-
- newFile2(a, '');
- newFile2(b, r'''
-import 'a.dart';
-
-void f(A a) {}
-''');
-
- // Ensure that [a.dart] library cycle is loaded.
- // So, `a.dart` is in the library context.
- await driver.getResultValid(a);
-
- // Update the file, changing its API signature.
- // Note that we don't call `changeFile`.
- newFile2(a, 'class A {}\n');
-
- // Get the file.
- // We have not called `changeFile(a)`, so we should not read the file.
- // Moreover, doing this will create a new library cycle [a.dart].
- // Library cycles are compared by their identity, so we would try to
- // reload linked summary for [a.dart], and crash.
- expect((await driver.getFileValid(a)).lineInfo.lineCount, 1);
-
- // We have not read `a.dart`, so `A` is still not declared.
- expect((await driver.getResultValid(b)).errors, isNotEmpty);
-
- // Notify the driver that the file was changed.
- driver.changeFile(a);
- await driver.applyPendingFileChanges();
-
- // So, `class A {}` is declared now.
- expect((await driver.getFileValid(a)).lineInfo.lineCount, 2);
- expect((await driver.getResultValid(b)).errors, isEmpty);
- }
-
- test_getFile_library() async {
- var path = convertPath('/test/lib/a.dart');
- newFile2(path, '');
- var file = await driver.getFileValid(path);
- expect(file.path, path);
- expect(file.uri.toString(), 'package:test/a.dart');
- expect(file.isPart, isFalse);
- }
-
- test_getFile_notAbsolutePath() async {
- var result = await driver.getFile('not_absolute.dart');
- expect(result, isA<InvalidPathResult>());
- }
-
- test_getFile_part() async {
- var path = convertPath('/test/lib/a.dart');
- newFile2(path, 'part of lib;');
- var file = await driver.getFileValid(path);
- expect(file.path, path);
- expect(file.uri.toString(), 'package:test/a.dart');
- expect(file.isPart, isTrue);
- }
-
test_getFilesDefiningClassMemberName_class() async {
var a = convertPath('/test/bin/a.dart');
var b = convertPath('/test/bin/b.dart');
@@ -1550,7 +1489,6 @@
expect(files, isNot(contains(c)));
}
- @deprecated
test_getFileSync_changedFile() async {
var a = convertPath('/test/lib/a.dart');
var b = convertPath('/test/lib/b.dart');
@@ -1588,7 +1526,6 @@
expect((await driver.getResultValid(b)).errors, isEmpty);
}
- @deprecated
test_getFileSync_library() async {
var path = convertPath('/test/lib/a.dart');
newFile2(path, '');
@@ -1598,13 +1535,11 @@
expect(file.isPart, isFalse);
}
- @deprecated
test_getFileSync_notAbsolutePath() async {
var result = driver.getFileSync('not_absolute.dart');
expect(result, isA<InvalidPathResult>());
}
- @deprecated
test_getFileSync_part() async {
var path = convertPath('/test/lib/a.dart');
newFile2(path, 'part of lib;');
@@ -1673,7 +1608,6 @@
expect(result, isA<CannotResolveUriResult>());
}
- @deprecated
test_getParsedLibrary() async {
var content = 'class A {}';
addTestFile(content);
@@ -1686,43 +1620,17 @@
expect(result.units[0].errors, isEmpty);
}
- test_getParsedLibrary2() async {
- var content = 'class A {}';
- addTestFile(content);
- var result = await 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);
- }
-
- test_getParsedLibrary2_invalidPath_notAbsolute() async {
- var result = await driver.getParsedLibrary2('not_absolute.dart');
- expect(result, isA<InvalidPathResult>());
- }
-
- test_getParsedLibrary2_notLibraryButPart() async {
- addTestFile('part of my;');
- var result = await driver.getParsedLibrary2(testFile);
- expect(result, isA<NotLibraryButPartResult>());
- }
-
- @deprecated
test_getParsedLibrary_invalidPath_notAbsolute() async {
var result = driver.getParsedLibrary('not_absolute.dart');
expect(result, isA<InvalidPathResult>());
}
- @deprecated
test_getParsedLibrary_notLibraryButPart() async {
addTestFile('part of my;');
var result = driver.getParsedLibrary(testFile);
expect(result, isA<NotLibraryButPartResult>());
}
- @deprecated
test_getParsedLibraryByUri() async {
var content = 'class A {}';
addTestFile(content);
@@ -1736,34 +1644,6 @@
expect(result.units[0].content, content);
}
- test_getParsedLibraryByUri2() async {
- var content = 'class A {}';
- addTestFile(content);
-
- var uri = Uri.parse('package:test/test.dart');
- var result = await driver.getParsedLibraryByUri2(uri);
- result as ParsedLibraryResult;
- expect(result.units, hasLength(1));
- expect(result.units[0].uri, uri);
- expect(result.units[0].path, testFile);
- expect(result.units[0].content, content);
- }
-
- test_getParsedLibraryByUri2_notLibrary() async {
- addTestFile('part of my;');
-
- var uri = Uri.parse('package:test/test.dart');
- var result = await driver.getParsedLibraryByUri2(uri);
- expect(result, isA<NotLibraryButPartResult>());
- }
-
- test_getParsedLibraryByUri2_unresolvedUri() async {
- var uri = Uri.parse('package:unknown/a.dart');
- var result = await driver.getParsedLibraryByUri2(uri);
- expect(result, isA<CannotResolveUriResult>());
- }
-
- @deprecated
test_getParsedLibraryByUri_notLibrary() async {
addTestFile('part of my;');
@@ -1772,7 +1652,6 @@
expect(result, isA<NotLibraryButPartResult>());
}
- @deprecated
test_getParsedLibraryByUri_unresolvedUri() async {
var uri = Uri.parse('package:unknown/a.dart');
var result = driver.getParsedLibraryByUri(uri);
@@ -2558,139 +2437,6 @@
expect(error.errorCode, CompileTimeErrorCode.MISSING_DART_LIBRARY);
}
- test_parseFile_changedFile() async {
- var a = convertPath('/test/lib/a.dart');
- var b = convertPath('/test/lib/b.dart');
-
- newFile2(a, '');
- newFile2(b, r'''
-import 'a.dart';
-
-void f(A a) {}
-''');
-
- // Ensure that [a.dart] library cycle is loaded.
- // So, `a.dart` is in the library context.
- await driver.getResultValid(a);
-
- // Update the file, changing its API signature.
- // Note that we don't call `changeFile`.
- newFile2(a, 'class A {}');
-
- // Parse the file.
- // We have not called `changeFile(a)`, so we should not read the file.
- // Moreover, doing this will create a new library cycle [a.dart].
- // Library cycles are compared by their identity, so we would try to
- // reload linked summary for [a.dart], and crash.
- {
- var parseResult = await driver.parseFile(a) as ParsedUnitResult;
- expect(parseResult.unit.declarations, isEmpty);
- }
-
- // We have not read `a.dart`, so `A` is still not declared.
- {
- var bResult = await driver.getResultValid(b);
- expect(bResult.errors, isNotEmpty);
- }
-
- // Notify the driver that the file was changed.
- driver.changeFile(a);
- await driver.applyPendingFileChanges();
-
- // So, `class A {}` is declared now.
- {
- var parseResult = await driver.parseFile(a) as ParsedUnitResult;
- expect(parseResult.unit.declarations, hasLength(1));
- }
- {
- var bResult = await driver.getResultValid(b);
- expect(bResult.errors, isEmpty);
- }
- }
-
- test_parseFile_doesNotReadImportedFiles() async {
- var a = convertPath('/test/lib/a.dart');
- var b = convertPath('/test/lib/b.dart');
-
- newFile2(a, '');
- newFile2(b, r'''
-import 'a.dart';
-''');
-
- expect(driver.fsState.knownFilePaths, isEmpty);
-
- // Don't read `a.dart` when parse.
- await driver.parseFile(b);
- expect(driver.fsState.knownFilePaths, unorderedEquals([b]));
-
- // Still don't read `a.dart` when parse the second time.
- await driver.parseFile(b);
- expect(driver.fsState.knownFilePaths, unorderedEquals([b]));
- }
-
- test_parseFile_doesNotReadPartedFiles() async {
- var a = convertPath('/test/lib/a.dart');
- var b = convertPath('/test/lib/b.dart');
-
- newFile2(a, r'''
-part of my;
-''');
- newFile2(b, r'''
-library my;
-part 'a.dart';
-''');
-
- expect(driver.fsState.knownFilePaths, isEmpty);
-
- // Don't read `a.dart` when parse.
- await driver.parseFile(b);
- expect(driver.fsState.knownFilePaths, unorderedEquals([b]));
-
- // Still don't read `a.dart` when parse the second time.
- await driver.parseFile(b);
- expect(driver.fsState.knownFilePaths, unorderedEquals([b]));
- }
-
- test_parseFile_languageVersion() async {
- var path = convertPath('/test/lib/test.dart');
-
- newFile2(path, r'''
-// @dart = 2.7
-class A {}
-''');
-
- var parseResult = await driver.parseFile(path) as ParsedUnitResult;
- var languageVersion = parseResult.unit.languageVersionToken!;
- expect(languageVersion.major, 2);
- expect(languageVersion.minor, 7);
- }
-
- test_parseFile_languageVersion_null() async {
- var path = convertPath('/test/lib/test.dart');
-
- newFile2(path, r'''
-class A {}
-''');
-
- var parseResult = await driver.parseFile(path) as ParsedUnitResult;
- expect(parseResult.unit.languageVersionToken, isNull);
- }
-
- test_parseFile_notAbsolutePath() async {
- var result = await driver.parseFile('not_absolute.dart');
- expect(result, isA<InvalidPathResult>());
- }
-
- test_parseFile_notDart() async {
- var p = convertPath('/test/bin/a.txt');
- newFile2(p, 'class A {}');
-
- var parseResult = await driver.parseFile(p) as ParsedUnitResult;
- expect(parseResult, isNotNull);
- expect(driver.knownFiles, contains(p));
- }
-
- @deprecated
test_parseFileSync_changedFile() async {
var a = convertPath('/test/lib/a.dart');
var b = convertPath('/test/lib/b.dart');
@@ -2740,7 +2486,6 @@
}
}
- @deprecated
test_parseFileSync_doesNotReadImportedFiles() async {
var a = convertPath('/test/lib/a.dart');
var b = convertPath('/test/lib/b.dart');
@@ -2761,7 +2506,6 @@
expect(driver.fsState.knownFilePaths, unorderedEquals([b]));
}
- @deprecated
test_parseFileSync_doesNotReadPartedFiles() async {
var a = convertPath('/test/lib/a.dart');
var b = convertPath('/test/lib/b.dart');
@@ -2785,7 +2529,6 @@
expect(driver.fsState.knownFilePaths, unorderedEquals([b]));
}
- @deprecated
test_parseFileSync_languageVersion() async {
var path = convertPath('/test/lib/test.dart');
@@ -2800,7 +2543,6 @@
expect(languageVersion.minor, 7);
}
- @deprecated
test_parseFileSync_languageVersion_null() async {
var path = convertPath('/test/lib/test.dart');
@@ -2812,13 +2554,11 @@
expect(parseResult.unit.languageVersionToken, isNull);
}
- @deprecated
test_parseFileSync_notAbsolutePath() async {
var result = driver.parseFileSync('not_absolute.dart');
expect(result, isA<InvalidPathResult>());
}
- @deprecated
test_parseFileSync_notDart() async {
var p = convertPath('/test/bin/a.txt');
newFile2(p, 'class A {}');
@@ -3717,15 +3457,10 @@
}
}
- @deprecated
FileResult getFileSyncValid(String path) {
return getFileSync(path) as FileResult;
}
- Future<FileResult> getFileValid(String path) async {
- return await getFile(path) as FileResult;
- }
-
Future<LibraryElementResult> getLibraryByUriValid(String uriStr) async {
return await getLibraryByUri(uriStr) as LibraryElementResult;
}
diff --git a/pkg/analyzer/test/src/dart/analysis/resolve_for_completion_test.dart b/pkg/analyzer/test/src/dart/analysis/resolve_for_completion_test.dart
index 56ea4ff..e9b7143 100644
--- a/pkg/analyzer/test/src/dart/analysis/resolve_for_completion_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/resolve_for_completion_test.dart
@@ -461,7 +461,7 @@
newFile2(testFilePath, 'class A {}');
// Read the file.
- await testDriver.getFile(testFilePathPlatform);
+ testDriver.getFileSync(testFilePathPlatform);
// Should call `changeFile()`, and the driver must re-read the file.
var result = await _resolveTestCode(r'''
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 d374b9c..5d1a963 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 @@
Future<ParsedLibraryResult> _getParsedLibrary(String path) async {
var session = contextFor(path).currentSession;
- return await session.getParsedLibrary2(path) as ParsedLibraryResult;
+ return session.getParsedLibrary(path) as ParsedLibraryResult;
}
}
diff --git a/pkg/analyzer/test/src/dart/analysis/session_test.dart b/pkg/analyzer/test/src/dart/analysis/session_test.dart
index b95640d..fac7f1f 100644
--- a/pkg/analyzer/test/src/dart/analysis/session_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/session_test.dart
@@ -44,17 +44,6 @@
expect(result.uri.toString(), 'package:dart.my/a.dart');
}
- void test_getParsedLibrary2_notFileOfUri() async {
- var relPath = 'dart/my/lib/a.dart';
- newFile2('$workspaceRootPath/bazel-bin/$relPath', '');
-
- var path = convertPath('$workspaceRootPath/$relPath');
- var session = contextFor(path).currentSession;
- var result = await session.getParsedLibrary2(path);
- expect(result, isA<NotPathOfUriResult>());
- }
-
- @deprecated
void test_getParsedLibrary_notFileOfUri() async {
var relPath = 'dart/my/lib/a.dart';
newFile2('$workspaceRootPath/bazel-bin/$relPath', '');
@@ -161,43 +150,6 @@
expect(errorsResult, isA<InvalidPathResult>());
}
- test_getFile2_inconsistent() async {
- var test = newFile2(testFilePath, '');
- var session = contextFor(test.path).currentSession;
- driverFor(test.path).changeFile(test.path);
- expect(
- () async => session.getFile2(test.path),
- throwsA(isA<InconsistentAnalysisException>()),
- );
- }
-
- test_getFile2_invalidPath_notAbsolute() async {
- var session = contextFor(testFilePath).currentSession;
- var errorsResult = await session.getFile2('not_absolute.dart');
- expect(errorsResult, isA<InvalidPathResult>());
- }
-
- test_getFile2_library() async {
- var a = newFile2('$testPackageLibPath/a.dart', '');
-
- var session = contextFor(testFilePath).currentSession;
- var file = await session.getFile2Valid(a.path);
- expect(file.path, a.path);
- expect(file.uri.toString(), 'package:test/a.dart');
- expect(file.isPart, isFalse);
- }
-
- test_getFile2_part() async {
- var a = newFile2('$testPackageLibPath/a.dart', 'part of lib;');
-
- var session = contextFor(testFilePath).currentSession;
- var file = await session.getFile2Valid(a.path);
- expect(file.path, a.path);
- expect(file.uri.toString(), 'package:test/a.dart');
- expect(file.isPart, isTrue);
- }
-
- @deprecated
test_getFile_inconsistent() async {
var test = newFile2(testFilePath, '');
var session = contextFor(test.path).currentSession;
@@ -208,14 +160,12 @@
);
}
- @deprecated
test_getFile_invalidPath_notAbsolute() async {
var session = contextFor(testFilePath).currentSession;
var errorsResult = session.getFile('not_absolute.dart');
expect(errorsResult, isA<InvalidPathResult>());
}
- @deprecated
test_getFile_library() async {
var a = newFile2('$testPackageLibPath/a.dart', '');
@@ -226,7 +176,6 @@
expect(file.isPart, isFalse);
}
- @deprecated
test_getFile_part() async {
var a = newFile2('$testPackageLibPath/a.dart', 'part of lib;');
@@ -267,7 +216,6 @@
expect(result, isA<CannotResolveUriResult>());
}
- @deprecated
test_getParsedLibrary() async {
var test = newFile2('$testPackageLibPath/a.dart', r'''
class A {}
@@ -288,189 +236,6 @@
}
}
- test_getParsedLibrary2() async {
- var test = newFile2('$testPackageLibPath/a.dart', r'''
-class A {}
-class B {}
-''');
-
- var session = contextFor(testFilePath).currentSession;
- var parsedLibrary = await session.getParsedLibrary2Valid(test.path);
- expect(parsedLibrary.session, session);
-
- expect(parsedLibrary.units, hasLength(1));
- {
- var parsedUnit = parsedLibrary.units[0];
- expect(parsedUnit.session, session);
- expect(parsedUnit.path, test.path);
- expect(parsedUnit.uri, Uri.parse('package:test/a.dart'));
- expect(parsedUnit.unit.declarations, hasLength(2));
- }
- }
-
- test_getParsedLibrary2_getElementDeclaration_class() async {
- var test = newFile2(testFilePath, r'''
-class A {}
-class B {}
-''');
-
- var session = contextFor(testFilePath).currentSession;
- var libraryResult = await session.getLibraryByUriValid(
- 'package:test/test.dart',
- );
- var parsedLibrary = await session.getParsedLibrary2Valid(test.path);
-
- var element = libraryResult.element.getType('A')!;
- var declaration = parsedLibrary.getElementDeclaration(element)!;
- var node = declaration.node as ClassDeclaration;
- expect(node.name.name, 'A');
- expect(node.offset, 0);
- expect(node.length, 10);
- }
-
- test_getParsedLibrary2_getElementDeclaration_notThisLibrary() async {
- var test = newFile2(testFilePath, '');
-
- var session = contextFor(testFilePath).currentSession;
- var resolvedUnit =
- await session.getResolvedUnit(test.path) as ResolvedUnitResult;
- var typeProvider = resolvedUnit.typeProvider;
- var intClass = typeProvider.intType.element;
-
- var parsedLibrary = await session.getParsedLibrary2Valid(test.path);
-
- expect(() {
- parsedLibrary.getElementDeclaration(intClass);
- }, throwsArgumentError);
- }
-
- test_getParsedLibrary2_getElementDeclaration_synthetic() async {
- var test = newFile2(testFilePath, r'''
-int foo = 0;
-''');
-
- var session = contextFor(testFilePath).currentSession;
- var parsedLibrary = await session.getParsedLibrary2Valid(test.path);
-
- var unitResult = await session.getUnitElementValid(test.path);
- var fooElement = unitResult.element.topLevelVariables[0];
- expect(fooElement.name, 'foo');
-
- // We can get the variable element declaration.
- var fooDeclaration = parsedLibrary.getElementDeclaration(fooElement)!;
- var fooNode = fooDeclaration.node as VariableDeclaration;
- expect(fooNode.name.name, 'foo');
- expect(fooNode.offset, 4);
- expect(fooNode.length, 7);
- expect(fooNode.name.staticElement, isNull);
-
- // Synthetic elements don't have nodes.
- expect(parsedLibrary.getElementDeclaration(fooElement.getter!), isNull);
- expect(parsedLibrary.getElementDeclaration(fooElement.setter!), isNull);
- }
-
- test_getParsedLibrary2_inconsistent() async {
- var test = newFile2(testFilePath, '');
- var session = contextFor(test.path).currentSession;
- driverFor(test.path).changeFile(test.path);
- expect(
- () => session.getParsedLibrary2(test.path),
- throwsA(isA<InconsistentAnalysisException>()),
- );
- }
-
- test_getParsedLibrary2_invalidPartUri() async {
- var test = newFile2(testFilePath, r'''
-part 'a.dart';
-part ':[invalid uri].dart';
-part 'c.dart';
-''');
-
- var session = contextFor(testFilePath).currentSession;
- var parsedLibrary = await session.getParsedLibrary2Valid(test.path);
-
- expect(parsedLibrary.units, hasLength(3));
- expect(
- parsedLibrary.units[0].path,
- convertPath('/home/test/lib/test.dart'),
- );
- expect(
- parsedLibrary.units[1].path,
- convertPath('/home/test/lib/a.dart'),
- );
- expect(
- parsedLibrary.units[2].path,
- convertPath('/home/test/lib/c.dart'),
- );
- }
-
- test_getParsedLibrary2_invalidPath_notAbsolute() async {
- var session = contextFor(testFilePath).currentSession;
- var result = await session.getParsedLibrary2('not_absolute.dart');
- expect(result, isA<InvalidPathResult>());
- }
-
- test_getParsedLibrary2_notLibrary() async {
- var test = newFile2(testFilePath, 'part of "a.dart";');
- var session = contextFor(testFilePath).currentSession;
- var result = await session.getParsedLibrary2(test.path);
- expect(result, isA<NotLibraryButPartResult>());
- }
-
- test_getParsedLibrary2_parts() async {
- var aContent = r'''
-part 'b.dart';
-part 'c.dart';
-
-class A {}
-''';
-
- var bContent = r'''
-part of 'a.dart';
-
-class B1 {}
-class B2 {}
-''';
-
- var cContent = r'''
-part of 'a.dart';
-
-class C1 {}
-class C2 {}
-class C3 {}
-''';
-
- var a = newFile2('$testPackageLibPath/a.dart', aContent);
- var b = newFile2('$testPackageLibPath/b.dart', bContent);
- var c = newFile2('$testPackageLibPath/c.dart', cContent);
-
- var session = contextFor(testFilePath).currentSession;
- var parsedLibrary = await session.getParsedLibrary2Valid(a.path);
- expect(parsedLibrary.units, hasLength(3));
-
- {
- var aUnit = parsedLibrary.units[0];
- expect(aUnit.path, a.path);
- expect(aUnit.uri, Uri.parse('package:test/a.dart'));
- expect(aUnit.unit.declarations, hasLength(1));
- }
-
- {
- var bUnit = parsedLibrary.units[1];
- expect(bUnit.path, b.path);
- expect(bUnit.uri, Uri.parse('package:test/b.dart'));
- expect(bUnit.unit.declarations, hasLength(2));
- }
-
- {
- var cUnit = parsedLibrary.units[2];
- expect(cUnit.path, c.path);
- expect(cUnit.uri, Uri.parse('package:test/c.dart'));
- expect(cUnit.unit.declarations, hasLength(3));
- }
- }
-
- @deprecated
test_getParsedLibrary_getElementDeclaration_class() async {
var test = newFile2(testFilePath, r'''
class A {}
@@ -491,7 +256,6 @@
expect(node.length, 10);
}
- @deprecated
test_getParsedLibrary_getElementDeclaration_notThisLibrary() async {
var test = newFile2(testFilePath, '');
@@ -508,7 +272,6 @@
}, throwsArgumentError);
}
- @deprecated
test_getParsedLibrary_getElementDeclaration_synthetic() async {
var test = newFile2(testFilePath, r'''
int foo = 0;
@@ -534,7 +297,6 @@
expect(parsedLibrary.getElementDeclaration(fooElement.setter!), isNull);
}
- @deprecated
test_getParsedLibrary_inconsistent() async {
var test = newFile2(testFilePath, '');
var session = contextFor(test.path).currentSession;
@@ -545,7 +307,6 @@
);
}
- @deprecated
test_getParsedLibrary_invalidPartUri() async {
var test = newFile2(testFilePath, r'''
part 'a.dart';
@@ -571,21 +332,18 @@
);
}
- @deprecated
test_getParsedLibrary_invalidPath_notAbsolute() async {
var session = contextFor(testFilePath).currentSession;
var result = session.getParsedLibrary('not_absolute.dart');
expect(result, isA<InvalidPathResult>());
}
- @deprecated
test_getParsedLibrary_notLibrary() async {
var test = newFile2(testFilePath, 'part of "a.dart";');
var session = contextFor(testFilePath).currentSession;
expect(session.getParsedLibrary(test.path), isA<NotLibraryButPartResult>());
}
- @deprecated
test_getParsedLibrary_parts() async {
var aContent = r'''
part 'b.dart';
@@ -639,7 +397,6 @@
}
}
- @deprecated
test_getParsedLibraryByElement() async {
var test = newFile2(testFilePath, '');
@@ -661,43 +418,6 @@
}
}
- test_getParsedLibraryByElement2() async {
- var test = newFile2(testFilePath, '');
-
- var session = contextFor(testFilePath).currentSession;
- var libraryResult = await session.getLibraryByUriValid(
- 'package:test/test.dart',
- );
- var element = libraryResult.element;
-
- var parsedLibrary = await session.getParsedLibraryByElement2Valid(element);
- expect(parsedLibrary.session, session);
- expect(parsedLibrary.units, hasLength(1));
-
- {
- var unit = parsedLibrary.units[0];
- expect(unit.path, test.path);
- expect(unit.uri, Uri.parse('package:test/test.dart'));
- expect(unit.unit, isNotNull);
- }
- }
-
- test_getParsedLibraryByElement2_differentSession() async {
- newFile2(testFilePath, '');
-
- var session = contextFor(testFilePath).currentSession;
- var libraryResult = await session.getLibraryByUriValid(
- 'package:test/test.dart',
- );
- var element = libraryResult.element;
-
- var aaaSession = contextFor('$workspaceRootPath/aaa').currentSession;
-
- var result = await aaaSession.getParsedLibraryByElement2(element);
- expect(result, isA<NotElementOfThisSessionResult>());
- }
-
- @deprecated
test_getParsedLibraryByElement_differentSession() async {
newFile2(testFilePath, '');
@@ -713,7 +433,6 @@
expect(result, isA<NotElementOfThisSessionResult>());
}
- @deprecated
test_getParsedUnit() async {
var test = newFile2(testFilePath, r'''
class A {}
@@ -728,37 +447,6 @@
expect(unitResult.unit.declarations, hasLength(2));
}
- test_getParsedUnit2() async {
- var test = newFile2(testFilePath, r'''
-class A {}
-class B {}
-''');
-
- var session = contextFor(testFilePath).currentSession;
- var unitResult = await session.getParsedUnit2Valid(test.path);
- expect(unitResult.session, session);
- expect(unitResult.path, test.path);
- expect(unitResult.uri, Uri.parse('package:test/test.dart'));
- expect(unitResult.unit.declarations, hasLength(2));
- }
-
- test_getParsedUnit2_inconsistent() async {
- var test = newFile2(testFilePath, '');
- var session = contextFor(test.path).currentSession;
- driverFor(test.path).changeFile(test.path);
- expect(
- () => session.getParsedUnit2(test.path),
- throwsA(isA<InconsistentAnalysisException>()),
- );
- }
-
- test_getParsedUnit2_invalidPath_notAbsolute() async {
- var session = contextFor(testFilePath).currentSession;
- var result = await session.getParsedUnit2('not_absolute.dart');
- expect(result, isA<InvalidPathResult>());
- }
-
- @deprecated
test_getParsedUnit_inconsistent() async {
var test = newFile2(testFilePath, '');
var session = contextFor(test.path).currentSession;
@@ -769,7 +457,6 @@
);
}
- @deprecated
test_getParsedUnit_invalidPath_notAbsolute() async {
var session = contextFor(testFilePath).currentSession;
var result = session.getParsedUnit('not_absolute.dart');
@@ -1018,11 +705,6 @@
return await getErrors(path) as ErrorsResult;
}
- Future<FileResult> getFile2Valid(String path) async {
- return await getFile2(path) as FileResult;
- }
-
- @deprecated
FileResult getFileValid(String path) {
return getFile(path) as FileResult;
}
@@ -1031,31 +713,14 @@
return await getLibraryByUri(path) as LibraryElementResult;
}
- Future<ParsedLibraryResult> getParsedLibrary2Valid(String path) async {
- return await getParsedLibrary2(path) as ParsedLibraryResult;
- }
-
- Future<ParsedLibraryResult> getParsedLibraryByElement2Valid(
- LibraryElement element,
- ) async {
- return await getParsedLibraryByElement2(element) as ParsedLibraryResult;
- }
-
- @deprecated
ParsedLibraryResult getParsedLibraryByElementValid(LibraryElement element) {
return getParsedLibraryByElement(element) as ParsedLibraryResult;
}
- @deprecated
ParsedLibraryResult getParsedLibraryValid(String path) {
return getParsedLibrary(path) as ParsedLibraryResult;
}
- Future<ParsedUnitResult> getParsedUnit2Valid(String path) async {
- return await getParsedUnit2(path) as ParsedUnitResult;
- }
-
- @deprecated
ParsedUnitResult getParsedUnitValid(String path) {
return getParsedUnit(path) as ParsedUnitResult;
}
diff --git a/pkg/analyzer/test/src/dart/micro/file_resolution.dart b/pkg/analyzer/test/src/dart/micro/file_resolution.dart
index 88d2563..57c9d56 100644
--- a/pkg/analyzer/test/src/dart/micro/file_resolution.dart
+++ b/pkg/analyzer/test/src/dart/micro/file_resolution.dart
@@ -66,9 +66,9 @@
fileResolver.testView = FileResolverTestView();
}
- ErrorsResult getTestErrors() {
+ Future<ErrorsResult> getTestErrors() async {
var path = convertPath(_testFile);
- return fileResolver.getErrors(path: path);
+ return fileResolver.getErrors2(path: path);
}
@override
@@ -76,7 +76,7 @@
String path, {
OperationPerformanceImpl? performance,
}) async {
- result = fileResolver.resolve(
+ result = await fileResolver.resolve2(
path: path,
performance: performance,
);
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 d7b654c..7319323 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
@@ -393,7 +393,8 @@
''');
await resolveFile(bPath);
- var result = fileResolver.findReferences(_findElement(6, aPath));
+ var element = await _findElement(6, aPath);
+ var result = await fileResolver.findReferences2(element);
var expected = <CiderSearchMatch>[
CiderSearchMatch(bPath, [CharacterLocation(4, 11)]),
CiderSearchMatch(aPath, [CharacterLocation(1, 7)])
@@ -414,7 +415,8 @@
''');
await resolveFile(aPath);
- var result = fileResolver.findReferences(_findElement(16, aPath));
+ var element = await _findElement(16, aPath);
+ var result = await fileResolver.findReferences2(element);
var expected = <CiderSearchMatch>[
CiderSearchMatch(
aPath, [CharacterLocation(2, 7), CharacterLocation(5, 5)])
@@ -433,7 +435,8 @@
''');
await resolveFile(aPath);
- var result = fileResolver.findReferences(_findElement(11, aPath));
+ var element = await _findElement(11, aPath);
+ var result = await fileResolver.findReferences2(element);
var expected = <CiderSearchMatch>[
CiderSearchMatch(
aPath, [CharacterLocation(2, 3), CharacterLocation(5, 1)])
@@ -459,7 +462,8 @@
''');
await resolveFile(bPath);
- var result = fileResolver.findReferences(_findElement(20, aPath));
+ var element = await _findElement(20, aPath);
+ var result = await fileResolver.findReferences2(element);
var expected = <CiderSearchMatch>[
CiderSearchMatch(bPath, [CharacterLocation(5, 15)]),
CiderSearchMatch(aPath, [CharacterLocation(2, 11)])
@@ -478,7 +482,8 @@
}
''');
await resolveFile(aPath);
- var result = fileResolver.findReferences(_findElement(39, aPath));
+ var element = await _findElement(39, aPath);
+ var result = await fileResolver.findReferences2(element);
var expected = <CiderSearchMatch>[
CiderSearchMatch(
aPath, [CharacterLocation(3, 9), CharacterLocation(4, 11)])
@@ -511,7 +516,8 @@
''');
await resolveFile(bPath);
- var result = fileResolver.findReferences(_findElement(17, aPath));
+ var element = await _findElement(17, aPath);
+ var result = await fileResolver.findReferences2(element);
var expected = <CiderSearchMatch>[
CiderSearchMatch(bPath, [CharacterLocation(5, 5)]),
CiderSearchMatch(
@@ -538,7 +544,8 @@
''');
await resolveFile(bPath);
- var result = fileResolver.findReferences(_findElement(21, aPath));
+ var element = await _findElement(21, aPath);
+ var result = await fileResolver.findReferences2(element);
var expected = <CiderSearchMatch>[
CiderSearchMatch(bPath, [CharacterLocation(5, 5)]),
CiderSearchMatch(aPath, [CharacterLocation(2, 12)])
@@ -565,7 +572,8 @@
''');
await resolveFile(bPath);
- var result = fileResolver.findReferences(_findElement(19, aPath));
+ var element = await _findElement(19, aPath);
+ var result = await fileResolver.findReferences2(element);
var expected = <CiderSearchMatch>[
CiderSearchMatch(bPath, [CharacterLocation(4, 13)]),
CiderSearchMatch(aPath, [CharacterLocation(3, 9)])
@@ -592,7 +600,8 @@
''');
await resolveFile(bPath);
- var result = fileResolver.findReferences(_findElement(20, aPath));
+ var element = await _findElement(20, aPath);
+ var result = await fileResolver.findReferences2(element);
var expected = <CiderSearchMatch>[
CiderSearchMatch(bPath, [CharacterLocation(4, 3)]),
CiderSearchMatch(aPath, [CharacterLocation(3, 10)])
@@ -612,7 +621,8 @@
''');
await resolveFile(aPath);
- var result = fileResolver.findReferences(_findElement(10, aPath));
+ var element = await _findElement(10, aPath);
+ var result = await fileResolver.findReferences2(element);
var expected = <CiderSearchMatch>[
CiderSearchMatch(
aPath, [CharacterLocation(1, 11), CharacterLocation(4, 11)])
@@ -630,7 +640,8 @@
}
''');
await resolveFile(aPath);
- var result = fileResolver.findReferences(_findElement(10, aPath));
+ var element = await _findElement(10, aPath);
+ var result = await fileResolver.findReferences2(element);
var expected = <CiderSearchMatch>[
CiderSearchMatch(aPath, [
CharacterLocation(1, 11),
@@ -658,7 +669,8 @@
''');
await resolveFile(bPath);
- var result = fileResolver.findReferences(_findElement(8, aPath));
+ var element = await _findElement(8, aPath);
+ var result = await fileResolver.findReferences2(element);
var expected = <CiderSearchMatch>[
CiderSearchMatch(bPath, [CharacterLocation(3, 8)]),
CiderSearchMatch(aPath, [CharacterLocation(1, 9)])
@@ -666,13 +678,13 @@
expect(result, unorderedEquals(expected));
}
- test_getErrors() {
+ test_getErrors() async {
addTestFile(r'''
var a = b;
var foo = 0;
''');
- var result = getTestErrors();
+ var result = await getTestErrors();
expect(result.path, convertPath('/workspace/dart/test/lib/test.dart'));
expect(result.uri.toString(), 'package:dart.test/test.dart');
assertErrorsInList(result.errors, [
@@ -681,7 +693,7 @@
expect(result.lineInfo.lineStarts, [0, 11, 24]);
}
- test_getErrors_reuse() {
+ test_getErrors_reuse() async {
addTestFile('var a = b;');
var path = convertPath('/workspace/dart/test/lib/test.dart');
@@ -690,34 +702,34 @@
expect(fileResolver.testView!.resolvedLibraries, isEmpty);
// No cached, will resolve once.
- expect(getTestErrors().errors, hasLength(1));
+ expect((await getTestErrors()).errors, hasLength(1));
expect(fileResolver.testView!.resolvedLibraries, [path]);
// Has cached, will be not resolved again.
- expect(getTestErrors().errors, hasLength(1));
+ expect((await getTestErrors()).errors, hasLength(1));
expect(fileResolver.testView!.resolvedLibraries, [path]);
// New resolver.
// Still has cached, will be not resolved.
createFileResolver();
- expect(getTestErrors().errors, hasLength(1));
+ expect((await getTestErrors()).errors, hasLength(1));
expect(fileResolver.testView!.resolvedLibraries, <Object>[]);
// Change the file, new resolver.
// With changed file the previously cached result cannot be used.
addTestFile('var a = c;');
createFileResolver();
- expect(getTestErrors().errors, hasLength(1));
+ expect((await getTestErrors()).errors, hasLength(1));
expect(fileResolver.testView!.resolvedLibraries, [path]);
// New resolver.
// Still has cached, will be not resolved.
createFileResolver();
- expect(getTestErrors().errors, hasLength(1));
+ expect((await getTestErrors()).errors, hasLength(1));
expect(fileResolver.testView!.resolvedLibraries, <Object>[]);
}
- test_getErrors_reuse_changeDependency() {
+ test_getErrors_reuse_changeDependency() async {
newFile2('/workspace/dart/test/lib/a.dart', r'''
var a = 0;
''');
@@ -733,11 +745,11 @@
expect(fileResolver.testView!.resolvedLibraries, isEmpty);
// No cached, will resolve once.
- expect(getTestErrors().errors, hasLength(1));
+ expect((await getTestErrors()).errors, hasLength(1));
expect(fileResolver.testView!.resolvedLibraries, [path]);
// Has cached, will be not resolved again.
- expect(getTestErrors().errors, hasLength(1));
+ expect((await getTestErrors()).errors, hasLength(1));
expect(fileResolver.testView!.resolvedLibraries, [path]);
// Change the dependency, new resolver.
@@ -747,13 +759,13 @@
var a = 4.2;
''');
createFileResolver();
- expect(getTestErrors().errors, hasLength(1));
+ expect((await getTestErrors()).errors, hasLength(1));
expect(fileResolver.testView!.resolvedLibraries, [path]);
// New resolver.
// Still has cached, will be not resolved.
createFileResolver();
- expect(getTestErrors().errors, hasLength(1));
+ expect((await getTestErrors()).errors, hasLength(1));
expect(fileResolver.testView!.resolvedLibraries, <Object>[]);
}
@@ -782,39 +794,41 @@
assertHasOneVariable();
}
- test_getLibraryByUri() {
+ test_getLibraryByUri() async {
newFile2('/workspace/dart/my/lib/a.dart', r'''
class A {}
''');
- var element = fileResolver.getLibraryByUri(
+ var element = await fileResolver.getLibraryByUri2(
uriStr: 'package:dart.my/a.dart',
);
expect(element.definingCompilationUnit.classes, hasLength(1));
}
- test_getLibraryByUri_notExistingFile() {
- var element = fileResolver.getLibraryByUri(
+ test_getLibraryByUri_notExistingFile() async {
+ var element = await fileResolver.getLibraryByUri2(
uriStr: 'package:dart.my/a.dart',
);
expect(element.definingCompilationUnit.classes, isEmpty);
}
- test_getLibraryByUri_partOf() {
+ test_getLibraryByUri_partOf() async {
newFile2('/workspace/dart/my/lib/a.dart', r'''
part of 'b.dart';
''');
- expect(() {
- fileResolver.getLibraryByUri(
+ expect(() async {
+ await fileResolver.getLibraryByUri2(
uriStr: 'package:dart.my/a.dart',
);
}, throwsArgumentError);
}
- test_getLibraryByUri_unresolvedUri() {
- expect(() {
- fileResolver.getLibraryByUri(uriStr: 'my:unresolved');
+ test_getLibraryByUri_unresolvedUri() async {
+ expect(() async {
+ await fileResolver.getLibraryByUri2(
+ uriStr: 'my:unresolved',
+ );
}, throwsArgumentError);
}
@@ -835,16 +849,16 @@
assertNoErrorsInResult();
}
- test_linkLibraries_getErrors() {
+ test_linkLibraries_getErrors() async {
addTestFile(r'''
var a = b;
var foo = 0;
''');
var path = convertPath('/workspace/dart/test/lib/test.dart');
- fileResolver.linkLibraries(path: path);
+ await fileResolver.linkLibraries2(path: path);
- var result = getTestErrors();
+ var result = await getTestErrors();
expect(result.path, path);
expect(result.uri.toString(), 'package:dart.test/test.dart');
assertErrorsInList(result.errors, [
@@ -1136,7 +1150,7 @@
var testView = fileResolver.testView!;
expect(testView.resolvedLibraries, isEmpty);
- fileResolver.resolve(
+ await fileResolver.resolve2(
path: b_path,
completionLine: 0,
completionColumn: 0,
@@ -1169,7 +1183,7 @@
}
''');
- var result = fileResolver.resolveLibrary(path: aPath);
+ var result = await fileResolver.resolveLibrary2(path: aPath);
expect(result.units.length, 2);
expect(result.units[0].path, aPath);
expect(result.units[0].uri, Uri.parse('package:dart.test/a.dart'));
@@ -1270,8 +1284,8 @@
expect(fileResolver.fsState!.testView.removedPaths, matcher);
}
- Element _findElement(int offset, String filePath) {
- var resolvedUnit = fileResolver.resolve(path: filePath);
+ Future<Element> _findElement(int offset, String filePath) async {
+ var resolvedUnit = await fileResolver.resolve2(path: filePath);
var node = NodeLocator(offset).searchWithin(resolvedUnit.unit);
var element = getElementOfNode(node);
return element!;
diff --git a/pkg/analyzer/test/src/services/available_declarations_test.dart b/pkg/analyzer/test/src/services/available_declarations_test.dart
index ded4f5a..84e997f 100644
--- a/pkg/analyzer/test/src/services/available_declarations_test.dart
+++ b/pkg/analyzer/test/src/services/available_declarations_test.dart
@@ -3491,9 +3491,9 @@
newFile2(a, 'class A {}');
newFile2(b, 'class B {}');
newFile2(c, 'class C {}');
- await testAnalysisContext.currentSession.getFile2(a);
- await testAnalysisContext.currentSession.getFile2(b);
- await 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_cli/lib/src/error_formatter.dart b/pkg/analyzer_cli/lib/src/error_formatter.dart
index 5455b3e..ceec735 100644
--- a/pkg/analyzer_cli/lib/src/error_formatter.dart
+++ b/pkg/analyzer_cli/lib/src/error_formatter.dart
@@ -311,7 +311,7 @@
// TODO(scheglov) We should add `LineInfo` to `DiagnosticMessage`.
var session = result.session.analysisContext;
if (session is DriverBasedAnalysisContext) {
- var fileResult = await session.driver.getFile(message.filePath);
+ var fileResult = session.driver.getFileSync(message.filePath);
if (fileResult is FileResult) {
var lineInfo = fileResult.lineInfo;
var location = lineInfo.getLocation(message.offset);
diff --git a/pkg/analyzer_utilities/lib/verify_tests.dart b/pkg/analyzer_utilities/lib/verify_tests.dart
index 9bc21e4..bdbf86d 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 = await session.getParsedUnit2(testAllFile.path);
+ var result = session.getParsedUnit(testAllFile.path);
if (result is! ParsedUnitResult) {
fail('Could not parse ${testAllFile.path}');
}
diff --git a/pkg/test_runner/tool/orphan_files.dart b/pkg/test_runner/tool/orphan_files.dart
index 4924123..6457209 100644
--- a/pkg/test_runner/tool/orphan_files.dart
+++ b/pkg/test_runner/tool/orphan_files.dart
@@ -17,7 +17,7 @@
import 'package:analyzer/dart/ast/ast.dart';
import 'package:test_runner/src/path.dart';
-Future<void> main(List<String> arguments) async {
+void main(List<String> arguments) {
_initAnalysisContext();
var suites = Directory('tests').listSync();
@@ -26,14 +26,14 @@
for (var entry in suites) {
// Skip the co19 tests since they don't use '_test.dart'.
if (entry is Directory && !entry.path.contains('co19')) {
- await _checkTestDirectory(entry);
+ _checkTestDirectory(entry);
}
}
}
AnalysisContext _analysisContext;
-Future<void> _checkTestDirectory(Directory directory) async {
+void _checkTestDirectory(Directory directory) {
print('-- ${directory.path} --');
var paths = directory
.listSync(recursive: true)
@@ -46,7 +46,7 @@
print('Finding referenced files...');
var importedPaths = <String>{};
for (var path in paths) {
- await _parseReferences(importedPaths, path);
+ _parseReferences(importedPaths, path);
}
// Find the ".dart" files that don't end in "_test.dart" but also aren't used
@@ -71,11 +71,10 @@
_analysisContext = ContextBuilder().createContext(contextRoot: roots[0]);
}
-Future<void> _parseReferences(
- Set<String> importedPaths, String filePath) async {
+void _parseReferences(Set<String> importedPaths, String filePath) {
var absolute = Path(filePath).absolute.toNativePath();
var analysisSession = _analysisContext.currentSession;
- var parseResult = await analysisSession.getParsedUnit2(absolute);
+ var parseResult = analysisSession.getParsedUnit(absolute);
var unit = (parseResult as ParsedUnitResult).unit;
void add(String importPath) {
diff --git a/tools/VERSION b/tools/VERSION
index db82f3b..64c8ecd 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 17
PATCH 0
-PRERELEASE 224
+PRERELEASE 225
PRERELEASE_PATCH 0
\ No newline at end of file