mirror of
https://github.com/dart-lang/sdk
synced 2024-10-04 16:04:53 +00:00
Rename AnalysisSession.getXyz2() into getXyz().
Change-Id: Ia76aafc6a1190dcdca026097c364270389f2860a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206565 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
parent
3e83023d72
commit
cac96f7f8d
|
@ -380,7 +380,7 @@ abstract class AbstractAnalysisServer {
|
|||
}
|
||||
|
||||
var session = getAnalysisDriver(path)?.currentSession;
|
||||
var result = session?.getParsedUnit2(path);
|
||||
var result = session?.getParsedUnit(path);
|
||||
return result is ParsedUnitResult ? result : null;
|
||||
}
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ class CompletionResolveHandler
|
|||
|
||||
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 {
|
||||
|
|
|
@ -172,7 +172,7 @@ class BulkFixProcessor {
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -154,7 +154,7 @@ class CreateMethod extends CorrectionProducer {
|
|||
// 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;
|
||||
}
|
||||
|
|
|
@ -450,7 +450,7 @@ class _ImportLibraryContainingExtension extends CorrectionProducer {
|
|||
|
||||
@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
|
||||
|
|
|
@ -37,7 +37,7 @@ Future<void> addLibraryImports(AnalysisSession session, SourceChange change,
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ class MoveFileRefactoringImpl extends RefactoringImpl
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ class RenameImportRefactoringImpl extends RenameRefactoringImpl {
|
|||
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 @@ class RenameImportRefactoringImpl extends RenameRefactoringImpl {
|
|||
/// 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;
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ class AbstractContextTest with ResourceProviderMixin {
|
|||
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 @@ class AbstractContextTest with ResourceProviderMixin {
|
|||
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
|
||||
|
|
|
@ -70,7 +70,7 @@ class AbstractSingleUnitTest extends AbstractContextTest {
|
|||
}
|
||||
|
||||
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!;
|
||||
|
|
|
@ -536,7 +536,7 @@ abstract class _BaseDartCompletionContributorTest extends AbstractContextTest
|
|||
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());
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ part 'test.dart';
|
|||
|
||||
// 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 {
|
||||
|
|
|
@ -582,7 +582,7 @@ import 'package:b/a.dart';''');
|
|||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -925,7 +925,7 @@ int c;
|
|||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ import 'package:test/old_name.dart';
|
|||
// 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 @@ import 'package:test0.test1.test2/111/name.dart';
|
|||
// 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 @@ import 'package:test0.test1.test2/111/name.dart';
|
|||
// 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 @@ import 'package:test0.test1.test2/111/name.dart';
|
|||
// 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 @@ import 'package:test/111/old_name.dart';
|
|||
// 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 @@ import 'package:test/222/old_name.dart';
|
|||
// 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();
|
||||
|
|
|
@ -398,7 +398,7 @@ void myMethod() {
|
|||
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();
|
||||
}
|
||||
|
|
|
@ -582,7 +582,7 @@ main() {}
|
|||
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();
|
||||
}
|
||||
|
|
|
@ -114,7 +114,7 @@ void main() {
|
|||
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);
|
||||
|
|
|
@ -50,7 +50,7 @@ class ImportElementsComputerTest extends AbstractContextTest {
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -471,7 +471,7 @@ bool randomBool() {
|
|||
// 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();
|
||||
|
|
|
@ -32,7 +32,7 @@ class AbstractOutlineComputerTest extends AbstractContextTest
|
|||
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,
|
||||
|
|
|
@ -194,7 +194,7 @@ void a(String b) {
|
|||
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();
|
||||
}
|
||||
|
|
|
@ -517,7 +517,7 @@ class MyWidget extends StatelessWidget {
|
|||
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();
|
||||
}
|
||||
|
|
|
@ -70,6 +70,6 @@ transforms:
|
|||
|
||||
extension on AnalysisSession {
|
||||
Future<ResolvedLibraryResult> getResolvedLibraryValid(String path) async {
|
||||
return await getResolvedLibrary2(path) as ResolvedLibraryResult;
|
||||
return await getResolvedLibrary(path) as ResolvedLibraryResult;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -262,7 +262,7 @@ abstract class FixProcessorTest extends BaseFixProcessorTest {
|
|||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ class CompletionRunner {
|
|||
}
|
||||
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 @@ class CompletionRunner {
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -134,7 +134,7 @@ void buildTestsIn(AnalysisSession session, String testDirPath,
|
|||
}
|
||||
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');
|
||||
}
|
||||
|
|
|
@ -1394,7 +1394,7 @@ class CodeShapeMetricsComputer {
|
|||
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.
|
||||
//
|
||||
|
|
|
@ -1293,7 +1293,7 @@ class CompletionMetricsComputer {
|
|||
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 @@ class CompletionMetricsComputer {
|
|||
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,
|
||||
|
|
|
@ -207,7 +207,7 @@ class FlutterMetricsComputer {
|
|||
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.
|
||||
//
|
||||
|
|
|
@ -184,7 +184,7 @@ class ImpliedTypeComputer {
|
|||
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.
|
||||
//
|
||||
|
|
|
@ -1940,7 +1940,7 @@ class RelevanceMetricsComputer {
|
|||
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.
|
||||
//
|
||||
|
|
|
@ -1459,7 +1459,7 @@ class RelevanceMetricsComputer {
|
|||
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.
|
||||
//
|
||||
|
|
|
@ -55,7 +55,7 @@ void buildTestsIn(AnalysisSession session, String testDirPath,
|
|||
}
|
||||
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');
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
* 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()`.
|
||||
|
|
|
@ -32,7 +32,7 @@ void main(List<String> args) async {
|
|||
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) {
|
||||
|
|
|
@ -35,47 +35,105 @@ abstract class AnalysisSession {
|
|||
///
|
||||
/// 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);
|
||||
}
|
||||
|
||||
|
|
|
@ -115,7 +115,7 @@ Future<SomeResolvedUnitResult> resolveFile2(
|
|||
{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]
|
||||
|
|
|
@ -55,31 +55,55 @@ class AnalysisSessionImpl implements AnalysisSession {
|
|||
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 @@ class AnalysisSessionImpl implements AnalysisSession {
|
|||
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 @@ class AnalysisSessionImpl implements AnalysisSession {
|
|||
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() {
|
||||
|
|
|
@ -22,7 +22,7 @@ class AnalysisSessionHelper {
|
|||
/// 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) {
|
||||
|
@ -60,7 +60,7 @@ class AnalysisSessionHelper {
|
|||
/// 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 @@ class AnalysisSessionHelper {
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -181,18 +181,18 @@ class _MicroAnalysisSessionImpl extends AnalysisSessionImpl {
|
|||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ class BaseDependencyTest extends PubPackageResolutionTest {
|
|||
|
||||
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();
|
||||
}
|
||||
|
|
|
@ -276,7 +276,7 @@ void f() {
|
|||
var testFilePathConverted = convertPath(testFilePath);
|
||||
var errorsResult = await contextFor(testFilePathConverted)
|
||||
.currentSession
|
||||
.getErrors2(testFilePathConverted) as ErrorsResult;
|
||||
.getErrors(testFilePathConverted) as ErrorsResult;
|
||||
return errorsResult.errors;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -439,7 +439,7 @@ class GetElementDeclarationParsedTest extends PubPackageResolutionTest
|
|||
|
||||
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 @@ class GetElementDeclarationResolvedTest extends PubPackageResolutionTest
|
|||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ class AnalysisSessionImpl_BazelWorkspaceTest
|
|||
|
||||
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 @@ class AnalysisSessionImpl_BazelWorkspaceTest
|
|||
|
||||
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 @@ class AnalysisSessionImpl_BazelWorkspaceTest
|
|||
|
||||
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 @@ class AnalysisSessionImpl_BazelWorkspaceTest
|
|||
|
||||
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 @@ class AnalysisSessionImpl_BazelWorkspaceTest
|
|||
);
|
||||
|
||||
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 @@ class AnalysisSessionImpl_BazelWorkspaceTest
|
|||
);
|
||||
|
||||
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 @@ class AnalysisSessionImpl_BazelWorkspaceTest
|
|||
|
||||
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:lib/
|
|||
}
|
||||
|
||||
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 @@ class B {}
|
|||
}
|
||||
|
||||
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>());
|
||||
}
|
||||
|
||||
|
@ -242,13 +241,13 @@ class B {}
|
|||
}
|
||||
|
||||
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 {
|
||||
|
@ -332,7 +331,7 @@ class B {}
|
|||
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;
|
||||
|
||||
|
@ -417,7 +416,7 @@ part 'c.dart';
|
|||
var aaaSession =
|
||||
contextCollection.contextFor(aaaContextPath).currentSession;
|
||||
|
||||
var result = aaaSession.getParsedLibraryByElement2(element);
|
||||
var result = aaaSession.getParsedLibraryByElement(element);
|
||||
expect(result, isA<NotElementOfThisSessionResult>());
|
||||
}
|
||||
|
||||
|
@ -435,7 +434,7 @@ class B {}
|
|||
}
|
||||
|
||||
test_getParsedUnit2_invalidPath_notAbsolute() async {
|
||||
var result = session.getParsedUnit2('not_absolute.dart');
|
||||
var result = session.getParsedUnit('not_absolute.dart');
|
||||
expect(result, isA<InvalidPathResult>());
|
||||
}
|
||||
|
||||
|
@ -506,14 +505,14 @@ class B2 extends X {}
|
|||
}
|
||||
|
||||
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>());
|
||||
}
|
||||
|
||||
|
@ -603,7 +602,7 @@ part 'c.dart';
|
|||
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 @@ class B {}
|
|||
''');
|
||||
|
||||
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 @@ class B {}
|
|||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -190,7 +190,7 @@ abstract class ContextResolutionTest
|
|||
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
|
||||
|
|
|
@ -3496,9 +3496,9 @@ class C {}
|
|||
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();
|
||||
|
|
|
@ -6116,7 +6116,7 @@ library
|
|||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -287,7 +287,7 @@ class DocumentationValidator {
|
|||
/// [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"');
|
||||
}
|
||||
|
|
|
@ -118,7 +118,7 @@ $snippet
|
|||
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;
|
||||
|
|
|
@ -363,7 +363,7 @@ class DocumentationGenerator {
|
|||
/// [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"');
|
||||
}
|
||||
|
|
|
@ -246,7 +246,7 @@ class ChangeBuilderImpl implements ChangeBuilder {
|
|||
}
|
||||
|
||||
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"');
|
||||
}
|
||||
|
|
|
@ -178,7 +178,7 @@ class _DartNavigationCollector {
|
|||
return null;
|
||||
}
|
||||
|
||||
var parsedLibrary = session.getParsedLibrary2(libraryPath);
|
||||
var parsedLibrary = session.getParsedLibrary(libraryPath);
|
||||
if (parsedLibrary is! ParsedLibraryResult) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -469,7 +469,7 @@ class _Base extends AbstractContextTest with DartChangeBuilderMixin {
|
|||
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');
|
||||
|
|
|
@ -98,7 +98,7 @@ class AbstractContextTest with ResourceProviderMixin {
|
|||
|
||||
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() {
|
||||
|
|
|
@ -103,7 +103,7 @@ class VerifyTests {
|
|||
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}');
|
||||
}
|
||||
|
|
|
@ -1000,7 +1000,7 @@ class _FixCodeProcessor extends Object {
|
|||
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,7 +1015,7 @@ class _FixCodeProcessor extends Object {
|
|||
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) {
|
||||
|
@ -1029,7 +1029,7 @@ class _FixCodeProcessor extends Object {
|
|||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ class InfoBuilder {
|
|||
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) {
|
||||
var sourceInfo =
|
||||
|
|
|
@ -120,7 +120,7 @@ export 'package:test_core/test_core.dart';
|
|||
}
|
||||
|
||||
LineInfo getLineInfo(String path) =>
|
||||
(session.getFile2(path) as FileResult).lineInfo;
|
||||
(session.getFile(path) as FileResult).lineInfo;
|
||||
|
||||
void setUp() {
|
||||
setupResourceProvider();
|
||||
|
|
|
@ -38,7 +38,7 @@ class AbstractSingleUnitTest extends AbstractContextTest {
|
|||
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) {
|
||||
|
|
|
@ -65,7 +65,7 @@ abstract class _ProvisionalApiTestBase extends AbstractContextTest {
|
|||
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) {
|
||||
var errors =
|
||||
|
@ -80,7 +80,7 @@ abstract class _ProvisionalApiTestBase extends AbstractContextTest {
|
|||
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) {
|
||||
migration.processInput(unit);
|
||||
|
@ -89,7 +89,7 @@ abstract class _ProvisionalApiTestBase extends AbstractContextTest {
|
|||
}
|
||||
_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) {
|
||||
migration.finalizeInput(unit);
|
||||
|
|
|
@ -24,7 +24,7 @@ void main() {
|
|||
@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 {
|
||||
|
|
|
@ -236,7 +236,7 @@ class NnbdMigrationTestBase extends AbstractAnalysisTest {
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -149,7 +149,7 @@ abstract class _InstrumentationTestBase extends AbstractContextTest {
|
|||
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);
|
||||
|
|
|
@ -67,12 +67,12 @@ void main(List<String> args) async {
|
|||
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 @@ void main(List<String> args) async {
|
|||
}
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ void _checkTestDirectory(Directory directory) {
|
|||
|
||||
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) {
|
||||
|
|
Loading…
Reference in a new issue