mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
Migrate several test classes
Change-Id: I7477d5c42a8c2f953c51aca7ab6fff8b6fc930f4 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195840 Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
parent
2622d728ae
commit
02d50e7ebf
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:analysis_server/protocol/protocol.dart';
|
||||
import 'package:analysis_server/protocol/protocol_generated.dart';
|
||||
import 'package:analysis_server/src/domain_analysis.dart';
|
||||
|
@ -128,7 +126,7 @@ main() {
|
|||
var request = _createGetErrorsRequest(file);
|
||||
var response = await serverChannel.sendRequest(request);
|
||||
expect(response.error, isNotNull);
|
||||
expect(response.error.code, RequestErrorCode.GET_ERRORS_INVALID_FILE);
|
||||
expect(response.error!.code, RequestErrorCode.GET_ERRORS_INVALID_FILE);
|
||||
}
|
||||
|
||||
Request _createGetErrorsRequest(String file) {
|
||||
|
|
|
@ -2,10 +2,7 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:analysis_server/protocol/protocol_generated.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
|
@ -45,12 +42,11 @@ class A {}
|
|||
|
||||
@reflectiveTest
|
||||
class AnalysisHoverTest extends AbstractAnalysisTest {
|
||||
Future<HoverInformation> prepareHover(String search) {
|
||||
var offset = findOffset(search);
|
||||
return prepareHoverAt(offset);
|
||||
Future<HoverInformation> prepareHover(String search) async {
|
||||
return (await prepareHoverOrNull(search))!;
|
||||
}
|
||||
|
||||
Future<HoverInformation> prepareHoverAt(int offset) async {
|
||||
Future<HoverInformation?> prepareHoverAt(int offset) async {
|
||||
await waitForTasksFinished();
|
||||
var request = AnalysisGetHoverParams(testFile, offset).toRequest('0');
|
||||
var response = await waitResponse(request);
|
||||
|
@ -59,6 +55,11 @@ class AnalysisHoverTest extends AbstractAnalysisTest {
|
|||
return hovers.isNotEmpty ? hovers.first : null;
|
||||
}
|
||||
|
||||
Future<HoverInformation?> prepareHoverOrNull(String search) {
|
||||
var offset = findOffset(search);
|
||||
return prepareHoverAt(offset);
|
||||
}
|
||||
|
||||
@override
|
||||
void setUp() {
|
||||
super.setUp();
|
||||
|
@ -662,7 +663,7 @@ main() {
|
|||
// nothing
|
||||
}
|
||||
''');
|
||||
var hover = await prepareHover('nothing');
|
||||
var hover = await prepareHoverOrNull('nothing');
|
||||
expect(hover, isNull);
|
||||
}
|
||||
|
||||
|
@ -896,10 +897,10 @@ typedef void A(int a);
|
|||
|
||||
void _assertHover(
|
||||
HoverInformation hover, {
|
||||
String containingLibraryPath,
|
||||
String containingLibraryName,
|
||||
@required String elementDescription,
|
||||
@required String elementKind,
|
||||
String? containingLibraryPath,
|
||||
String? containingLibraryName,
|
||||
required String elementDescription,
|
||||
required String elementKind,
|
||||
bool isDeprecated = false,
|
||||
}) {
|
||||
containingLibraryName ??= 'bin/test.dart';
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:analysis_server/src/protocol_server.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
@ -24,7 +22,7 @@ class AnalysisSignatureTest extends AbstractAnalysisTest {
|
|||
return prepareRawSignatureAt(offset);
|
||||
}
|
||||
|
||||
Future<Response> prepareRawSignatureAt(int offset, {String file}) async {
|
||||
Future<Response> prepareRawSignatureAt(int offset, {String? file}) async {
|
||||
await waitForTasksFinished();
|
||||
var request =
|
||||
AnalysisGetSignatureParams(file ?? testFile, offset).toRequest('0');
|
||||
|
@ -37,7 +35,7 @@ class AnalysisSignatureTest extends AbstractAnalysisTest {
|
|||
}
|
||||
|
||||
Future<AnalysisGetSignatureResult> prepareSignatureAt(int offset,
|
||||
{String file}) async {
|
||||
{String? file}) async {
|
||||
var response = await prepareRawSignatureAt(offset, file: file);
|
||||
return AnalysisGetSignatureResult.fromResponse(response);
|
||||
}
|
||||
|
@ -131,17 +129,15 @@ main() {
|
|||
}
|
||||
''');
|
||||
var result = await prepareRawSignature('/*^*/');
|
||||
expect(result.error, isNotNull);
|
||||
expect(result.error.code,
|
||||
equals(RequestErrorCode.GET_SIGNATURE_UNKNOWN_FUNCTION));
|
||||
var error = result.error!;
|
||||
expect(error.code, equals(RequestErrorCode.GET_SIGNATURE_UNKNOWN_FUNCTION));
|
||||
}
|
||||
|
||||
Future<void> test_error_file_not_analyzed() async {
|
||||
var result = await prepareRawSignatureAt(0,
|
||||
file: convertPath('/not/in/project.dart'));
|
||||
expect(result.error, isNotNull);
|
||||
expect(
|
||||
result.error.code, equals(RequestErrorCode.GET_SIGNATURE_INVALID_FILE));
|
||||
var error = result.error!;
|
||||
expect(error.code, equals(RequestErrorCode.GET_SIGNATURE_INVALID_FILE));
|
||||
}
|
||||
|
||||
Future<void> test_error_function_unknown() async {
|
||||
|
@ -149,9 +145,8 @@ main() {
|
|||
someFunc(/*^*/);
|
||||
''');
|
||||
var result = await prepareRawSignature('/*^*/');
|
||||
expect(result.error, isNotNull);
|
||||
expect(result.error.code,
|
||||
equals(RequestErrorCode.GET_SIGNATURE_UNKNOWN_FUNCTION));
|
||||
var error = result.error!;
|
||||
expect(error.code, equals(RequestErrorCode.GET_SIGNATURE_UNKNOWN_FUNCTION));
|
||||
}
|
||||
|
||||
Future<void> test_error_offset_invalid() async {
|
||||
|
@ -159,9 +154,8 @@ someFunc(/*^*/);
|
|||
a() {}
|
||||
''');
|
||||
var result = await prepareRawSignatureAt(1000);
|
||||
expect(result.error, isNotNull);
|
||||
expect(result.error.code,
|
||||
equals(RequestErrorCode.GET_SIGNATURE_INVALID_OFFSET));
|
||||
var error = result.error!;
|
||||
expect(error.code, equals(RequestErrorCode.GET_SIGNATURE_INVALID_OFFSET));
|
||||
}
|
||||
|
||||
Future<void> test_function_expression() async {
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:analysis_server/protocol/protocol.dart';
|
||||
import 'package:analysis_server/protocol/protocol_constants.dart';
|
||||
import 'package:analysis_server/protocol/protocol_generated.dart'
|
||||
|
@ -33,13 +31,13 @@ main() {
|
|||
print(y);
|
||||
}''';
|
||||
|
||||
List<AnalysisError> get errors => filesErrors[testFile];
|
||||
List<AnalysisError> get errors => filesErrors[testFile]!;
|
||||
|
||||
List<AnalysisError> get optionsFileErrors => filesErrors[optionsFilePath];
|
||||
List<AnalysisError> get optionsFileErrors => filesErrors[optionsFilePath]!;
|
||||
|
||||
String get optionsFilePath => '$projectPath/analysis_options.yaml';
|
||||
|
||||
List<AnalysisError> get testFileErrors => filesErrors[testFile];
|
||||
List<AnalysisError> get testFileErrors => filesErrors[testFile]!;
|
||||
|
||||
void addOptionsFile(String contents) {
|
||||
newFile(optionsFilePath, content: contents);
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:analysis_server/protocol/protocol.dart';
|
||||
import 'package:analysis_server/protocol/protocol_constants.dart';
|
||||
import 'package:analysis_server/protocol/protocol_generated.dart';
|
||||
|
@ -20,7 +18,7 @@ void main() {
|
|||
|
||||
@reflectiveTest
|
||||
class AnalysisNotificationAnalyzedFilesTest extends AbstractAnalysisTest {
|
||||
List<String> analyzedFiles;
|
||||
late List<String> analyzedFiles;
|
||||
bool analyzedFilesReceived = false;
|
||||
|
||||
void assertHasFile(String filePath) {
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:analysis_server/protocol/protocol.dart';
|
||||
|
@ -38,9 +36,9 @@ Widget build(BuildContext context) {
|
|||
ClosingLabel(79, 57, '<Widget>[]')
|
||||
];
|
||||
|
||||
List<ClosingLabel> lastLabels;
|
||||
List<ClosingLabel>? lastLabels;
|
||||
|
||||
Completer _labelsReceived;
|
||||
late Completer _labelsReceived;
|
||||
|
||||
@override
|
||||
void processNotification(Notification notification) {
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:analysis_server/protocol/protocol.dart';
|
||||
import 'package:analysis_server/protocol/protocol_constants.dart';
|
||||
import 'package:analysis_server/protocol/protocol_generated.dart';
|
||||
|
@ -27,8 +25,8 @@ void main() {
|
|||
|
||||
@reflectiveTest
|
||||
class NotificationErrorsTest extends AbstractAnalysisTest {
|
||||
Folder pedanticFolder;
|
||||
Map<String, List<AnalysisError>> filesErrors = {};
|
||||
late Folder pedanticFolder;
|
||||
Map<String, List<AnalysisError>?> filesErrors = {};
|
||||
|
||||
@override
|
||||
void processNotification(Notification notification) {
|
||||
|
@ -69,7 +67,7 @@ linter:
|
|||
//
|
||||
// Verify the error result.
|
||||
//
|
||||
var errors = filesErrors[analysisOptionsFile];
|
||||
var errors = filesErrors[analysisOptionsFile]!;
|
||||
expect(errors, hasLength(1));
|
||||
var error = errors[0];
|
||||
expect(error.location.file, filePath);
|
||||
|
@ -90,7 +88,7 @@ include: package:pedantic/analysis_options.yaml
|
|||
await pumpEventQueue();
|
||||
|
||||
// Verify there's an error for the import.
|
||||
var errors = filesErrors[analysisOptionsFile];
|
||||
var errors = filesErrors[analysisOptionsFile]!;
|
||||
expect(errors, hasLength(1));
|
||||
var error = errors[0];
|
||||
expect(error.location.file, filePath);
|
||||
|
@ -105,7 +103,7 @@ pedantic:${pedanticFolder.toUri()}
|
|||
// Ensure the errors disappear.
|
||||
await waitForTasksFinished();
|
||||
await pumpEventQueue();
|
||||
errors = filesErrors[analysisOptionsFile];
|
||||
errors = filesErrors[analysisOptionsFile]!;
|
||||
expect(errors, hasLength(0));
|
||||
}
|
||||
|
||||
|
@ -132,7 +130,7 @@ analyzer:
|
|||
//
|
||||
// Verify the error result.
|
||||
//
|
||||
var errors = filesErrors[manifestFile];
|
||||
var errors = filesErrors[manifestFile]!;
|
||||
expect(errors, hasLength(1));
|
||||
var error = errors[0];
|
||||
expect(error.location.file, filePath);
|
||||
|
@ -216,7 +214,7 @@ transforms:
|
|||
//
|
||||
// Verify the error result.
|
||||
//
|
||||
var errors = filesErrors[dataFile];
|
||||
var errors = filesErrors[dataFile]!;
|
||||
expect(errors, hasLength(1));
|
||||
var error = errors[0];
|
||||
expect(error.location.file, filePath);
|
||||
|
@ -309,7 +307,7 @@ import 'does_not_exist.dart';
|
|||
''');
|
||||
await waitForTasksFinished();
|
||||
await pumpEventQueue(times: 5000);
|
||||
var errors = filesErrors[testFile];
|
||||
var errors = filesErrors[testFile]!;
|
||||
// Verify that we are generating only 1 error for the bad URI.
|
||||
// https://github.com/dart-lang/sdk/issues/23754
|
||||
expect(errors, hasLength(1));
|
||||
|
@ -336,7 +334,7 @@ linter:
|
|||
|
||||
await waitForTasksFinished();
|
||||
|
||||
var testDriver = server.getAnalysisDriver(testFile);
|
||||
var testDriver = server.getAnalysisDriver(testFile)!;
|
||||
var lints = testDriver.analysisOptions.lintRules;
|
||||
|
||||
// Registry should only contain single lint rule.
|
||||
|
@ -345,7 +343,7 @@ linter:
|
|||
expect(lint.name, camelCaseTypesLintName);
|
||||
|
||||
// Verify lint error result.
|
||||
var errors = filesErrors[testFile];
|
||||
var errors = filesErrors[testFile]!;
|
||||
expect(errors, hasLength(1));
|
||||
var error = errors[0];
|
||||
expect(error.location.file, join(projectPath, 'bin', 'test.dart'));
|
||||
|
@ -474,7 +472,7 @@ main() {
|
|||
addTestFile('library lib');
|
||||
await waitForTasksFinished();
|
||||
await pumpEventQueue(times: 5000);
|
||||
var errors = filesErrors[testFile];
|
||||
var errors = filesErrors[testFile]!;
|
||||
expect(errors, hasLength(1));
|
||||
var error = errors[0];
|
||||
expect(error.location.file, join(projectPath, 'bin', 'test.dart'));
|
||||
|
@ -499,7 +497,7 @@ version: 1.3.2
|
|||
//
|
||||
// Verify the error result.
|
||||
//
|
||||
var errors = filesErrors[pubspecFile];
|
||||
var errors = filesErrors[pubspecFile]!;
|
||||
expect(errors, hasLength(1));
|
||||
var error = errors[0];
|
||||
expect(error.location.file, filePath);
|
||||
|
@ -515,7 +513,7 @@ version: 1.3.2
|
|||
await waitForTasksFinished();
|
||||
await pumpEventQueue();
|
||||
|
||||
errors = filesErrors[pubspecFile];
|
||||
errors = filesErrors[pubspecFile]!;
|
||||
expect(errors, hasLength(0));
|
||||
}
|
||||
|
||||
|
@ -544,7 +542,7 @@ dependencies:
|
|||
//
|
||||
// Verify the error result.
|
||||
//
|
||||
var errors = filesErrors[pubspecFile];
|
||||
var errors = filesErrors[pubspecFile]!;
|
||||
expect(errors, hasLength(1));
|
||||
var error = errors[0];
|
||||
expect(error.location.file, filePath);
|
||||
|
@ -563,7 +561,7 @@ dependencies:
|
|||
await waitForTasksFinished();
|
||||
await pumpEventQueue();
|
||||
|
||||
errors = filesErrors[pubspecFile];
|
||||
errors = filesErrors[pubspecFile]!;
|
||||
expect(errors, hasLength(0));
|
||||
}
|
||||
|
||||
|
@ -582,7 +580,7 @@ void f(E e) {
|
|||
''');
|
||||
await waitForTasksFinished();
|
||||
await pumpEventQueue(times: 5000);
|
||||
var errors = filesErrors[testFile];
|
||||
var errors = filesErrors[testFile]!;
|
||||
expect(errors, hasLength(1));
|
||||
var error = errors[0];
|
||||
expect(error.severity, AnalysisErrorSeverity.WARNING);
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:analysis_server/protocol/protocol_constants.dart';
|
||||
|
@ -34,9 +32,9 @@ main async() {}
|
|||
FoldingRegion(FoldingKind.DIRECTIVES, 6, 34)
|
||||
];
|
||||
|
||||
List<FoldingRegion> lastRegions;
|
||||
List<FoldingRegion>? lastRegions;
|
||||
|
||||
Completer _regionsReceived;
|
||||
late Completer _regionsReceived;
|
||||
|
||||
@override
|
||||
void processNotification(Notification notification) {
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:analysis_server/protocol/protocol.dart';
|
||||
|
@ -1244,7 +1242,7 @@ class A {
|
|||
}
|
||||
|
||||
class HighlightsTestSupport extends AbstractAnalysisTest {
|
||||
List<HighlightRegion> regions;
|
||||
late List<HighlightRegion> regions;
|
||||
|
||||
final Completer<void> _resultsAvailable = Completer();
|
||||
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:analysis_server/protocol/protocol.dart';
|
||||
import 'package:analysis_server/protocol/protocol_constants.dart';
|
||||
import 'package:analysis_server/protocol/protocol_generated.dart';
|
||||
|
@ -21,8 +19,8 @@ void main() {
|
|||
|
||||
@reflectiveTest
|
||||
class AnalysisNotificationImplementedTest extends AbstractAnalysisTest {
|
||||
List<ImplementedClass> implementedClasses;
|
||||
List<ImplementedMember> implementedMembers;
|
||||
List<ImplementedClass>? implementedClasses;
|
||||
List<ImplementedMember>? implementedMembers;
|
||||
|
||||
/// Validates that there is an [ImplementedClass] at the offset of [search].
|
||||
///
|
||||
|
@ -34,9 +32,9 @@ class AnalysisNotificationImplementedTest extends AbstractAnalysisTest {
|
|||
length = findIdentifierLength(search);
|
||||
}
|
||||
if (implementedClasses == null) {
|
||||
fail('No notification of impemented classes was received');
|
||||
fail('No notification of implemented classes was received');
|
||||
}
|
||||
for (var clazz in implementedClasses) {
|
||||
for (var clazz in implementedClasses!) {
|
||||
if (clazz.offset == offset && clazz.length == length) {
|
||||
return;
|
||||
}
|
||||
|
@ -55,9 +53,9 @@ class AnalysisNotificationImplementedTest extends AbstractAnalysisTest {
|
|||
length = findIdentifierLength(search);
|
||||
}
|
||||
if (implementedMembers == null) {
|
||||
fail('No notification of impemented members was received');
|
||||
fail('No notification of implemented members was received');
|
||||
}
|
||||
for (var member in implementedMembers) {
|
||||
for (var member in implementedMembers!) {
|
||||
if (member.offset == offset && member.length == length) {
|
||||
return;
|
||||
}
|
||||
|
@ -76,9 +74,9 @@ class AnalysisNotificationImplementedTest extends AbstractAnalysisTest {
|
|||
length = findIdentifierLength(search);
|
||||
}
|
||||
if (implementedMembers == null) {
|
||||
fail('No notification of impemented members was received');
|
||||
fail('No notification of implemented members was received');
|
||||
}
|
||||
for (var member in implementedMembers) {
|
||||
for (var member in implementedMembers!) {
|
||||
if (member.offset == offset) {
|
||||
fail('Unexpected implemented member at $offset'
|
||||
' in $implementedMembers');
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:analysis_server/protocol/protocol.dart';
|
||||
|
@ -22,14 +20,14 @@ void main() {
|
|||
}
|
||||
|
||||
class AbstractNavigationTest extends AbstractAnalysisTest {
|
||||
List<NavigationRegion> regions;
|
||||
List<NavigationTarget> targets;
|
||||
List<String> targetFiles;
|
||||
late List<NavigationRegion> regions;
|
||||
late List<NavigationTarget> targets;
|
||||
late List<String> targetFiles;
|
||||
|
||||
NavigationRegion testRegion;
|
||||
List<int> testTargetIndexes;
|
||||
List<NavigationTarget> testTargets;
|
||||
NavigationTarget testTarget;
|
||||
late NavigationRegion testRegion;
|
||||
late List<int> testTargetIndexes;
|
||||
late List<NavigationTarget> testTargets;
|
||||
late NavigationTarget testTarget;
|
||||
|
||||
/// Validates that there is a target in [testTargetIndexes] with [file],
|
||||
/// at [offset] and with the given [length].
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:analysis_server/protocol/protocol.dart';
|
||||
|
@ -23,8 +21,8 @@ void main() {
|
|||
|
||||
@reflectiveTest
|
||||
class AnalysisNotificationOccurrencesTest extends AbstractAnalysisTest {
|
||||
List<Occurrences> occurrencesList;
|
||||
Occurrences testOccurrences;
|
||||
late List<Occurrences> occurrencesList;
|
||||
late Occurrences testOccurrences;
|
||||
|
||||
final Completer<void> _resultsAvailable = Completer();
|
||||
|
||||
|
@ -51,7 +49,7 @@ class AnalysisNotificationOccurrencesTest extends AbstractAnalysisTest {
|
|||
/// Otherwise remembers this it into [testOccurrences].
|
||||
///
|
||||
/// If [exists] is `false`, then fails if such [Occurrences] exists.
|
||||
void findRegion(int offset, int length, [bool exists]) {
|
||||
void findRegion(int offset, int length, [bool? exists]) {
|
||||
for (var occurrences in occurrencesList) {
|
||||
if (occurrences.length != length) {
|
||||
continue;
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:analysis_server/protocol/protocol.dart';
|
||||
|
@ -23,12 +21,12 @@ void main() {
|
|||
|
||||
@reflectiveTest
|
||||
class AnalysisNotificationOutlineTest extends AbstractAnalysisTest {
|
||||
FileKind fileKind;
|
||||
String libraryName;
|
||||
Outline outline;
|
||||
late FileKind fileKind;
|
||||
String? libraryName;
|
||||
Outline? outline;
|
||||
|
||||
final Completer<void> _outlineReceived = Completer();
|
||||
Completer _highlightsReceived = Completer();
|
||||
Completer? _highlightsReceived = Completer();
|
||||
|
||||
Future prepareOutline() {
|
||||
addAnalysisSubscription(AnalysisService.OUTLINE, testFile);
|
||||
|
@ -71,7 +69,7 @@ class BBB {
|
|||
await waitForTasksFinished();
|
||||
expect(outline, isNull);
|
||||
await prepareOutline();
|
||||
var unitOutline = outline;
|
||||
var unitOutline = outline!;
|
||||
var outlines = unitOutline.children;
|
||||
expect(outlines, hasLength(2));
|
||||
}
|
||||
|
@ -128,11 +126,11 @@ class B {}
|
|||
// This will pre-cache the analysis result for the file.
|
||||
setPriorityFiles([testFile]);
|
||||
addAnalysisSubscription(AnalysisService.HIGHLIGHTS, testFile);
|
||||
await _highlightsReceived.future;
|
||||
await _highlightsReceived!.future;
|
||||
|
||||
// Now subscribe for outline notification, we must get it even though
|
||||
// the result which is used is pre-cached, and not a newly computed.
|
||||
await prepareOutline();
|
||||
expect(outline.children, hasLength(2));
|
||||
expect(outline!.children, hasLength(2));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:analysis_server/protocol/protocol.dart';
|
||||
|
@ -22,8 +20,8 @@ void main() {
|
|||
|
||||
@reflectiveTest
|
||||
class AnalysisNotificationOverridesTest extends AbstractAnalysisTest {
|
||||
List<Override> overridesList;
|
||||
Override overrideObject;
|
||||
late List<Override> overridesList;
|
||||
late Override overrideObject;
|
||||
|
||||
final Completer<void> _resultsAvailable = Completer();
|
||||
|
||||
|
@ -31,13 +29,14 @@ class AnalysisNotificationOverridesTest extends AbstractAnalysisTest {
|
|||
/// offset of [search] in [override].
|
||||
void assertHasInterfaceMember(String search) {
|
||||
var offset = findOffset(search);
|
||||
for (var member in overrideObject.interfaceMembers) {
|
||||
if (member.element.location.offset == offset) {
|
||||
var interfaceMembers = overrideObject.interfaceMembers!;
|
||||
for (var member in interfaceMembers) {
|
||||
if (member.element.location!.offset == offset) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
fail('Expect to find an overridden interface members at $offset in '
|
||||
'${overrideObject.interfaceMembers.join('\n')}');
|
||||
'${interfaceMembers.join('\n')}');
|
||||
}
|
||||
|
||||
/// Validates that there is an [Override] at the offset of [search].
|
||||
|
@ -57,7 +56,7 @@ class AnalysisNotificationOverridesTest extends AbstractAnalysisTest {
|
|||
void assertHasSuperElement(String search) {
|
||||
var offset = findOffset(search);
|
||||
var member = overrideObject.superclassMember;
|
||||
expect(member.element.location.offset, offset);
|
||||
expect(member!.element.location!.offset, offset);
|
||||
}
|
||||
|
||||
/// Asserts that there are no overridden members from interfaces.
|
||||
|
@ -88,7 +87,7 @@ class AnalysisNotificationOverridesTest extends AbstractAnalysisTest {
|
|||
/// Otherwise remembers this it into [override].
|
||||
///
|
||||
/// If [exists] is `false`, then fails if such [Override] exists.
|
||||
void findOverride(int offset, int length, [bool exists]) {
|
||||
void findOverride(int offset, int length, [bool? exists]) {
|
||||
for (var override in overridesList) {
|
||||
if (override.offset == offset && override.length == length) {
|
||||
if (exists == false) {
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:analysis_server/protocol/protocol.dart';
|
||||
import 'package:analysis_server/protocol/protocol_constants.dart';
|
||||
import 'package:analysis_server/protocol/protocol_generated.dart';
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:analysis_server/protocol/protocol.dart';
|
||||
import 'package:analysis_server/protocol/protocol_generated.dart';
|
||||
import 'package:analysis_server/src/domain_analysis.dart';
|
||||
|
@ -139,8 +137,7 @@ analyzer:
|
|||
var response = await _setPriorityFile(testFile);
|
||||
expect(response, isResponseSuccess('0'));
|
||||
// verify
|
||||
var params = pluginManager.analysisSetPriorityFilesParams;
|
||||
expect(params, isNotNull);
|
||||
var params = pluginManager.analysisSetPriorityFilesParams!;
|
||||
expect(params.files, <String>[testFile]);
|
||||
}
|
||||
|
||||
|
@ -155,7 +152,7 @@ analyzer:
|
|||
}
|
||||
|
||||
void _verifyPriorityFiles(String path) {
|
||||
var driver = server.getAnalysisDriver(path);
|
||||
var driver = server.getAnalysisDriver(path)!;
|
||||
var prioritySources = driver.priorityFiles;
|
||||
expect(prioritySources, [path]);
|
||||
}
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:analysis_server/protocol/protocol.dart';
|
||||
import 'package:analysis_server/protocol/protocol_constants.dart';
|
||||
import 'package:analysis_server/protocol/protocol_generated.dart';
|
||||
|
@ -56,7 +54,7 @@ class UpdateContentTest extends AbstractAnalysisTest {
|
|||
fail('Expected an exception to be thrown');
|
||||
} on RequestFailure catch (e) {
|
||||
expect(e.response.id, id);
|
||||
expect(e.response.error.code, RequestErrorCode.INVALID_OVERLAY_CHANGE);
|
||||
expect(e.response.error!.code, RequestErrorCode.INVALID_OVERLAY_CHANGE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -162,8 +160,8 @@ f() {}
|
|||
|
||||
// exactly 2 contexts
|
||||
expect(server.driverMap, hasLength(2));
|
||||
var driver1 = server.getAnalysisDriver(filePath1);
|
||||
var driver2 = server.getAnalysisDriver(filePath2);
|
||||
var driver1 = server.getAnalysisDriver(filePath1)!;
|
||||
var driver2 = server.getAnalysisDriver(filePath2)!;
|
||||
|
||||
// no sources
|
||||
expect(_getUserSources(driver1), isEmpty);
|
||||
|
@ -229,39 +227,38 @@ f() {}
|
|||
// Add
|
||||
//
|
||||
handleSuccessfulRequest(AnalysisUpdateContentParams(
|
||||
<String, dynamic>{filePath: AddContentOverlay(fileContent)})
|
||||
<String, Object>{filePath: AddContentOverlay(fileContent)})
|
||||
.toRequest('0'));
|
||||
var params = pluginManager.analysisUpdateContentParams;
|
||||
expect(params, isNotNull);
|
||||
var params = pluginManager.analysisUpdateContentParams!;
|
||||
var files = params.files;
|
||||
expect(files, hasLength(1));
|
||||
var overlay = files[filePath];
|
||||
expect(overlay, const TypeMatcher<AddContentOverlay>());
|
||||
AddContentOverlay addOverlay = overlay;
|
||||
var addOverlay = overlay as AddContentOverlay;
|
||||
expect(addOverlay.content, fileContent);
|
||||
//
|
||||
// Change
|
||||
//
|
||||
pluginManager.analysisUpdateContentParams = null;
|
||||
handleSuccessfulRequest(AnalysisUpdateContentParams(<String, dynamic>{
|
||||
handleSuccessfulRequest(AnalysisUpdateContentParams(<String, Object>{
|
||||
filePath: ChangeContentOverlay(
|
||||
<SourceEdit>[SourceEdit(8, 1, "'"), SourceEdit(18, 1, "'")])
|
||||
}).toRequest('1'));
|
||||
params = pluginManager.analysisUpdateContentParams;
|
||||
params = pluginManager.analysisUpdateContentParams!;
|
||||
expect(params, isNotNull);
|
||||
files = params.files;
|
||||
expect(files, hasLength(1));
|
||||
overlay = files[filePath];
|
||||
expect(overlay, const TypeMatcher<ChangeContentOverlay>());
|
||||
ChangeContentOverlay changeOverlay = overlay;
|
||||
var changeOverlay = overlay as ChangeContentOverlay;
|
||||
expect(changeOverlay.edits, hasLength(2));
|
||||
//
|
||||
// Remove
|
||||
//
|
||||
pluginManager.analysisUpdateContentParams = null;
|
||||
handleSuccessfulRequest(AnalysisUpdateContentParams(
|
||||
<String, dynamic>{filePath: RemoveContentOverlay()}).toRequest('2'));
|
||||
params = pluginManager.analysisUpdateContentParams;
|
||||
<String, Object>{filePath: RemoveContentOverlay()}).toRequest('2'));
|
||||
params = pluginManager.analysisUpdateContentParams!;
|
||||
expect(params, isNotNull);
|
||||
files = params.files;
|
||||
expect(files, hasLength(1));
|
||||
|
@ -269,13 +266,6 @@ f() {}
|
|||
expect(overlay, const TypeMatcher<RemoveContentOverlay>());
|
||||
}
|
||||
|
||||
// CompilationUnit _getTestUnit() {
|
||||
// ContextSourcePair pair = server.getContextSourcePair(testFile);
|
||||
// AnalysisContext context = pair.context;
|
||||
// Source source = pair.source;
|
||||
// return context.getResolvedCompilationUnit2(source, source);
|
||||
// }
|
||||
|
||||
List<String> _getUserSources(AnalysisDriver driver) {
|
||||
var sources = <String>[];
|
||||
driver.addedFiles.forEach((path) {
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:analysis_server/protocol/protocol.dart';
|
||||
import 'package:analysis_server/protocol/protocol_constants.dart';
|
||||
import 'package:analysis_server/protocol/protocol_generated.dart'
|
||||
|
@ -40,28 +38,29 @@ int findIdentifierLength(String search) {
|
|||
|
||||
/// An abstract base for all 'analysis' domain tests.
|
||||
class AbstractAnalysisTest with ResourceProviderMixin {
|
||||
MockServerChannel serverChannel;
|
||||
TestPluginManager pluginManager;
|
||||
AnalysisServer server;
|
||||
RequestHandler handler;
|
||||
late MockServerChannel serverChannel;
|
||||
late TestPluginManager pluginManager;
|
||||
late AnalysisServer server;
|
||||
late RequestHandler handler;
|
||||
|
||||
final List<GeneralAnalysisService> generalServices =
|
||||
<GeneralAnalysisService>[];
|
||||
final Map<AnalysisService, List<String>> analysisSubscriptions = {};
|
||||
|
||||
String projectPath;
|
||||
String testFolder;
|
||||
String testFile;
|
||||
String testCode;
|
||||
late String projectPath;
|
||||
late String testFolder;
|
||||
late String testFile;
|
||||
late String testCode;
|
||||
|
||||
AbstractAnalysisTest();
|
||||
|
||||
AnalysisDomainHandler get analysisHandler => server.handlers
|
||||
.singleWhere((handler) => handler is AnalysisDomainHandler);
|
||||
AnalysisDomainHandler get analysisHandler =>
|
||||
server.handlers.singleWhere((handler) => handler is AnalysisDomainHandler)
|
||||
as AnalysisDomainHandler;
|
||||
|
||||
AnalysisOptions get analysisOptions => testDiver.analysisOptions;
|
||||
|
||||
AnalysisDriver get testDiver => server.getAnalysisDriver(testFile);
|
||||
AnalysisDriver get testDiver => server.getAnalysisDriver(testFile)!;
|
||||
|
||||
void addAnalysisOptionsFile(String content) {
|
||||
newFile(
|
||||
|
@ -97,7 +96,7 @@ class AbstractAnalysisTest with ResourceProviderMixin {
|
|||
}
|
||||
|
||||
/// Create an analysis options file based on the given arguments.
|
||||
void createAnalysisOptionsFile({List<String> experiments}) {
|
||||
void createAnalysisOptionsFile({List<String>? experiments}) {
|
||||
var buffer = StringBuffer();
|
||||
if (experiments != null) {
|
||||
buffer.writeln('analyzer:');
|
||||
|
@ -128,14 +127,14 @@ class AbstractAnalysisTest with ResourceProviderMixin {
|
|||
}
|
||||
|
||||
/// Creates a project [projectPath].
|
||||
void createProject({Map<String, String> packageRoots}) {
|
||||
void createProject({Map<String, String>? packageRoots}) {
|
||||
newFolder(projectPath);
|
||||
setRoots(included: [projectPath], excluded: []);
|
||||
}
|
||||
|
||||
void doAllDeclarationsTrackerWork() {
|
||||
while (server.declarationsTracker.hasWork) {
|
||||
server.declarationsTracker.doWork();
|
||||
while (server.declarationsTracker!.hasWork) {
|
||||
server.declarationsTracker!.doWork();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -158,9 +157,9 @@ class AbstractAnalysisTest with ResourceProviderMixin {
|
|||
}
|
||||
|
||||
/// Validates that the given [request] is handled successfully.
|
||||
Response handleSuccessfulRequest(Request request, {RequestHandler handler}) {
|
||||
Response handleSuccessfulRequest(Request request, {RequestHandler? handler}) {
|
||||
handler ??= this.handler;
|
||||
var response = handler.handleRequest(request);
|
||||
var response = handler.handleRequest(request)!;
|
||||
expect(response, isResponseSuccess(request.id));
|
||||
return response;
|
||||
}
|
||||
|
@ -190,8 +189,8 @@ class AbstractAnalysisTest with ResourceProviderMixin {
|
|||
}
|
||||
|
||||
void setRoots({
|
||||
@required List<String> included,
|
||||
@required List<String> excluded,
|
||||
required List<String> included,
|
||||
required List<String> excluded,
|
||||
}) {
|
||||
var includedConverted = included.map(convertPath).toList();
|
||||
var excludedConverted = excluded.map(convertPath).toList();
|
||||
|
@ -221,9 +220,6 @@ class AbstractAnalysisTest with ResourceProviderMixin {
|
|||
@mustCallSuper
|
||||
void tearDown() {
|
||||
server.done();
|
||||
handler = null;
|
||||
server = null;
|
||||
serverChannel = null;
|
||||
}
|
||||
|
||||
/// Returns a [Future] that completes when the server's analysis is complete.
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:analysis_server/protocol/protocol.dart';
|
||||
import 'package:analysis_server/protocol/protocol_constants.dart';
|
||||
import 'package:analysis_server/protocol/protocol_generated.dart';
|
||||
|
@ -27,8 +25,8 @@ void main() {
|
|||
|
||||
@reflectiveTest
|
||||
class AnalysisServerTest with ResourceProviderMixin {
|
||||
MockServerChannel channel;
|
||||
AnalysisServer server;
|
||||
late MockServerChannel channel;
|
||||
late AnalysisServer server;
|
||||
|
||||
/// Test that having multiple analysis contexts analyze the same file doesn't
|
||||
/// cause that file to receive duplicate notifications when it's modified.
|
||||
|
@ -116,8 +114,9 @@ class A {}
|
|||
expect(notifications.any((Notification notification) {
|
||||
if (notification.event == SERVER_NOTIFICATION_STATUS) {
|
||||
var params = ServerStatusParams.fromNotification(notification);
|
||||
if (params.analysis != null) {
|
||||
return params.analysis.isAnalyzing;
|
||||
var analysis = params.analysis;
|
||||
if (analysis != null) {
|
||||
return analysis.isAnalyzing;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -126,7 +125,7 @@ class A {}
|
|||
// The last notification should indicate that analysis is complete.
|
||||
var notification = notifications[notifications.length - 1];
|
||||
var params = ServerStatusParams.fromNotification(notification);
|
||||
expect(params.analysis.isAnalyzing, isFalse);
|
||||
expect(params.analysis!.isAnalyzing, isFalse);
|
||||
}
|
||||
|
||||
Future test_serverStatusNotifications_noFiles() async {
|
||||
|
@ -145,8 +144,9 @@ class A {}
|
|||
expect(notifications.any((Notification notification) {
|
||||
if (notification.event == SERVER_NOTIFICATION_STATUS) {
|
||||
var params = ServerStatusParams.fromNotification(notification);
|
||||
if (params.analysis != null) {
|
||||
return params.analysis.isAnalyzing;
|
||||
var analysis = params.analysis;
|
||||
if (analysis != null) {
|
||||
return analysis.isAnalyzing;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -155,7 +155,7 @@ class A {}
|
|||
// The last notification should indicate that analysis is complete.
|
||||
var notification = notifications[notifications.length - 1];
|
||||
var params = ServerStatusParams.fromNotification(notification);
|
||||
expect(params.analysis.isAnalyzing, isFalse);
|
||||
expect(params.analysis!.isAnalyzing, isFalse);
|
||||
}
|
||||
|
||||
Future<void>
|
||||
|
@ -221,7 +221,7 @@ analyzer:
|
|||
|
||||
class EchoHandler implements RequestHandler {
|
||||
@override
|
||||
Response handleRequest(Request request) {
|
||||
Response? handleRequest(Request request) {
|
||||
if (request.method == 'echo') {
|
||||
return Response(request.id, result: {'echo': true});
|
||||
}
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:analysis_server/protocol/protocol.dart';
|
||||
import 'package:analysis_server/protocol/protocol_generated.dart'
|
||||
hide AnalysisOptions;
|
||||
|
@ -13,6 +11,7 @@ import 'package:analysis_server/src/domain_completion.dart';
|
|||
import 'package:analysis_server/src/server/crash_reporting_attachments.dart';
|
||||
import 'package:analysis_server/src/utilities/mocks.dart';
|
||||
import 'package:analyzer/file_system/file_system.dart';
|
||||
import 'package:analyzer/file_system/memory_file_system.dart';
|
||||
import 'package:analyzer/instrumentation/instrumentation.dart';
|
||||
import 'package:analyzer/src/dart/analysis/driver.dart';
|
||||
import 'package:analyzer/src/generated/engine.dart';
|
||||
|
@ -26,7 +25,7 @@ import '../../mocks.dart';
|
|||
abstract class AbstractClient {
|
||||
final MockServerChannel serverChannel;
|
||||
final TestPluginManager pluginManager;
|
||||
AnalysisServer server;
|
||||
late AnalysisServer server;
|
||||
|
||||
final List<GeneralAnalysisService> generalServices =
|
||||
<GeneralAnalysisService>[];
|
||||
|
@ -34,18 +33,18 @@ abstract class AbstractClient {
|
|||
|
||||
final String projectPath;
|
||||
final String testFilePath;
|
||||
String testCode;
|
||||
late String testCode;
|
||||
|
||||
MockSdk sdk;
|
||||
late MockSdk sdk;
|
||||
|
||||
final AnalysisServerOptions serverOptions;
|
||||
|
||||
AbstractClient({
|
||||
@required this.projectPath,
|
||||
@required this.testFilePath,
|
||||
@required String sdkPath,
|
||||
@required this.serverOptions,
|
||||
}) : serverChannel = MockServerChannel(),
|
||||
required this.projectPath,
|
||||
required this.testFilePath,
|
||||
required String sdkPath,
|
||||
required this.serverOptions,
|
||||
}) : serverChannel = MockServerChannel(),
|
||||
pluginManager = TestPluginManager() {
|
||||
server = createAnalysisServer(sdkPath);
|
||||
var notificationStream = serverChannel.notificationController.stream;
|
||||
|
@ -54,17 +53,18 @@ abstract class AbstractClient {
|
|||
});
|
||||
}
|
||||
|
||||
AnalysisDomainHandler get analysisHandler => server.handlers
|
||||
.singleWhere((handler) => handler is AnalysisDomainHandler);
|
||||
AnalysisDomainHandler get analysisHandler =>
|
||||
server.handlers.singleWhere((handler) => handler is AnalysisDomainHandler)
|
||||
as AnalysisDomainHandler;
|
||||
|
||||
AnalysisOptions get analysisOptions => testDriver.analysisOptions;
|
||||
|
||||
CompletionDomainHandler get completionHandler =>
|
||||
server.handlers.whereType<CompletionDomainHandler>().single;
|
||||
|
||||
ResourceProvider get resourceProvider;
|
||||
MemoryResourceProvider get resourceProvider;
|
||||
|
||||
AnalysisDriver get testDriver => server.getAnalysisDriver(testFilePath);
|
||||
AnalysisDriver get testDriver => server.getAnalysisDriver(testFilePath)!;
|
||||
|
||||
void addAnalysisOptionsFile(String content) {
|
||||
newFile(
|
||||
|
@ -118,7 +118,7 @@ abstract class AbstractClient {
|
|||
|
||||
/// Create a project at [projectPath].
|
||||
@mustCallSuper
|
||||
void createProject({Map<String, String> packageRoots}) {
|
||||
void createProject({Map<String, String>? packageRoots}) {
|
||||
newFolder(projectPath);
|
||||
var request = AnalysisSetAnalysisRootsParams([projectPath], [],
|
||||
packageRoots: packageRoots)
|
||||
|
@ -129,9 +129,9 @@ abstract class AbstractClient {
|
|||
void expect(actual, matcher, {String reason});
|
||||
|
||||
/// Validate that the given [request] is handled successfully.
|
||||
Response handleSuccessfulRequest(Request request, {RequestHandler handler}) {
|
||||
Response handleSuccessfulRequest(Request request, {RequestHandler? handler}) {
|
||||
handler ??= analysisHandler;
|
||||
var response = handler.handleRequest(request);
|
||||
var response = handler.handleRequest(request)!;
|
||||
expect(response, isResponseSuccess(request.id));
|
||||
return response;
|
||||
}
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:analysis_server/protocol/protocol.dart';
|
||||
|
@ -17,17 +15,17 @@ import 'analysis_abstract.dart';
|
|||
import 'constants.dart';
|
||||
|
||||
class AbstractCompletionDomainTest extends AbstractAnalysisTest {
|
||||
String completionId;
|
||||
int completionOffset;
|
||||
int replacementOffset;
|
||||
int replacementLength;
|
||||
late String completionId;
|
||||
late int completionOffset;
|
||||
late int replacementOffset;
|
||||
late int replacementLength;
|
||||
Map<String, Completer<void>> receivedSuggestionsCompleters = {};
|
||||
List<CompletionSuggestion> suggestions = [];
|
||||
bool suggestionsDone = false;
|
||||
Map<String, List<CompletionSuggestion>> allSuggestions = {};
|
||||
|
||||
@override
|
||||
String addTestFile(String content, {int offset}) {
|
||||
String addTestFile(String content, {int? offset}) {
|
||||
completionOffset = content.indexOf('^');
|
||||
if (offset != null) {
|
||||
expect(completionOffset, -1, reason: 'cannot supply offset and ^');
|
||||
|
@ -44,11 +42,11 @@ class AbstractCompletionDomainTest extends AbstractAnalysisTest {
|
|||
void assertHasResult(CompletionSuggestionKind kind, String completion,
|
||||
{bool isDeprecated = false,
|
||||
bool isPotential = false,
|
||||
int selectionOffset,
|
||||
int replacementOffset,
|
||||
int replacementLength,
|
||||
ElementKind elementKind}) {
|
||||
CompletionSuggestion cs;
|
||||
int? selectionOffset,
|
||||
int? replacementOffset,
|
||||
int? replacementLength,
|
||||
ElementKind? elementKind}) {
|
||||
CompletionSuggestion? cs;
|
||||
suggestions.forEach((s) {
|
||||
if (elementKind != null && s.element?.kind != elementKind) {
|
||||
return;
|
||||
|
@ -71,16 +69,17 @@ class AbstractCompletionDomainTest extends AbstractAnalysisTest {
|
|||
|
||||
fail('expected $expectationText, but found\n $completions');
|
||||
}
|
||||
expect(cs.kind, equals(kind));
|
||||
expect(cs.selectionOffset, selectionOffset ?? completion.length);
|
||||
expect(cs.selectionLength, equals(0));
|
||||
expect(cs.replacementOffset, equals(replacementOffset));
|
||||
expect(cs.replacementLength, equals(replacementLength));
|
||||
expect(cs.isDeprecated, equals(isDeprecated));
|
||||
expect(cs.isPotential, equals(isPotential));
|
||||
var suggestion = cs!;
|
||||
expect(suggestion.kind, equals(kind));
|
||||
expect(suggestion.selectionOffset, selectionOffset ?? completion.length);
|
||||
expect(suggestion.selectionLength, equals(0));
|
||||
expect(suggestion.replacementOffset, equals(replacementOffset));
|
||||
expect(suggestion.replacementLength, equals(replacementLength));
|
||||
expect(suggestion.isDeprecated, equals(isDeprecated));
|
||||
expect(suggestion.isPotential, equals(isPotential));
|
||||
}
|
||||
|
||||
void assertNoResult(String completion, {ElementKind elementKind}) {
|
||||
void assertNoResult(String completion, {ElementKind? elementKind}) {
|
||||
if (suggestions.any((cs) =>
|
||||
cs.completion == completion &&
|
||||
(elementKind == null || cs.element?.kind == elementKind))) {
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:analysis_server/protocol/protocol_generated.dart';
|
||||
import 'package:analysis_server/src/domain_diagnostic.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
@ -35,7 +33,7 @@ class DiagnosticDomainTest extends AbstractAnalysisTest {
|
|||
await server.onAnalysisComplete;
|
||||
|
||||
var request = DiagnosticGetDiagnosticsParams().toRequest('0');
|
||||
var response = handler.handleRequest(request);
|
||||
var response = handler.handleRequest(request)!;
|
||||
var result = DiagnosticGetDiagnosticsResult.fromResponse(response);
|
||||
|
||||
expect(result.contexts, hasLength(1));
|
||||
|
@ -51,7 +49,7 @@ class DiagnosticDomainTest extends AbstractAnalysisTest {
|
|||
|
||||
Future<void> test_getDiagnostics_noRoot() async {
|
||||
var request = DiagnosticGetDiagnosticsParams().toRequest('0');
|
||||
var response = handler.handleRequest(request);
|
||||
var response = handler.handleRequest(request)!;
|
||||
var result = DiagnosticGetDiagnosticsResult.fromResponse(response);
|
||||
expect(result.contexts, isEmpty);
|
||||
}
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:analysis_server/protocol/protocol.dart';
|
||||
import 'package:analysis_server/protocol/protocol_generated.dart';
|
||||
import 'package:analysis_server/src/edit/edit_dartfix.dart';
|
||||
|
@ -39,18 +37,19 @@ class EditDartfixDomainHandlerTest extends AbstractAnalysisTest {
|
|||
}
|
||||
|
||||
void expectSuggestion(DartFixSuggestion suggestion, String partialText,
|
||||
[int offset, int length]) {
|
||||
[int? offset, int? length]) {
|
||||
expect(suggestion.description, contains(partialText));
|
||||
if (offset == null) {
|
||||
expect(suggestion.location, isNull);
|
||||
} else {
|
||||
expect(suggestion.location.offset, offset);
|
||||
expect(suggestion.location.length, length);
|
||||
var location = suggestion.location!;
|
||||
expect(location.offset, offset);
|
||||
expect(location.length, length);
|
||||
}
|
||||
}
|
||||
|
||||
Future<EditDartfixResult> performFix(
|
||||
{List<String> includedFixes, bool pedantic}) async {
|
||||
{List<String>? includedFixes, bool? pedantic}) async {
|
||||
var response =
|
||||
await performFixRaw(includedFixes: includedFixes, pedantic: pedantic);
|
||||
expect(response.error, isNull);
|
||||
|
@ -58,9 +57,9 @@ class EditDartfixDomainHandlerTest extends AbstractAnalysisTest {
|
|||
}
|
||||
|
||||
Future<Response> performFixRaw(
|
||||
{List<String> includedFixes,
|
||||
List<String> excludedFixes,
|
||||
bool pedantic}) async {
|
||||
{List<String>? includedFixes,
|
||||
List<String>? excludedFixes,
|
||||
bool? pedantic}) async {
|
||||
final id = nextRequestId;
|
||||
final params = EditDartfixParams([projectPath]);
|
||||
params.includedFixes = includedFixes;
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:analysis_server/protocol/protocol_generated.dart';
|
||||
import 'package:analysis_server/src/analysis_server.dart';
|
||||
import 'package:analysis_server/src/domain_execution.dart';
|
||||
|
@ -25,8 +23,8 @@ void main() {
|
|||
});
|
||||
group('ExecutionDomainHandler', () {
|
||||
var provider = MemoryResourceProvider();
|
||||
AnalysisServer server;
|
||||
ExecutionDomainHandler handler;
|
||||
late AnalysisServer server;
|
||||
late ExecutionDomainHandler handler;
|
||||
|
||||
setUp(() {
|
||||
server = AnalysisServer(
|
||||
|
@ -42,13 +40,13 @@ void main() {
|
|||
group('createContext/deleteContext', () {
|
||||
test('create/delete multiple contexts', () {
|
||||
var request = ExecutionCreateContextParams('/a/b.dart').toRequest('0');
|
||||
var response = handler.handleRequest(request);
|
||||
var response = handler.handleRequest(request)!;
|
||||
expect(response, isResponseSuccess('0'));
|
||||
var result = ExecutionCreateContextResult.fromResponse(response);
|
||||
var id0 = result.id;
|
||||
|
||||
request = ExecutionCreateContextParams('/c/d.dart').toRequest('1');
|
||||
response = handler.handleRequest(request);
|
||||
response = handler.handleRequest(request)!;
|
||||
expect(response, isResponseSuccess('1'));
|
||||
result = ExecutionCreateContextResult.fromResponse(response);
|
||||
var id1 = result.id;
|
||||
|
@ -56,11 +54,11 @@ void main() {
|
|||
expect(id0 == id1, isFalse);
|
||||
|
||||
request = ExecutionDeleteContextParams(id0).toRequest('2');
|
||||
response = handler.handleRequest(request);
|
||||
response = handler.handleRequest(request)!;
|
||||
expect(response, isResponseSuccess('2'));
|
||||
|
||||
request = ExecutionDeleteContextParams(id1).toRequest('3');
|
||||
response = handler.handleRequest(request);
|
||||
response = handler.handleRequest(request)!;
|
||||
expect(response, isResponseSuccess('3'));
|
||||
});
|
||||
|
||||
|
@ -161,7 +159,7 @@ void main() {
|
|||
|
||||
@reflectiveTest
|
||||
class ExecutionDomainTest extends AbstractAnalysisTest {
|
||||
String contextId;
|
||||
late String contextId;
|
||||
|
||||
@override
|
||||
void setUp() {
|
||||
|
@ -239,7 +237,7 @@ void contextFunction() {
|
|||
|
||||
void _createExecutionContext(String path) {
|
||||
var request = ExecutionCreateContextParams(path).toRequest('0');
|
||||
var response = handler.handleRequest(request);
|
||||
var response = handler.handleRequest(request)!;
|
||||
expect(response, isResponseSuccess('0'));
|
||||
var result = ExecutionCreateContextResult.fromResponse(response);
|
||||
contextId = result.id;
|
||||
|
@ -251,10 +249,10 @@ void contextFunction() {
|
|||
expect(response, isResponseSuccess('1'));
|
||||
}
|
||||
|
||||
ExecutionMapUriResult _mapUri({String file, String uri}) {
|
||||
ExecutionMapUriResult _mapUri({String? file, String? uri}) {
|
||||
var request =
|
||||
ExecutionMapUriParams(contextId, file: file, uri: uri).toRequest('2');
|
||||
var response = handler.handleRequest(request);
|
||||
var response = handler.handleRequest(request)!;
|
||||
expect(response, isResponseSuccess('2'));
|
||||
return ExecutionMapUriResult.fromResponse(response);
|
||||
}
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:analysis_server/protocol/protocol.dart';
|
||||
import 'package:analysis_server/protocol/protocol_constants.dart';
|
||||
import 'package:analysis_server/protocol/protocol_generated.dart';
|
||||
|
@ -20,9 +18,9 @@ import 'constants.dart';
|
|||
import 'mocks.dart';
|
||||
|
||||
void main() {
|
||||
AnalysisServer server;
|
||||
ServerDomainHandler handler;
|
||||
MockServerChannel serverChannel;
|
||||
late AnalysisServer server;
|
||||
late ServerDomainHandler handler;
|
||||
late MockServerChannel serverChannel;
|
||||
|
||||
setUp(() {
|
||||
serverChannel = MockServerChannel();
|
||||
|
@ -40,7 +38,7 @@ void main() {
|
|||
group('ServerDomainHandler', () {
|
||||
test('getVersion', () {
|
||||
var request = ServerGetVersionParams().toRequest('0');
|
||||
var response = handler.handleRequest(request);
|
||||
var response = handler.handleRequest(request)!;
|
||||
expect(
|
||||
response.toJson(),
|
||||
equals({
|
||||
|
|
|
@ -2,11 +2,10 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:analysis_server/protocol/protocol_generated.dart';
|
||||
import 'package:analysis_server/src/edit/edit_domain.dart';
|
||||
import 'package:analysis_server/src/plugin/plugin_manager.dart';
|
||||
import 'package:analyzer/instrumentation/service.dart';
|
||||
import 'package:analyzer_plugin/protocol/protocol.dart' as plugin;
|
||||
import 'package:analyzer_plugin/protocol/protocol_common.dart';
|
||||
import 'package:analyzer_plugin/protocol/protocol_generated.dart' as plugin;
|
||||
|
@ -15,6 +14,7 @@ import 'package:test_reflective_loader/test_reflective_loader.dart';
|
|||
|
||||
import '../analysis_abstract.dart';
|
||||
import '../mocks.dart';
|
||||
import '../src/plugin/plugin_manager_test.dart';
|
||||
|
||||
void main() {
|
||||
defineReflectiveSuite(() {
|
||||
|
@ -68,7 +68,8 @@ main() {
|
|||
}
|
||||
|
||||
Future<void> test_fromPlugins() async {
|
||||
PluginInfo info = DiscoveredPluginInfo('a', 'b', 'c', null, null);
|
||||
PluginInfo info = DiscoveredPluginInfo('a', 'b', 'c',
|
||||
TestNotificationManager(), InstrumentationService.NULL_SERVICE);
|
||||
var fixes = plugin.AnalysisErrorFixes(AnalysisError(
|
||||
AnalysisErrorSeverity.ERROR,
|
||||
AnalysisErrorType.HINT,
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:analysis_server/protocol/protocol.dart';
|
||||
import 'package:analysis_server/protocol/protocol_generated.dart';
|
||||
import 'package:analysis_server/src/edit/edit_domain.dart';
|
||||
|
@ -22,7 +20,7 @@ void main() {
|
|||
|
||||
@reflectiveTest
|
||||
class PostfixCompletionTest extends AbstractAnalysisTest {
|
||||
SourceChange change;
|
||||
late SourceChange change;
|
||||
|
||||
@override
|
||||
void setUp() {
|
||||
|
@ -69,7 +67,7 @@ main() {
|
|||
);
|
||||
}
|
||||
|
||||
void _assertHasChange(String message, String expectedCode, [Function cmp]) {
|
||||
void _assertHasChange(String message, String expectedCode, [Function? cmp]) {
|
||||
if (change.message == message) {
|
||||
if (change.edits.isNotEmpty) {
|
||||
var resultCode =
|
||||
|
@ -77,12 +75,12 @@ main() {
|
|||
expect(resultCode, expectedCode.replaceAll('/*caret*/', ''));
|
||||
if (cmp != null) {
|
||||
int offset = cmp(resultCode);
|
||||
expect(change.selection.offset, offset);
|
||||
expect(change.selection!.offset, offset);
|
||||
}
|
||||
} else {
|
||||
if (cmp != null) {
|
||||
int offset = cmp(testCode);
|
||||
expect(change.selection.offset, offset);
|
||||
expect(change.selection!.offset, offset);
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:analysis_server/protocol/protocol.dart';
|
||||
import 'package:analysis_server/protocol/protocol_constants.dart';
|
||||
import 'package:analysis_server/protocol/protocol_generated.dart';
|
||||
|
@ -15,17 +13,17 @@ import '../analysis_abstract.dart';
|
|||
|
||||
class AbstractSearchDomainTest extends AbstractAnalysisTest {
|
||||
final Map<String, _ResultSet> resultSets = {};
|
||||
String searchId;
|
||||
late String searchId;
|
||||
List<SearchResult> results = <SearchResult>[];
|
||||
SearchResult result;
|
||||
late SearchResult result;
|
||||
|
||||
void assertHasResult(SearchResultKind kind, String search, [int length]) {
|
||||
void assertHasResult(SearchResultKind kind, String search, [int? length]) {
|
||||
var offset = findOffset(search);
|
||||
length ??= findIdentifierLength(search);
|
||||
findResult(kind, testFile, offset, length, true);
|
||||
}
|
||||
|
||||
void assertNoResult(SearchResultKind kind, String search, [int length]) {
|
||||
void assertNoResult(SearchResultKind kind, String search, [int? length]) {
|
||||
var offset = findOffset(search);
|
||||
length ??= findIdentifierLength(search);
|
||||
findResult(kind, testFile, offset, length, false);
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:analysis_server/protocol/protocol.dart';
|
||||
import 'package:analysis_server/protocol/protocol_generated.dart';
|
||||
import 'package:analysis_server/src/search/search_domain.dart';
|
||||
|
@ -36,7 +34,7 @@ class GetTypeHierarchyTest extends AbstractAnalysisTest {
|
|||
main() {
|
||||
}
|
||||
''');
|
||||
var items = await _getTypeHierarchy('main() {');
|
||||
var items = await _getTypeHierarchyOrNull('main() {');
|
||||
expect(items, isNull);
|
||||
}
|
||||
|
||||
|
@ -46,7 +44,7 @@ main() {
|
|||
/* target */
|
||||
}
|
||||
''');
|
||||
var items = await _getTypeHierarchy('/* target */');
|
||||
var items = await _getTypeHierarchyOrNull('/* target */');
|
||||
expect(items, isNull);
|
||||
}
|
||||
|
||||
|
@ -95,7 +93,7 @@ class B extends A<int> {
|
|||
''');
|
||||
var items = await _getTypeHierarchy('B extends');
|
||||
var itemB = items[0];
|
||||
var itemA = items[itemB.superclass];
|
||||
var itemA = items[itemB.superclass!];
|
||||
expect(itemA.classElement.name, 'A');
|
||||
expect(itemB.classElement.name, 'B');
|
||||
expect(itemA.displayName, 'A<int>');
|
||||
|
@ -507,12 +505,10 @@ class B extends A with Mixin {}
|
|||
var items = await _getTypeHierarchy('test = 1;');
|
||||
var itemA = items.firstWhere((e) => e.classElement.name == 'A');
|
||||
var itemB = items.firstWhere((e) => e.classElement.name == 'B');
|
||||
var memberA = itemA.memberElement;
|
||||
var memberB = itemB.memberElement;
|
||||
expect(memberA, isNotNull);
|
||||
expect(memberB, isNotNull);
|
||||
expect(memberA.location.offset, findOffset('test = 1;'));
|
||||
expect(memberB.location.offset, findOffset('test => 2;'));
|
||||
var memberA = itemA.memberElement!;
|
||||
var memberB = itemB.memberElement!;
|
||||
expect(memberA.location!.offset, findOffset('test = 1;'));
|
||||
expect(memberB.location!.offset, findOffset('test => 2;'));
|
||||
}
|
||||
|
||||
Future<void> test_fromField_toMixinSetter() async {
|
||||
|
@ -528,12 +524,10 @@ class B extends A with Mixin {}
|
|||
var items = await _getTypeHierarchy('test = 1;');
|
||||
var itemA = items.firstWhere((e) => e.classElement.name == 'A');
|
||||
var itemB = items.firstWhere((e) => e.classElement.name == 'B');
|
||||
var memberA = itemA.memberElement;
|
||||
var memberB = itemB.memberElement;
|
||||
expect(memberA, isNotNull);
|
||||
expect(memberB, isNotNull);
|
||||
expect(memberA.location.offset, findOffset('test = 1;'));
|
||||
expect(memberB.location.offset, findOffset('test(m) {}'));
|
||||
var memberA = itemA.memberElement!;
|
||||
var memberB = itemB.memberElement!;
|
||||
expect(memberA.location!.offset, findOffset('test = 1;'));
|
||||
expect(memberB.location!.offset, findOffset('test(m) {}'));
|
||||
}
|
||||
|
||||
Future<void> test_member_fromField_toField() async {
|
||||
|
@ -547,11 +541,11 @@ class B extends A {
|
|||
''');
|
||||
var items = await _getTypeHierarchy('test = 2;');
|
||||
var itemB = items[0];
|
||||
var itemA = items[itemB.superclass];
|
||||
var itemA = items[itemB.superclass!];
|
||||
expect(itemA.classElement.name, 'A');
|
||||
expect(itemB.classElement.name, 'B');
|
||||
expect(itemA.memberElement.location.offset, findOffset('test = 1;'));
|
||||
expect(itemB.memberElement.location.offset, findOffset('test = 2;'));
|
||||
expect(itemA.memberElement!.location!.offset, findOffset('test = 1;'));
|
||||
expect(itemB.memberElement!.location!.offset, findOffset('test = 2;'));
|
||||
}
|
||||
|
||||
Future<void> test_member_fromField_toGetter() async {
|
||||
|
@ -565,11 +559,11 @@ class B extends A {
|
|||
''');
|
||||
var items = await _getTypeHierarchy('test = 2;');
|
||||
var itemB = items[0];
|
||||
var itemA = items[itemB.superclass];
|
||||
var itemA = items[itemB.superclass!];
|
||||
expect(itemA.classElement.name, 'A');
|
||||
expect(itemB.classElement.name, 'B');
|
||||
expect(itemA.memberElement.location.offset, findOffset('test => 1'));
|
||||
expect(itemB.memberElement.location.offset, findOffset('test = 2;'));
|
||||
expect(itemA.memberElement!.location!.offset, findOffset('test => 1'));
|
||||
expect(itemB.memberElement!.location!.offset, findOffset('test = 2;'));
|
||||
}
|
||||
|
||||
Future<void> test_member_fromField_toSetter() async {
|
||||
|
@ -583,11 +577,11 @@ class B extends A {
|
|||
''');
|
||||
var items = await _getTypeHierarchy('test = 2;');
|
||||
var itemB = items[0];
|
||||
var itemA = items[itemB.superclass];
|
||||
var itemA = items[itemB.superclass!];
|
||||
expect(itemA.classElement.name, 'A');
|
||||
expect(itemB.classElement.name, 'B');
|
||||
expect(itemA.memberElement.location.offset, findOffset('test(a) {}'));
|
||||
expect(itemB.memberElement.location.offset, findOffset('test = 2;'));
|
||||
expect(itemA.memberElement!.location!.offset, findOffset('test(a) {}'));
|
||||
expect(itemB.memberElement!.location!.offset, findOffset('test = 2;'));
|
||||
}
|
||||
|
||||
Future<void> test_member_fromFinalField_toGetter() async {
|
||||
|
@ -601,11 +595,11 @@ class B extends A {
|
|||
''');
|
||||
var items = await _getTypeHierarchy('test = 2;');
|
||||
var itemB = items[0];
|
||||
var itemA = items[itemB.superclass];
|
||||
var itemA = items[itemB.superclass!];
|
||||
expect(itemA.classElement.name, 'A');
|
||||
expect(itemB.classElement.name, 'B');
|
||||
expect(itemA.memberElement.location.offset, findOffset('test => 1;'));
|
||||
expect(itemB.memberElement.location.offset, findOffset('test = 2;'));
|
||||
expect(itemA.memberElement!.location!.offset, findOffset('test => 1;'));
|
||||
expect(itemB.memberElement!.location!.offset, findOffset('test = 2;'));
|
||||
}
|
||||
|
||||
Future<void> test_member_fromFinalField_toSetter() async {
|
||||
|
@ -619,11 +613,11 @@ class B extends A {
|
|||
''');
|
||||
var items = await _getTypeHierarchy('test = 2;');
|
||||
var itemB = items[0];
|
||||
var itemA = items[itemB.superclass];
|
||||
var itemA = items[itemB.superclass!];
|
||||
expect(itemA.classElement.name, 'A');
|
||||
expect(itemB.classElement.name, 'B');
|
||||
expect(itemA.memberElement, isNull);
|
||||
expect(itemB.memberElement.location.offset, findOffset('test = 2;'));
|
||||
expect(itemB.memberElement!.location!.offset, findOffset('test = 2;'));
|
||||
}
|
||||
|
||||
Future<void> test_member_getter() async {
|
||||
|
@ -642,19 +636,19 @@ class D extends C {
|
|||
''');
|
||||
var items = await _getTypeHierarchy('test => null; // in B');
|
||||
var itemB = items[0];
|
||||
var itemA = items[itemB.superclass];
|
||||
var itemA = items[itemB.superclass!];
|
||||
var itemC = items[itemB.subclasses[0]];
|
||||
var itemD = items[itemC.subclasses[0]];
|
||||
expect(itemA.classElement.name, 'A');
|
||||
expect(itemB.classElement.name, 'B');
|
||||
expect(itemC.classElement.name, 'C');
|
||||
expect(itemD.classElement.name, 'D');
|
||||
expect(itemA.memberElement.location.offset,
|
||||
expect(itemA.memberElement!.location!.offset,
|
||||
findOffset('test => null; // in A'));
|
||||
expect(itemB.memberElement.location.offset,
|
||||
expect(itemB.memberElement!.location!.offset,
|
||||
findOffset('test => null; // in B'));
|
||||
expect(itemC.memberElement, isNull);
|
||||
expect(itemD.memberElement.location.offset,
|
||||
expect(itemD.memberElement!.location!.offset,
|
||||
findOffset('test => null; // in D'));
|
||||
}
|
||||
|
||||
|
@ -674,7 +668,7 @@ class D extends C {
|
|||
''');
|
||||
var items = await _getTypeHierarchy('test() {} // in B');
|
||||
var itemB = items[0];
|
||||
var itemA = items[itemB.superclass];
|
||||
var itemA = items[itemB.superclass!];
|
||||
var itemC = items[itemB.subclasses[0]];
|
||||
var itemD = items[itemC.subclasses[0]];
|
||||
expect(itemA.classElement.name, 'A');
|
||||
|
@ -682,12 +676,12 @@ class D extends C {
|
|||
expect(itemC.classElement.name, 'C');
|
||||
expect(itemD.classElement.name, 'D');
|
||||
expect(
|
||||
itemA.memberElement.location.offset, findOffset('test() {} // in A'));
|
||||
itemA.memberElement!.location!.offset, findOffset('test() {} // in A'));
|
||||
expect(
|
||||
itemB.memberElement.location.offset, findOffset('test() {} // in B'));
|
||||
itemB.memberElement!.location!.offset, findOffset('test() {} // in B'));
|
||||
expect(itemC.memberElement, isNull);
|
||||
expect(
|
||||
itemD.memberElement.location.offset, findOffset('test() {} // in D'));
|
||||
itemD.memberElement!.location!.offset, findOffset('test() {} // in D'));
|
||||
}
|
||||
|
||||
Future<void> test_member_method_private_differentLib() async {
|
||||
|
@ -711,7 +705,7 @@ class D extends C {
|
|||
''');
|
||||
var items = await _getTypeHierarchy('_m() {} // in B');
|
||||
var itemB = items[0];
|
||||
var itemA = items[itemB.superclass];
|
||||
var itemA = items[itemB.superclass!];
|
||||
var itemC = items[itemB.subclasses[0]];
|
||||
var itemD = items[itemC.subclasses[0]];
|
||||
expect(itemB.classElement.name, 'B');
|
||||
|
@ -738,14 +732,17 @@ class C extends B {
|
|||
''');
|
||||
var items = await _getTypeHierarchy('_m() {} // in B');
|
||||
var itemB = items[0];
|
||||
var itemA = items[itemB.superclass];
|
||||
var itemA = items[itemB.superclass!];
|
||||
var itemC = items[itemB.subclasses[0]];
|
||||
expect(itemA.classElement.name, 'A');
|
||||
expect(itemB.classElement.name, 'B');
|
||||
expect(itemC.classElement.name, 'C');
|
||||
expect(itemA.memberElement.location.offset, findOffset('_m() {} // in A'));
|
||||
expect(itemB.memberElement.location.offset, findOffset('_m() {} // in B'));
|
||||
expect(itemC.memberElement.location.offset, findOffset('_m() {} // in C'));
|
||||
expect(
|
||||
itemA.memberElement!.location!.offset, findOffset('_m() {} // in A'));
|
||||
expect(
|
||||
itemB.memberElement!.location!.offset, findOffset('_m() {} // in B'));
|
||||
expect(
|
||||
itemC.memberElement!.location!.offset, findOffset('_m() {} // in C'));
|
||||
}
|
||||
|
||||
Future<void> test_member_ofMixin2_method() async {
|
||||
|
@ -781,9 +778,8 @@ class D4 extends Object with M2, M1 {
|
|||
}
|
||||
// D2 mixes-in M2 last, which overrides
|
||||
{
|
||||
var member2 = item2.memberElement;
|
||||
expect(member2, isNotNull);
|
||||
expect(member2.location.offset, findOffset('test() {} // in M2'));
|
||||
var member2 = item2.memberElement!;
|
||||
expect(member2.location!.offset, findOffset('test() {} // in M2'));
|
||||
}
|
||||
// D3 mixes-in M1 last and does not override itself
|
||||
{
|
||||
|
@ -792,8 +788,8 @@ class D4 extends Object with M2, M1 {
|
|||
}
|
||||
// D4 mixes-in M1 last, but it also overrides
|
||||
{
|
||||
var member4 = item4.memberElement;
|
||||
expect(member4.location.offset, findOffset('test() {} // in D4'));
|
||||
var member4 = item4.memberElement!;
|
||||
expect(member4.location!.offset, findOffset('test() {} // in D4'));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -814,15 +810,13 @@ class Derived2 extends Base {
|
|||
var itemBase = items.firstWhere((e) => e.classElement.name == 'Base');
|
||||
var item1 = items.firstWhere((e) => e.classElement.name == 'Derived1');
|
||||
var item2 = items.firstWhere((e) => e.classElement.name == 'Derived2');
|
||||
var memberBase = itemBase.memberElement;
|
||||
var member1 = item1.memberElement;
|
||||
var member2 = item2.memberElement;
|
||||
expect(memberBase, isNotNull);
|
||||
expect(member1, isNotNull);
|
||||
expect(member2, isNotNull);
|
||||
expect(memberBase.location.offset, findOffset('test; // in Base'));
|
||||
expect(member1.location.offset, findOffset('test => null; // in Mixin'));
|
||||
expect(member2.location.offset, findOffset('test => null; // in Derived2'));
|
||||
var memberBase = itemBase.memberElement!;
|
||||
var member1 = item1.memberElement!;
|
||||
var member2 = item2.memberElement!;
|
||||
expect(memberBase.location!.offset, findOffset('test; // in Base'));
|
||||
expect(member1.location!.offset, findOffset('test => null; // in Mixin'));
|
||||
expect(
|
||||
member2.location!.offset, findOffset('test => null; // in Derived2'));
|
||||
}
|
||||
|
||||
Future<void> test_member_ofMixin_method() async {
|
||||
|
@ -842,15 +836,12 @@ class Derived2 extends Base {
|
|||
var itemBase = items.firstWhere((e) => e.classElement.name == 'Base');
|
||||
var item1 = items.firstWhere((e) => e.classElement.name == 'Derived1');
|
||||
var item2 = items.firstWhere((e) => e.classElement.name == 'Derived2');
|
||||
var memberBase = itemBase.memberElement;
|
||||
var member1 = item1.memberElement;
|
||||
var member2 = item2.memberElement;
|
||||
expect(memberBase, isNotNull);
|
||||
expect(member1, isNotNull);
|
||||
expect(member2, isNotNull);
|
||||
expect(memberBase.location.offset, findOffset('test(); // in Base'));
|
||||
expect(member1.location.offset, findOffset('test() {} // in Mixin'));
|
||||
expect(member2.location.offset, findOffset('test() {} // in Derived2'));
|
||||
var memberBase = itemBase.memberElement!;
|
||||
var member1 = item1.memberElement!;
|
||||
var member2 = item2.memberElement!;
|
||||
expect(memberBase.location!.offset, findOffset('test(); // in Base'));
|
||||
expect(member1.location!.offset, findOffset('test() {} // in Mixin'));
|
||||
expect(member2.location!.offset, findOffset('test() {} // in Derived2'));
|
||||
}
|
||||
|
||||
Future<void> test_member_ofMixin_setter() async {
|
||||
|
@ -870,15 +861,12 @@ class Derived2 extends Base {
|
|||
var itemBase = items.firstWhere((e) => e.classElement.name == 'Base');
|
||||
var item1 = items.firstWhere((e) => e.classElement.name == 'Derived1');
|
||||
var item2 = items.firstWhere((e) => e.classElement.name == 'Derived2');
|
||||
var memberBase = itemBase.memberElement;
|
||||
var member1 = item1.memberElement;
|
||||
var member2 = item2.memberElement;
|
||||
expect(memberBase, isNotNull);
|
||||
expect(member1, isNotNull);
|
||||
expect(member2, isNotNull);
|
||||
expect(memberBase.location.offset, findOffset('test(x); // in Base'));
|
||||
expect(member1.location.offset, findOffset('test(x) {} // in Mixin'));
|
||||
expect(member2.location.offset, findOffset('test(x) {} // in Derived2'));
|
||||
var memberBase = itemBase.memberElement!;
|
||||
var member1 = item1.memberElement!;
|
||||
var member2 = item2.memberElement!;
|
||||
expect(memberBase.location!.offset, findOffset('test(x); // in Base'));
|
||||
expect(member1.location!.offset, findOffset('test(x) {} // in Mixin'));
|
||||
expect(member2.location!.offset, findOffset('test(x) {} // in Derived2'));
|
||||
}
|
||||
|
||||
Future<void> test_member_ofSuperclassConstraint_getter() async {
|
||||
|
@ -954,19 +942,19 @@ class D extends C {
|
|||
''');
|
||||
var items = await _getTypeHierarchy('==(x) => null; // in B');
|
||||
var itemB = items[0];
|
||||
var itemA = items[itemB.superclass];
|
||||
var itemA = items[itemB.superclass!];
|
||||
var itemC = items[itemB.subclasses[0]];
|
||||
var itemD = items[itemC.subclasses[0]];
|
||||
expect(itemA.classElement.name, 'A');
|
||||
expect(itemB.classElement.name, 'B');
|
||||
expect(itemC.classElement.name, 'C');
|
||||
expect(itemD.classElement.name, 'D');
|
||||
expect(itemA.memberElement.location.offset,
|
||||
expect(itemA.memberElement!.location!.offset,
|
||||
findOffset('==(x) => null; // in A'));
|
||||
expect(itemB.memberElement.location.offset,
|
||||
expect(itemB.memberElement!.location!.offset,
|
||||
findOffset('==(x) => null; // in B'));
|
||||
expect(itemC.memberElement, isNull);
|
||||
expect(itemD.memberElement.location.offset,
|
||||
expect(itemD.memberElement!.location!.offset,
|
||||
findOffset('==(x) => null; // in D'));
|
||||
}
|
||||
|
||||
|
@ -986,20 +974,20 @@ class D extends C {
|
|||
''');
|
||||
var items = await _getTypeHierarchy('test(x) {} // in B');
|
||||
var itemB = items[0];
|
||||
var itemA = items[itemB.superclass];
|
||||
var itemA = items[itemB.superclass!];
|
||||
var itemC = items[itemB.subclasses[0]];
|
||||
var itemD = items[itemC.subclasses[0]];
|
||||
expect(itemA.classElement.name, 'A');
|
||||
expect(itemB.classElement.name, 'B');
|
||||
expect(itemC.classElement.name, 'C');
|
||||
expect(itemD.classElement.name, 'D');
|
||||
expect(
|
||||
itemA.memberElement.location.offset, findOffset('test(x) {} // in A'));
|
||||
expect(
|
||||
itemB.memberElement.location.offset, findOffset('test(x) {} // in B'));
|
||||
expect(itemA.memberElement!.location!.offset,
|
||||
findOffset('test(x) {} // in A'));
|
||||
expect(itemB.memberElement!.location!.offset,
|
||||
findOffset('test(x) {} // in B'));
|
||||
expect(itemC.memberElement, isNull);
|
||||
expect(
|
||||
itemD.memberElement.location.offset, findOffset('test(x) {} // in D'));
|
||||
expect(itemD.memberElement!.location!.offset,
|
||||
findOffset('test(x) {} // in D'));
|
||||
}
|
||||
|
||||
Future<void> test_superOnly() async {
|
||||
|
@ -1073,17 +1061,22 @@ class D extends C {}
|
|||
}
|
||||
|
||||
void _assertMember(TypeHierarchyItem item, String search) {
|
||||
expect(item.memberElement.location.offset, findOffset(search));
|
||||
expect(item.memberElement!.location!.offset, findOffset(search));
|
||||
}
|
||||
|
||||
Request _createGetTypeHierarchyRequest(String search, {bool superOnly}) {
|
||||
Request _createGetTypeHierarchyRequest(String search, {bool? superOnly}) {
|
||||
return SearchGetTypeHierarchyParams(testFile, findOffset(search),
|
||||
superOnly: superOnly)
|
||||
.toRequest(requestId);
|
||||
}
|
||||
|
||||
Future<List<TypeHierarchyItem>> _getTypeHierarchy(String search,
|
||||
{bool superOnly}) async {
|
||||
{bool? superOnly}) async {
|
||||
return (await _getTypeHierarchyOrNull(search, superOnly: superOnly))!;
|
||||
}
|
||||
|
||||
Future<List<TypeHierarchyItem>?> _getTypeHierarchyOrNull(String search,
|
||||
{bool? superOnly}) async {
|
||||
await waitForTasksFinished();
|
||||
var request = _createGetTypeHierarchyRequest(search, superOnly: superOnly);
|
||||
var response = await serverChannel.sendRequest(request);
|
||||
|
|
Loading…
Reference in a new issue