mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
Migrate remaining unblocked tests
Change-Id: I30e3c22db7df6e78be88125f20eea2dce054f446 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195860 Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
parent
5dd02f0583
commit
54fc28ec25
|
@ -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';
|
||||
|
@ -94,9 +92,10 @@ class Bar {
|
|||
var request = _createGetNavigationRequest(file, 0, 100);
|
||||
var response = await serverChannel.sendRequest(request);
|
||||
expect(response.error, isNull);
|
||||
expect(response.result['files'], isEmpty);
|
||||
expect(response.result['targets'], isEmpty);
|
||||
expect(response.result['regions'], isEmpty);
|
||||
var result = response.result!;
|
||||
expect(result['files'], isEmpty);
|
||||
expect(result['targets'], isEmpty);
|
||||
expect(result['regions'], isEmpty);
|
||||
}
|
||||
|
||||
Future<void> test_fileOutsideOfRoot() 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:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import 'get_errors_test.dart' as get_errors;
|
||||
|
|
|
@ -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/analysis_server.dart';
|
||||
import 'package:analysis_server/src/services/completion/dart/utilities.dart';
|
||||
import 'package:analyzer/src/test_utilities/resource_provider_mixin.dart';
|
||||
|
@ -23,9 +21,9 @@ void main() {
|
|||
}
|
||||
|
||||
abstract class AbstractCompletionDriverTest with ResourceProviderMixin {
|
||||
CompletionDriver driver;
|
||||
Map<String, String> packageRoots;
|
||||
List<CompletionSuggestion> suggestions;
|
||||
late CompletionDriver driver;
|
||||
Map<String, String> packageRoots = {};
|
||||
late List<CompletionSuggestion> suggestions;
|
||||
|
||||
String get projectName => 'project';
|
||||
|
||||
|
@ -47,7 +45,7 @@ abstract class AbstractCompletionDriverTest with ResourceProviderMixin {
|
|||
}
|
||||
|
||||
Future<List<CompletionSuggestion>> addTestFile(String content,
|
||||
{int offset}) async {
|
||||
{int? offset}) async {
|
||||
driver.addTestFile(content, offset: offset);
|
||||
await getSuggestions();
|
||||
// For sanity, ensure that there are no errors recorded for project files
|
||||
|
@ -57,10 +55,10 @@ abstract class AbstractCompletionDriverTest with ResourceProviderMixin {
|
|||
}
|
||||
|
||||
void assertNoSuggestion({
|
||||
@required String completion,
|
||||
ElementKind element,
|
||||
CompletionSuggestionKind kind,
|
||||
String file,
|
||||
required String completion,
|
||||
ElementKind? element,
|
||||
CompletionSuggestionKind? kind,
|
||||
String? file,
|
||||
}) {
|
||||
expect(
|
||||
suggestionsWith(
|
||||
|
@ -73,10 +71,10 @@ abstract class AbstractCompletionDriverTest with ResourceProviderMixin {
|
|||
}
|
||||
|
||||
void assertSuggestion({
|
||||
@required String completion,
|
||||
ElementKind element,
|
||||
CompletionSuggestionKind kind,
|
||||
String file,
|
||||
required String completion,
|
||||
ElementKind? element,
|
||||
CompletionSuggestionKind? kind,
|
||||
String? file,
|
||||
}) {
|
||||
expect(
|
||||
suggestionWith(
|
||||
|
@ -89,10 +87,10 @@ abstract class AbstractCompletionDriverTest with ResourceProviderMixin {
|
|||
}
|
||||
|
||||
void assertSuggestions({
|
||||
@required String completion,
|
||||
ElementKind element,
|
||||
CompletionSuggestionKind kind,
|
||||
String file,
|
||||
required String completion,
|
||||
ElementKind? element,
|
||||
CompletionSuggestionKind? kind,
|
||||
String? file,
|
||||
}) {
|
||||
expect(
|
||||
suggestionWith(
|
||||
|
@ -129,7 +127,7 @@ abstract class AbstractCompletionDriverTest with ResourceProviderMixin {
|
|||
suggestions.sort(completionComparator);
|
||||
for (var s in suggestions) {
|
||||
print(
|
||||
'[${s.relevance}] ${s.completion} • ${s.element?.kind?.name ?? ""} ${s.kind.name} ${s.element?.location?.file ?? ""}');
|
||||
'[${s.relevance}] ${s.completion} • ${s.element?.kind.name ?? ""} ${s.kind.name} ${s.element?.location?.file ?? ""}');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -152,10 +150,10 @@ project:${toUri('$projectPath/lib')}
|
|||
}
|
||||
|
||||
SuggestionMatcher suggestionHas({
|
||||
@required String completion,
|
||||
ElementKind element,
|
||||
CompletionSuggestionKind kind,
|
||||
String file,
|
||||
required String completion,
|
||||
ElementKind? element,
|
||||
CompletionSuggestionKind? kind,
|
||||
String? file,
|
||||
}) =>
|
||||
(CompletionSuggestion s) {
|
||||
if (s.completion != completion) {
|
||||
|
@ -175,19 +173,19 @@ project:${toUri('$projectPath/lib')}
|
|||
};
|
||||
|
||||
Iterable<CompletionSuggestion> suggestionsWith({
|
||||
@required String completion,
|
||||
ElementKind element,
|
||||
CompletionSuggestionKind kind,
|
||||
String file,
|
||||
required String completion,
|
||||
ElementKind? element,
|
||||
CompletionSuggestionKind? kind,
|
||||
String? file,
|
||||
}) =>
|
||||
suggestions.where(suggestionHas(
|
||||
completion: completion, element: element, kind: kind, file: file));
|
||||
|
||||
CompletionSuggestion suggestionWith({
|
||||
@required String completion,
|
||||
ElementKind element,
|
||||
CompletionSuggestionKind kind,
|
||||
String file,
|
||||
required String completion,
|
||||
ElementKind? element,
|
||||
CompletionSuggestionKind? kind,
|
||||
String? file,
|
||||
}) {
|
||||
final matches = suggestionsWith(
|
||||
completion: completion, element: element, kind: kind, file: file);
|
||||
|
|
|
@ -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 'dart:math' as math;
|
||||
|
||||
|
@ -73,18 +71,18 @@ class CompletionDriver extends AbstractClient with ExpectMixin {
|
|||
|
||||
final Map<String, List<AnalysisError>> filesErrors = {};
|
||||
|
||||
String completionId;
|
||||
int completionOffset;
|
||||
int replacementOffset;
|
||||
int replacementLength;
|
||||
late String completionId;
|
||||
late int completionOffset;
|
||||
late int replacementOffset;
|
||||
late int replacementLength;
|
||||
|
||||
CompletionDriver({
|
||||
@required this.supportsAvailableSuggestions,
|
||||
AnalysisServerOptions serverOptions,
|
||||
@required MemoryResourceProvider resourceProvider,
|
||||
@required String projectPath,
|
||||
@required String testFilePath,
|
||||
}) : _resourceProvider = resourceProvider,
|
||||
required this.supportsAvailableSuggestions,
|
||||
AnalysisServerOptions? serverOptions,
|
||||
required MemoryResourceProvider resourceProvider,
|
||||
required String projectPath,
|
||||
required String testFilePath,
|
||||
}) : _resourceProvider = resourceProvider,
|
||||
super(
|
||||
serverOptions: serverOptions ?? AnalysisServerOptions(),
|
||||
projectPath: resourceProvider.convertPath(projectPath),
|
||||
|
@ -95,7 +93,7 @@ class CompletionDriver extends AbstractClient with ExpectMixin {
|
|||
MemoryResourceProvider get resourceProvider => _resourceProvider;
|
||||
|
||||
@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 ^');
|
||||
|
@ -110,7 +108,7 @@ class CompletionDriver extends AbstractClient with ExpectMixin {
|
|||
}
|
||||
|
||||
@override
|
||||
void createProject({Map<String, String> packageRoots}) {
|
||||
void createProject({Map<String, String>? packageRoots}) {
|
||||
super.createProject(packageRoots: packageRoots);
|
||||
if (supportsAvailableSuggestions) {
|
||||
var request = CompletionSetSubscriptionsParams(
|
||||
|
@ -133,7 +131,7 @@ class CompletionDriver extends AbstractClient with ExpectMixin {
|
|||
}
|
||||
|
||||
@override
|
||||
File newFile(String path, String content, [int stamp]) => resourceProvider
|
||||
File newFile(String path, String content, [int? stamp]) => resourceProvider
|
||||
.newFile(resourceProvider.convertPath(path), content, stamp);
|
||||
|
||||
@override
|
||||
|
@ -190,12 +188,12 @@ class CompletionDriver extends AbstractClient with ExpectMixin {
|
|||
var importedSets = <IncludedSuggestionSet>[];
|
||||
var notImportedSets = <IncludedSuggestionSet>[];
|
||||
|
||||
for (var set in params.includedSuggestionSets) {
|
||||
for (var set in params.includedSuggestionSets!) {
|
||||
var id = set.id;
|
||||
while (!idToSetMap.containsKey(id)) {
|
||||
await Future.delayed(const Duration(milliseconds: 1));
|
||||
}
|
||||
var suggestionSet = idToSetMap[id];
|
||||
var suggestionSet = idToSetMap[id]!;
|
||||
if (importedLibraryUris.contains(suggestionSet.uri)) {
|
||||
importedSets.add(set);
|
||||
} else {
|
||||
|
@ -212,7 +210,7 @@ class CompletionDriver extends AbstractClient with ExpectMixin {
|
|||
void addSuggestion(
|
||||
AvailableSuggestion suggestion, IncludedSuggestionSet includeSet) {
|
||||
var kind = suggestion.element.kind;
|
||||
if (!includedKinds.contains(kind)) {
|
||||
if (!includedKinds!.contains(kind)) {
|
||||
return;
|
||||
}
|
||||
var completionSuggestion =
|
||||
|
@ -229,7 +227,7 @@ class CompletionDriver extends AbstractClient with ExpectMixin {
|
|||
'${s.declaringLibraryUri}:${s.element.kind}:${s.label}';
|
||||
|
||||
for (var includeSet in importedSets) {
|
||||
var set = idToSetMap[includeSet.id];
|
||||
var set = idToSetMap[includeSet.id]!;
|
||||
for (var suggestion in set.items) {
|
||||
if (seenElements.add(suggestionId(suggestion))) {
|
||||
addSuggestion(suggestion, includeSet);
|
||||
|
@ -238,7 +236,7 @@ class CompletionDriver extends AbstractClient with ExpectMixin {
|
|||
}
|
||||
|
||||
for (var includeSet in notImportedSets) {
|
||||
var set = idToSetMap[includeSet.id];
|
||||
var set = idToSetMap[includeSet.id]!;
|
||||
for (var suggestion in set.items) {
|
||||
if (!seenElements.contains(suggestionId(suggestion))) {
|
||||
addSuggestion(suggestion, includeSet);
|
||||
|
@ -252,11 +250,11 @@ class CompletionDriver extends AbstractClient with ExpectMixin {
|
|||
var params = CompletionAvailableSuggestionsParams.fromNotification(
|
||||
notification,
|
||||
);
|
||||
for (var set in params.changedLibraries) {
|
||||
for (var set in params.changedLibraries!) {
|
||||
idToSetMap[set.id] = set;
|
||||
uriToSetMap[set.uri] = set;
|
||||
}
|
||||
for (var id in params.removedLibraries) {
|
||||
for (var id in params.removedLibraries!) {
|
||||
var set = idToSetMap.remove(id);
|
||||
uriToSetMap.remove(set?.uri);
|
||||
}
|
||||
|
|
|
@ -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:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import 'completion_driver_test.dart' as completion_driver;
|
||||
|
|
|
@ -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:collection';
|
||||
|
||||
import 'package:test/test.dart';
|
||||
|
@ -2418,7 +2416,7 @@ class A<Z extends X> {
|
|||
/// expected to fail. This should be used to mark known completion bugs that
|
||||
/// have not yet been fixed.
|
||||
void buildTests(String baseName, String originalSource, List<String> results,
|
||||
{Map<String, String> extraFiles, String failingTests = ''}) {
|
||||
{Map<String, String>? extraFiles, String failingTests = ''}) {
|
||||
var completionTests = LocationSpec.from(originalSource, results);
|
||||
completionTests.sort((LocationSpec first, LocationSpec second) {
|
||||
return first.id.compareTo(second.id);
|
||||
|
|
|
@ -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:collection';
|
||||
|
||||
import 'package:analyzer_plugin/protocol/protocol_common.dart';
|
||||
|
@ -20,7 +18,7 @@ class CompletionTestCase extends AbstractCompletionDomainTest {
|
|||
.toList();
|
||||
|
||||
void assertHasCompletion(String completion,
|
||||
{ElementKind elementKind, bool isDeprecated}) {
|
||||
{ElementKind? elementKind, bool? isDeprecated}) {
|
||||
var expectedOffset = completion.indexOf(CURSOR_MARKER);
|
||||
if (expectedOffset >= 0) {
|
||||
if (completion.contains(CURSOR_MARKER, expectedOffset + 1)) {
|
||||
|
@ -31,8 +29,8 @@ class CompletionTestCase extends AbstractCompletionDomainTest {
|
|||
} else {
|
||||
expectedOffset = completion.length;
|
||||
}
|
||||
CompletionSuggestion matchingSuggestion;
|
||||
suggestions.forEach((CompletionSuggestion suggestion) {
|
||||
CompletionSuggestion? matchingSuggestion;
|
||||
for (var suggestion in suggestions) {
|
||||
if (suggestion.completion == completion) {
|
||||
if (matchingSuggestion == null) {
|
||||
matchingSuggestion = suggestion;
|
||||
|
@ -48,14 +46,14 @@ class CompletionTestCase extends AbstractCompletionDomainTest {
|
|||
"Expected exactly one '$completion' but found multiple:\n $suggestedCompletions");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
if (matchingSuggestion == null) {
|
||||
fail("Expected '$completion' but found none:\n $suggestedCompletions");
|
||||
}
|
||||
expect(matchingSuggestion.selectionOffset, equals(expectedOffset));
|
||||
expect(matchingSuggestion.selectionLength, equals(0));
|
||||
if (elementKind != null) {
|
||||
expect(matchingSuggestion.element.kind, elementKind);
|
||||
expect(matchingSuggestion.element!.kind, elementKind);
|
||||
}
|
||||
if (isDeprecated != null) {
|
||||
expect(matchingSuggestion.isDeprecated, isDeprecated);
|
||||
|
@ -74,14 +72,14 @@ class CompletionTestCase extends AbstractCompletionDomainTest {
|
|||
/// "already typed".
|
||||
void filterResults(String content) {
|
||||
var charsAlreadyTyped =
|
||||
content.substring(replacementOffset, completionOffset).toLowerCase();
|
||||
content.substring(replacementOffset!, completionOffset).toLowerCase();
|
||||
suggestions = suggestions
|
||||
.where((CompletionSuggestion suggestion) =>
|
||||
suggestion.completion.toLowerCase().startsWith(charsAlreadyTyped))
|
||||
.toList();
|
||||
}
|
||||
|
||||
Future runTest(LocationSpec spec, [Map<String, String> extraFiles]) {
|
||||
Future runTest(LocationSpec spec, [Map<String, String>? extraFiles]) {
|
||||
super.setUp();
|
||||
return Future(() {
|
||||
var content = spec.source;
|
||||
|
@ -113,7 +111,7 @@ class LocationSpec {
|
|||
int testLocation = -1;
|
||||
List<String> positiveResults = <String>[];
|
||||
List<String> negativeResults = <String>[];
|
||||
String source;
|
||||
late String source;
|
||||
|
||||
LocationSpec(this.id);
|
||||
|
||||
|
|
|
@ -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';
|
||||
|
@ -20,7 +18,6 @@ import 'package:analyzer/src/test_utilities/package_config_file_builder.dart';
|
|||
import 'package:analyzer/src/test_utilities/resource_provider_mixin.dart';
|
||||
import 'package:analyzer_plugin/protocol/protocol_common.dart';
|
||||
import 'package:analyzer_plugin/protocol/protocol_generated.dart' as plugin;
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
|
@ -263,7 +260,7 @@ class AnalysisDomainHandlerTest extends AbstractAnalysisTest {
|
|||
Response testSetAnalysisRoots(List<String> included, List<String> excluded) {
|
||||
var request =
|
||||
AnalysisSetAnalysisRootsParams(included, excluded).toRequest('0');
|
||||
return handler.handleRequest(request);
|
||||
return handler.handleRequest(request)!;
|
||||
}
|
||||
|
||||
Future<void> xtest_getReachableSources_invalidSource() async {
|
||||
|
@ -276,10 +273,9 @@ class AnalysisDomainHandlerTest extends AbstractAnalysisTest {
|
|||
|
||||
var request = AnalysisGetReachableSourcesParams('/does/not/exist.dart')
|
||||
.toRequest('0');
|
||||
var response = handler.handleRequest(request);
|
||||
expect(response.error, isNotNull);
|
||||
expect(response.error.code,
|
||||
RequestErrorCode.GET_REACHABLE_SOURCES_INVALID_FILE);
|
||||
var response = handler.handleRequest(request)!;
|
||||
var error = response.error!;
|
||||
expect(error.code, RequestErrorCode.GET_REACHABLE_SOURCES_INVALID_FILE);
|
||||
}
|
||||
|
||||
Future<void> xtest_getReachableSources_validSources() async {
|
||||
|
@ -293,9 +289,9 @@ class AnalysisDomainHandlerTest extends AbstractAnalysisTest {
|
|||
await server.onAnalysisComplete;
|
||||
|
||||
var request = AnalysisGetReachableSourcesParams(fileA).toRequest('0');
|
||||
var response = handler.handleRequest(request);
|
||||
var response = handler.handleRequest(request)!;
|
||||
|
||||
Map json = response.toJson()[Response.RESULT];
|
||||
var json = response.toJson()[Response.RESULT] as Map<String, dynamic>;
|
||||
|
||||
// Sanity checks.
|
||||
expect(json['sources'], hasLength(6));
|
||||
|
@ -1418,9 +1414,9 @@ void f(A a) {}
|
|||
}
|
||||
|
||||
void _assertAnalyzedFiles({
|
||||
@required List<String> hasErrors,
|
||||
required List<String> hasErrors,
|
||||
List<String> noErrors = const [],
|
||||
@required List<String> notAnalyzed,
|
||||
required List<String> notAnalyzed,
|
||||
}) {
|
||||
for (var path in hasErrors) {
|
||||
assertHasErrors(path);
|
||||
|
@ -1454,9 +1450,9 @@ void f(A a) {}
|
|||
|
||||
/// A helper to test 'analysis.*' requests.
|
||||
class AnalysisTestHelper with ResourceProviderMixin {
|
||||
MockServerChannel serverChannel;
|
||||
AnalysisServer server;
|
||||
AnalysisDomainHandler handler;
|
||||
late MockServerChannel serverChannel;
|
||||
late AnalysisServer server;
|
||||
late AnalysisDomainHandler handler;
|
||||
|
||||
Map<AnalysisService, List<String>> analysisSubscriptions = {};
|
||||
|
||||
|
@ -1464,9 +1460,9 @@ class AnalysisTestHelper with ResourceProviderMixin {
|
|||
Map<String, List<HighlightRegion>> filesHighlights = {};
|
||||
Map<String, List<NavigationRegion>> filesNavigation = {};
|
||||
|
||||
String projectPath;
|
||||
String testFile;
|
||||
String testCode;
|
||||
late String projectPath;
|
||||
late String testFile;
|
||||
late String testCode;
|
||||
|
||||
AnalysisTestHelper() {
|
||||
projectPath = convertPath('/project');
|
||||
|
@ -1773,8 +1769,7 @@ class A {}
|
|||
addAnalysisSubscription(AnalysisService.HIGHLIGHTS, testFile);
|
||||
// wait for analysis
|
||||
await waitForTasksFinished();
|
||||
var params = pluginManager.analysisSetSubscriptionsParams;
|
||||
expect(params, isNotNull);
|
||||
var params = pluginManager.analysisSetSubscriptionsParams!;
|
||||
var subscriptions = params.subscriptions;
|
||||
expect(subscriptions, hasLength(1));
|
||||
var files = subscriptions[plugin.AnalysisService.HIGHLIGHTS];
|
||||
|
|
|
@ -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/plugin/plugin_manager.dart';
|
||||
import 'package:analysis_server/src/provisional/completion/dart/completion_dart.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 'domain_completion_util.dart';
|
||||
import 'mocks.dart';
|
||||
import 'src/plugin/plugin_manager_test.dart';
|
||||
|
||||
void main() {
|
||||
defineReflectiveSuite(() {
|
||||
|
@ -735,7 +735,7 @@ main() {
|
|||
.toRequest('0');
|
||||
var response = await waitResponse(request);
|
||||
expect(response.id, '0');
|
||||
expect(response.error.code, RequestErrorCode.INVALID_PARAMETER);
|
||||
expect(response.error!.code, RequestErrorCode.INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
Future<void> test_overrides() {
|
||||
|
@ -803,7 +803,8 @@ class B extends A {m() {^}}
|
|||
^
|
||||
}
|
||||
''');
|
||||
PluginInfo info = DiscoveredPluginInfo('a', 'b', 'c', null, null);
|
||||
PluginInfo info = DiscoveredPluginInfo('a', 'b', 'c',
|
||||
TestNotificationManager(), InstrumentationService.NULL_SERVICE);
|
||||
var result = plugin.CompletionGetSuggestionsResult(
|
||||
testFile.indexOf('^'), 0, <CompletionSuggestion>[
|
||||
CompletionSuggestion(CompletionSuggestionKind.IDENTIFIER,
|
||||
|
|
|
@ -17,7 +17,7 @@ import 'constants.dart';
|
|||
class AbstractCompletionDomainTest extends AbstractAnalysisTest {
|
||||
late String completionId;
|
||||
late int completionOffset;
|
||||
late int replacementOffset;
|
||||
int? replacementOffset;
|
||||
late int replacementLength;
|
||||
Map<String, Completer<void>> receivedSuggestionsCompleters = {};
|
||||
List<CompletionSuggestion> suggestions = [];
|
||||
|
|
|
@ -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(() {
|
||||
|
@ -24,7 +24,7 @@ void main() {
|
|||
|
||||
@reflectiveTest
|
||||
class AssistsTest extends AbstractAnalysisTest {
|
||||
List<SourceChange> changes;
|
||||
late List<SourceChange> changes;
|
||||
|
||||
Future<void> prepareAssists(String search, [int length = 0]) async {
|
||||
var offset = findOffset(search);
|
||||
|
@ -46,7 +46,8 @@ class AssistsTest extends AbstractAnalysisTest {
|
|||
}
|
||||
|
||||
Future<void> test_fromPlugins() async {
|
||||
PluginInfo info = DiscoveredPluginInfo('a', 'b', 'c', null, null);
|
||||
PluginInfo info = DiscoveredPluginInfo('a', 'b', 'c',
|
||||
TestNotificationManager(), InstrumentationService.NULL_SERVICE);
|
||||
var message = 'From a plugin';
|
||||
var change = plugin.PrioritizedSourceChange(
|
||||
5,
|
||||
|
|
|
@ -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:io';
|
||||
|
||||
import 'package:analysis_server/protocol/protocol_generated.dart';
|
||||
|
@ -11,7 +9,6 @@ import 'package:analysis_server/src/edit/edit_domain.dart';
|
|||
import 'package:analysis_server/src/services/linter/lint_names.dart';
|
||||
import 'package:analyzer_plugin/protocol/protocol_common.dart';
|
||||
import 'package:linter/src/rules.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
|
@ -26,7 +23,7 @@ void main() {
|
|||
@reflectiveTest
|
||||
class BulkFixesTest extends AbstractAnalysisTest {
|
||||
void assertContains(List<BulkFix> details,
|
||||
{@required String path, @required String code, @required int count}) {
|
||||
{required String path, required String code, required int count}) {
|
||||
for (var detail in details) {
|
||||
if (detail.path == path) {
|
||||
for (var fix in detail.fixes) {
|
||||
|
|
|
@ -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/edit/edit_domain.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
@ -112,7 +110,7 @@ main() { int x =
|
|||
}
|
||||
|
||||
EditFormatResult _formatAt(int selectionOffset, int selectionLength,
|
||||
{int lineLength}) {
|
||||
{int? lineLength}) {
|
||||
var request = EditFormatParams(testFile, selectionOffset, selectionLength,
|
||||
lineLength: lineLength)
|
||||
.toRequest('0');
|
||||
|
|
|
@ -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/edit/edit_domain.dart';
|
||||
import 'package:analyzer_plugin/protocol/protocol_common.dart';
|
||||
|
@ -21,7 +19,7 @@ void main() {
|
|||
|
||||
@reflectiveTest
|
||||
class OrganizeDirectivesTest extends AbstractAnalysisTest {
|
||||
SourceFileEdit fileEdit;
|
||||
late SourceFileEdit fileEdit;
|
||||
|
||||
@override
|
||||
void setUp() {
|
||||
|
|
|
@ -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';
|
||||
|
@ -248,7 +246,7 @@ main(A a, B b, C c, D d) {
|
|||
@reflectiveTest
|
||||
class ExtractLocalVariableTest extends _AbstractGetRefactoring_Test {
|
||||
Future<Response> sendExtractRequest(
|
||||
int offset, int length, String name, bool extractAll) {
|
||||
int offset, int length, String? name, bool extractAll) {
|
||||
var kind = RefactoringKind.EXTRACT_LOCAL_VARIABLE;
|
||||
var options =
|
||||
name != null ? ExtractLocalVariableOptions(name, extractAll) : null;
|
||||
|
@ -263,7 +261,7 @@ class ExtractLocalVariableTest extends _AbstractGetRefactoring_Test {
|
|||
}
|
||||
|
||||
Future<Response> sendStringSuffixRequest(
|
||||
String search, String suffix, String name, bool extractAll) {
|
||||
String search, String suffix, String? name, bool extractAll) {
|
||||
var offset = findOffset(search + suffix);
|
||||
var length = search.length;
|
||||
return sendExtractRequest(offset, length, name, extractAll);
|
||||
|
@ -293,7 +291,7 @@ main() {
|
|||
return sendStringRequest('1 + 2', 'res', true);
|
||||
});
|
||||
// We get the refactoring feedback....
|
||||
ExtractLocalVariableFeedback feedback = result.feedback;
|
||||
var feedback = result.feedback as ExtractLocalVariableFeedback;
|
||||
expect(feedback.names, contains('myName'));
|
||||
}
|
||||
|
||||
|
@ -306,7 +304,7 @@ main() {
|
|||
return getRefactoringResult(() {
|
||||
return sendExtractRequest(testCode.indexOf('222 +'), 0, 'res', true);
|
||||
}).then((result) {
|
||||
ExtractLocalVariableFeedback feedback = result.feedback;
|
||||
var feedback = result.feedback as ExtractLocalVariableFeedback;
|
||||
expect(feedback.coveringExpressionOffsets, [
|
||||
testCode.indexOf('222 +'),
|
||||
testCode.indexOf('111 +'),
|
||||
|
@ -390,7 +388,7 @@ main() {
|
|||
var result = await getRefactoringResult(() {
|
||||
return sendStringSuffixRequest('getSelectedItem()', ';', null, true);
|
||||
});
|
||||
ExtractLocalVariableFeedback feedback = result.feedback;
|
||||
var feedback = result.feedback as ExtractLocalVariableFeedback;
|
||||
expect(
|
||||
feedback.names, unorderedEquals(['treeItem', 'item', 'selectedItem']));
|
||||
expect(result.change, isNull);
|
||||
|
@ -426,7 +424,7 @@ main() {
|
|||
return getRefactoringResult(() {
|
||||
return sendStringRequest('1 + 2', 'res', true);
|
||||
}).then((result) {
|
||||
ExtractLocalVariableFeedback feedback = result.feedback;
|
||||
var feedback = result.feedback as ExtractLocalVariableFeedback;
|
||||
expect(feedback.offsets, [findOffset('1 + 2'), findOffset('1 + 2')]);
|
||||
expect(feedback.lengths, [5, 6]);
|
||||
});
|
||||
|
@ -490,7 +488,7 @@ foo(int myName) {}
|
|||
var result = await getRefactoringResult(() {
|
||||
return sendStringRequest('1 + 2', 'res', true);
|
||||
});
|
||||
ExtractLocalVariableFeedback feedback = result.feedback;
|
||||
var feedback = result.feedback as ExtractLocalVariableFeedback;
|
||||
expect(feedback.names, contains('myName'));
|
||||
}
|
||||
var initialResetCount = test_resetCount;
|
||||
|
@ -515,7 +513,7 @@ foo(int myName) {}
|
|||
var result = await getRefactoringResult(() {
|
||||
return sendStringRequest('1 + 2', 'res', true);
|
||||
});
|
||||
ExtractLocalVariableFeedback feedback = result.feedback;
|
||||
var feedback = result.feedback as ExtractLocalVariableFeedback;
|
||||
expect(feedback.names, contains('myName'));
|
||||
}
|
||||
var initialResetCount = test_resetCount;
|
||||
|
@ -534,7 +532,7 @@ foo(int otherName) {}
|
|||
var result = await getRefactoringResult(() {
|
||||
return sendStringRequest('1 + 2', 'res', true);
|
||||
});
|
||||
ExtractLocalVariableFeedback feedback = result.feedback;
|
||||
var feedback = result.feedback as ExtractLocalVariableFeedback;
|
||||
// The refactoring was reset, so we don't get stale results.
|
||||
expect(feedback.names, contains('otherName'));
|
||||
}
|
||||
|
@ -549,8 +547,8 @@ main() {
|
|||
''');
|
||||
return waitForTasksFinished().then((_) {
|
||||
return sendStringRequest('1 + 2', 'res', true).then((response) {
|
||||
expect(response.error, isNotNull);
|
||||
expect(response.error.code, RequestErrorCode.SERVER_ERROR);
|
||||
var error = response.error!;
|
||||
expect(error.code, RequestErrorCode.SERVER_ERROR);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -564,8 +562,8 @@ main() {
|
|||
''');
|
||||
return waitForTasksFinished().then((_) {
|
||||
return sendStringRequest('1 + 2', 'res', true).then((response) {
|
||||
expect(response.error, isNotNull);
|
||||
expect(response.error.code, RequestErrorCode.SERVER_ERROR);
|
||||
var error = response.error!;
|
||||
expect(error.code, RequestErrorCode.SERVER_ERROR);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -579,8 +577,8 @@ main() {
|
|||
''');
|
||||
return waitForTasksFinished().then((_) {
|
||||
return sendStringRequest('1 + 2', 'res', true).then((response) {
|
||||
expect(response.error, isNotNull);
|
||||
expect(response.error.code, RequestErrorCode.SERVER_ERROR);
|
||||
var error = response.error!;
|
||||
expect(error.code, RequestErrorCode.SERVER_ERROR);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -588,10 +586,10 @@ main() {
|
|||
|
||||
@reflectiveTest
|
||||
class ExtractMethodTest extends _AbstractGetRefactoring_Test {
|
||||
int offset;
|
||||
int length;
|
||||
late int offset;
|
||||
late int length;
|
||||
String name = 'res';
|
||||
ExtractMethodOptions options;
|
||||
ExtractMethodOptions? options;
|
||||
|
||||
Future<void> test_expression() {
|
||||
addTestFile('''
|
||||
|
@ -644,13 +642,13 @@ main() {
|
|||
''');
|
||||
_setOffsetLengthForString('a + b');
|
||||
var result = await getRefactoringResult(_computeChange);
|
||||
ExtractMethodFeedback feedback = result.feedback;
|
||||
var feedback = result.feedback as ExtractMethodFeedback;
|
||||
var parameters = feedback.parameters;
|
||||
parameters[0].name = 'aaa';
|
||||
parameters[1].name = 'bbb';
|
||||
parameters[1].type = 'num';
|
||||
parameters.insert(0, parameters.removeLast());
|
||||
options.parameters = parameters;
|
||||
options!.parameters = parameters;
|
||||
return assertSuccessfulRefactoring(_sendExtractRequest, '''
|
||||
main() {
|
||||
int a = 1;
|
||||
|
@ -775,7 +773,7 @@ void res(int a, int b) {
|
|||
await waitForTasksFinished();
|
||||
var response = await _sendExtractRequest();
|
||||
var result = EditGetRefactoringResult.fromResponse(response);
|
||||
return result.feedback;
|
||||
return result.feedback as ExtractMethodFeedback;
|
||||
}
|
||||
|
||||
Future _prepareOptions() {
|
||||
|
@ -785,7 +783,7 @@ void res(int a, int b) {
|
|||
}).then((result) {
|
||||
assertResultProblemsOK(result);
|
||||
// fill options from result
|
||||
ExtractMethodFeedback feedback = result.feedback;
|
||||
var feedback = result.feedback as ExtractMethodFeedback;
|
||||
options = ExtractMethodOptions(
|
||||
feedback.returnType, false, name, feedback.parameters, true);
|
||||
// done
|
||||
|
@ -811,7 +809,7 @@ void res(int a, int b) {
|
|||
|
||||
@reflectiveTest
|
||||
class GetAvailableRefactoringsTest extends AbstractAnalysisTest {
|
||||
List<RefactoringKind> kinds;
|
||||
late List<RefactoringKind> kinds;
|
||||
|
||||
void addFlutterPackage() {
|
||||
var libFolder = MockPackages.instance.addFlutter(resourceProvider);
|
||||
|
@ -1077,7 +1075,7 @@ main() {
|
|||
return _sendInlineRequest('res =');
|
||||
});
|
||||
// We get the refactoring feedback....
|
||||
InlineLocalVariableFeedback feedback = result.feedback;
|
||||
var feedback = result.feedback as InlineLocalVariableFeedback;
|
||||
expect(feedback.occurrences, 2);
|
||||
}
|
||||
|
||||
|
@ -1092,7 +1090,7 @@ main() {
|
|||
return getRefactoringResult(() {
|
||||
return _sendInlineRequest('test =');
|
||||
}).then((result) {
|
||||
InlineLocalVariableFeedback feedback = result.feedback;
|
||||
var feedback = result.feedback as InlineLocalVariableFeedback;
|
||||
expect(feedback.name, 'test');
|
||||
expect(feedback.occurrences, 2);
|
||||
});
|
||||
|
@ -1183,7 +1181,7 @@ class A {
|
|||
return getRefactoringResult(() {
|
||||
return _sendInlineRequest('test(int p)');
|
||||
}).then((result) {
|
||||
InlineMethodFeedback feedback = result.feedback;
|
||||
var feedback = result.feedback as InlineMethodFeedback;
|
||||
expect(feedback.className, 'A');
|
||||
expect(feedback.methodName, 'test');
|
||||
expect(feedback.isDeclaration, isTrue);
|
||||
|
@ -1288,7 +1286,7 @@ main() {
|
|||
|
||||
@reflectiveTest
|
||||
class MoveFileTest extends _AbstractGetRefactoring_Test {
|
||||
MoveFileOptions options;
|
||||
late MoveFileOptions options;
|
||||
|
||||
@failingTest
|
||||
Future<void> test_OK() {
|
||||
|
@ -1322,7 +1320,7 @@ import 'bin/lib.dart';
|
|||
|
||||
@reflectiveTest
|
||||
class RenameTest extends _AbstractGetRefactoring_Test {
|
||||
Future<Response> sendRenameRequest(String search, String newName,
|
||||
Future<Response> sendRenameRequest(String search, String? newName,
|
||||
{String id = '0', bool validateOnly = false}) {
|
||||
var options = newName != null ? RenameOptions(newName) : null;
|
||||
var request = EditGetRefactoringParams(RefactoringKind.RENAME, testFile,
|
||||
|
@ -1409,7 +1407,7 @@ class NewName {
|
|||
}
|
||||
''',
|
||||
feedbackValidator: (feedback) {
|
||||
RenameFeedback renameFeedback = feedback;
|
||||
var renameFeedback = feedback as RenameFeedback;
|
||||
expect(renameFeedback.offset, 18);
|
||||
expect(renameFeedback.length, 4);
|
||||
},
|
||||
|
@ -1438,7 +1436,7 @@ main() {
|
|||
}
|
||||
''',
|
||||
feedbackValidator: (feedback) {
|
||||
RenameFeedback renameFeedback = feedback;
|
||||
var renameFeedback = feedback as RenameFeedback;
|
||||
expect(renameFeedback.offset, 42);
|
||||
expect(renameFeedback.length, 4);
|
||||
},
|
||||
|
@ -1467,7 +1465,7 @@ main() {
|
|||
}
|
||||
''',
|
||||
feedbackValidator: (feedback) {
|
||||
RenameFeedback renameFeedback = feedback;
|
||||
var renameFeedback = feedback as RenameFeedback;
|
||||
expect(renameFeedback.offset, 48);
|
||||
expect(renameFeedback.length, 4);
|
||||
},
|
||||
|
@ -1496,7 +1494,7 @@ main() {
|
|||
}
|
||||
''',
|
||||
feedbackValidator: (feedback) {
|
||||
RenameFeedback renameFeedback = feedback;
|
||||
var renameFeedback = feedback as RenameFeedback;
|
||||
expect(renameFeedback.offset, 42);
|
||||
expect(renameFeedback.length, 4);
|
||||
},
|
||||
|
@ -1525,7 +1523,7 @@ main() {
|
|||
}
|
||||
''',
|
||||
feedbackValidator: (feedback) {
|
||||
RenameFeedback renameFeedback = feedback;
|
||||
var renameFeedback = feedback as RenameFeedback;
|
||||
expect(renameFeedback.offset, 48);
|
||||
expect(renameFeedback.length, 4);
|
||||
},
|
||||
|
@ -1559,7 +1557,7 @@ main() {
|
|||
return getRefactoringResult(() {
|
||||
return sendRenameRequest('Test {}', 'NewName', validateOnly: true);
|
||||
}).then((result) {
|
||||
RenameFeedback feedback = result.feedback;
|
||||
var feedback = result.feedback as RenameFeedback;
|
||||
assertResultProblemsOK(result);
|
||||
expect(feedback.elementKindName, 'class');
|
||||
expect(feedback.oldName, 'Test');
|
||||
|
@ -1735,13 +1733,12 @@ main(A a, a2) {
|
|||
}).then((result) {
|
||||
assertResultProblemsOK(result);
|
||||
// prepare potential edit ID
|
||||
var potentialIds = result.potentialEdits;
|
||||
var potentialIds = result.potentialEdits!;
|
||||
expect(potentialIds, hasLength(1));
|
||||
var potentialId = potentialIds[0];
|
||||
// find potential edit
|
||||
var change = result.change;
|
||||
var potentialEdit = _findEditWithId(change, potentialId);
|
||||
expect(potentialEdit, isNotNull);
|
||||
var change = result.change!;
|
||||
var potentialEdit = _findEditWithId(change, potentialId)!;
|
||||
expect(potentialEdit.offset, findOffset('test(); // a2'));
|
||||
expect(potentialEdit.length, 4);
|
||||
});
|
||||
|
@ -1790,7 +1787,7 @@ class B {
|
|||
}
|
||||
''',
|
||||
feedbackValidator: (feedback) {
|
||||
RenameFeedback renameFeedback = feedback;
|
||||
var renameFeedback = feedback as RenameFeedback;
|
||||
expect(renameFeedback.offset, 20);
|
||||
expect(renameFeedback.length, 4);
|
||||
},
|
||||
|
@ -1819,7 +1816,7 @@ main() {
|
|||
}
|
||||
''',
|
||||
feedbackValidator: (feedback) {
|
||||
RenameFeedback renameFeedback = feedback;
|
||||
var renameFeedback = feedback as RenameFeedback;
|
||||
expect(renameFeedback.offset, 43);
|
||||
expect(renameFeedback.length, 4);
|
||||
},
|
||||
|
@ -1836,7 +1833,7 @@ main() {
|
|||
return getRefactoringResult(() {
|
||||
return sendRenameRequest('st v;', 'NewName');
|
||||
}).then((result) {
|
||||
RenameFeedback feedback = result.feedback;
|
||||
var feedback = result.feedback as RenameFeedback;
|
||||
expect(feedback, isNotNull);
|
||||
expect(feedback.offset, findOffset('Test v;'));
|
||||
expect(feedback.length, 'Test'.length);
|
||||
|
@ -1930,7 +1927,7 @@ main() {
|
|||
}
|
||||
''',
|
||||
feedbackValidator: (feedback) {
|
||||
RenameFeedback renameFeedback = feedback;
|
||||
var renameFeedback = feedback as RenameFeedback;
|
||||
expect(renameFeedback.offset, -1);
|
||||
expect(renameFeedback.length, 0);
|
||||
});
|
||||
|
@ -1958,7 +1955,7 @@ main() {
|
|||
}
|
||||
''',
|
||||
feedbackValidator: (feedback) {
|
||||
RenameFeedback renameFeedback = feedback;
|
||||
var renameFeedback = feedback as RenameFeedback;
|
||||
expect(renameFeedback.offset, 51);
|
||||
expect(renameFeedback.length, 4);
|
||||
});
|
||||
|
@ -2127,7 +2124,7 @@ main() {
|
|||
print(otherName);
|
||||
}
|
||||
''');
|
||||
server.getAnalysisDriver(testFile).getResult2(testFile);
|
||||
server.getAnalysisDriver(testFile)!.getResult2(testFile);
|
||||
// send the second request, with the same kind, file and offset
|
||||
await waitForTasksFinished();
|
||||
result = await getRefactoringResult(() {
|
||||
|
@ -2143,8 +2140,8 @@ main() {
|
|||
isResponseFailure('0', RequestErrorCode.REFACTORING_REQUEST_CANCELLED));
|
||||
}
|
||||
|
||||
SourceEdit _findEditWithId(SourceChange change, String id) {
|
||||
SourceEdit potentialEdit;
|
||||
SourceEdit? _findEditWithId(SourceChange change, String id) {
|
||||
SourceEdit? potentialEdit;
|
||||
change.edits.forEach((fileEdit) {
|
||||
fileEdit.edits.forEach((edit) {
|
||||
if (edit.id == id) {
|
||||
|
@ -2155,9 +2152,8 @@ main() {
|
|||
return potentialEdit;
|
||||
}
|
||||
|
||||
void _validateFeedback(EditGetRefactoringResult result, {String oldName}) {
|
||||
RenameFeedback feedback = result.feedback;
|
||||
expect(feedback, isNotNull);
|
||||
void _validateFeedback(EditGetRefactoringResult result, {String? oldName}) {
|
||||
var feedback = result.feedback as RenameFeedback;
|
||||
if (oldName != null) {
|
||||
expect(feedback.oldName, oldName);
|
||||
}
|
||||
|
@ -2170,7 +2166,7 @@ class _AbstractGetRefactoring_Test extends AbstractAnalysisTest {
|
|||
|
||||
/// Asserts that [problems] has a single ERROR problem.
|
||||
void assertResultProblemsError(List<RefactoringProblem> problems,
|
||||
[String message]) {
|
||||
[String? message]) {
|
||||
var problem = problems[0];
|
||||
expect(problem.severity, RefactoringProblemSeverity.ERROR,
|
||||
reason: problem.toString());
|
||||
|
@ -2181,7 +2177,7 @@ class _AbstractGetRefactoring_Test extends AbstractAnalysisTest {
|
|||
|
||||
/// Asserts that [result] has a single FATAL problem.
|
||||
void assertResultProblemsFatal(List<RefactoringProblem> problems,
|
||||
[String message]) {
|
||||
[String? message]) {
|
||||
var problem = problems[0];
|
||||
expect(problems, hasLength(1));
|
||||
expect(problem.severity, RefactoringProblemSeverity.FATAL,
|
||||
|
@ -2200,7 +2196,7 @@ class _AbstractGetRefactoring_Test extends AbstractAnalysisTest {
|
|||
|
||||
/// Asserts that [result] has a single WARNING problem.
|
||||
void assertResultProblemsWarning(List<RefactoringProblem> problems,
|
||||
[String message]) {
|
||||
[String? message]) {
|
||||
var problem = problems[0];
|
||||
expect(problems, hasLength(1));
|
||||
expect(problem.severity, RefactoringProblemSeverity.WARNING,
|
||||
|
@ -2212,7 +2208,7 @@ class _AbstractGetRefactoring_Test extends AbstractAnalysisTest {
|
|||
|
||||
Future assertSuccessfulRefactoring(
|
||||
Future<Response> Function() requestSender, String expectedCode,
|
||||
{void Function(RefactoringFeedback) feedbackValidator}) async {
|
||||
{void Function(RefactoringFeedback?)? feedbackValidator}) async {
|
||||
var result = await getRefactoringResult(requestSender);
|
||||
assertResultProblemsOK(result);
|
||||
if (feedbackValidator != null) {
|
||||
|
@ -2225,8 +2221,7 @@ class _AbstractGetRefactoring_Test extends AbstractAnalysisTest {
|
|||
/// which results in the [expectedCode].
|
||||
void assertTestRefactoringResult(
|
||||
EditGetRefactoringResult result, String expectedCode) {
|
||||
var change = result.change;
|
||||
expect(change, isNotNull);
|
||||
var change = result.change!;
|
||||
for (var fileEdit in change.edits) {
|
||||
if (fileEdit.file == testFile) {
|
||||
var actualCode = SourceEdit.applySequence(testCode, fileEdit.edits);
|
||||
|
@ -2247,7 +2242,7 @@ class _AbstractGetRefactoring_Test extends AbstractAnalysisTest {
|
|||
}
|
||||
|
||||
Future<Response> sendRequest(
|
||||
RefactoringKind kind, int offset, int length, RefactoringOptions options,
|
||||
RefactoringKind kind, int offset, int length, RefactoringOptions? options,
|
||||
[bool validateOnly = false]) {
|
||||
var request = EditGetRefactoringParams(
|
||||
kind, testFile, offset, length, validateOnly,
|
||||
|
|
|
@ -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/edit/edit_domain.dart';
|
||||
import 'package:analyzer_plugin/protocol/protocol_common.dart';
|
||||
|
@ -21,7 +19,7 @@ void main() {
|
|||
|
||||
@reflectiveTest
|
||||
class SortMembersTest extends AbstractAnalysisTest {
|
||||
SourceFileEdit fileEdit;
|
||||
late SourceFileEdit fileEdit;
|
||||
|
||||
@override
|
||||
void setUp() {
|
||||
|
|
|
@ -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/edit/edit_domain.dart';
|
||||
import 'package:analyzer_plugin/protocol/protocol_common.dart';
|
||||
|
@ -21,7 +19,7 @@ void main() {
|
|||
|
||||
@reflectiveTest
|
||||
class StatementCompletionTest extends AbstractAnalysisTest {
|
||||
SourceChange change;
|
||||
late SourceChange change;
|
||||
|
||||
@override
|
||||
void setUp() {
|
||||
|
@ -103,7 +101,7 @@ main() {
|
|||
(s) => s.indexOf(match) + match.length); // Ensure cursor after '='.
|
||||
}
|
||||
|
||||
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 =
|
||||
|
@ -111,12 +109,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:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import 'assists_test.dart' as assists;
|
||||
|
|
|
@ -13,7 +13,7 @@ import '../analysis_abstract.dart';
|
|||
|
||||
class AbstractSearchDomainTest extends AbstractAnalysisTest {
|
||||
final Map<String, _ResultSet> resultSets = {};
|
||||
late String searchId;
|
||||
String? searchId;
|
||||
List<SearchResult> results = <SearchResult>[];
|
||||
late SearchResult result;
|
||||
|
||||
|
|
|
@ -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:analyzer_plugin/protocol/protocol_common.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
@ -19,10 +17,10 @@ void main() {
|
|||
|
||||
@reflectiveTest
|
||||
class DeclarationsTest extends AbstractSearchDomainTest {
|
||||
SearchGetElementDeclarationsResult declarationsResult;
|
||||
late SearchGetElementDeclarationsResult declarationsResult;
|
||||
|
||||
ElementDeclaration assertHas(String name, ElementKind kind,
|
||||
{String className, String mixinName}) {
|
||||
{String? className, String? mixinName}) {
|
||||
return declarationsResult.declarations.singleWhere((ElementDeclaration d) =>
|
||||
declarationsResult.files[d.fileIndex] == testFile &&
|
||||
d.name == name &&
|
||||
|
@ -214,7 +212,7 @@ typedef tf2<T> = int Function<S>(T tp, S sp);
|
|||
}
|
||||
|
||||
Future<void> _getDeclarations(
|
||||
{String file, String pattern, int maxResults}) async {
|
||||
{String? file, String? pattern, int? maxResults}) async {
|
||||
var request = SearchGetElementDeclarationsParams(
|
||||
file: file, pattern: pattern, maxResults: maxResults)
|
||||
.toRequest('0');
|
||||
|
|
|
@ -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:analyzer_plugin/protocol/protocol_common.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
@ -19,7 +17,7 @@ void main() {
|
|||
|
||||
@reflectiveTest
|
||||
class ElementReferencesTest extends AbstractSearchDomainTest {
|
||||
Element searchElement;
|
||||
Element? searchElement;
|
||||
|
||||
void assertHasRef(SearchResultKind kind, String search, bool isPotential) {
|
||||
assertHasResult(kind, search);
|
||||
|
@ -53,7 +51,7 @@ main() {
|
|||
}
|
||||
''');
|
||||
await findElementReferences('named(p)', false);
|
||||
expect(searchElement.kind, ElementKind.CONSTRUCTOR);
|
||||
expect(searchElement!.kind, ElementKind.CONSTRUCTOR);
|
||||
expect(results, hasLength(2));
|
||||
assertHasResult(SearchResultKind.REFERENCE, '.named(1)', 6);
|
||||
assertHasResult(SearchResultKind.REFERENCE, '.named(2)', 6);
|
||||
|
@ -77,7 +75,7 @@ f(x) {
|
|||
}
|
||||
''');
|
||||
await findElementReferences('named(p); // A', true);
|
||||
expect(searchElement.kind, ElementKind.CONSTRUCTOR);
|
||||
expect(searchElement!.kind, ElementKind.CONSTRUCTOR);
|
||||
expect(results, hasLength(1));
|
||||
assertHasResult(SearchResultKind.REFERENCE, '.named(1)', 6);
|
||||
}
|
||||
|
@ -93,7 +91,7 @@ main() {
|
|||
}
|
||||
''');
|
||||
await findElementReferences('A(p)', false);
|
||||
expect(searchElement.kind, ElementKind.CONSTRUCTOR);
|
||||
expect(searchElement!.kind, ElementKind.CONSTRUCTOR);
|
||||
expect(results, hasLength(2));
|
||||
assertHasResult(SearchResultKind.REFERENCE, '(1)', 0);
|
||||
assertHasResult(SearchResultKind.REFERENCE, '(2)', 0);
|
||||
|
@ -122,7 +120,7 @@ main() {
|
|||
}
|
||||
''');
|
||||
await findElementReferences('A(p)', true);
|
||||
expect(searchElement.kind, ElementKind.CONSTRUCTOR);
|
||||
expect(searchElement!.kind, ElementKind.CONSTRUCTOR);
|
||||
expect(results, hasLength(1));
|
||||
assertHasResult(SearchResultKind.REFERENCE, '(1)', 0);
|
||||
}
|
||||
|
@ -140,7 +138,7 @@ main() {
|
|||
}
|
||||
''');
|
||||
await findElementReferences('E on int', false);
|
||||
expect(searchElement.kind, ElementKind.EXTENSION);
|
||||
expect(searchElement!.kind, ElementKind.EXTENSION);
|
||||
expect(results, hasLength(2));
|
||||
assertHasResult(SearchResultKind.REFERENCE, 'E.foo();');
|
||||
assertHasResult(SearchResultKind.REFERENCE, 'E(0)');
|
||||
|
@ -167,7 +165,7 @@ main(A a) {
|
|||
}
|
||||
''');
|
||||
await findElementReferences('fff; // declaration', false);
|
||||
expect(searchElement.kind, ElementKind.FIELD);
|
||||
expect(searchElement!.kind, ElementKind.FIELD);
|
||||
expect(results, hasLength(10));
|
||||
assertHasResult(SearchResultKind.WRITE, 'fff); // in constructor');
|
||||
assertHasResult(SearchResultKind.WRITE, 'fff = 1;');
|
||||
|
@ -200,7 +198,7 @@ main(A a) {
|
|||
''');
|
||||
{
|
||||
await findElementReferences('fff =>', false);
|
||||
expect(searchElement.kind, ElementKind.FIELD);
|
||||
expect(searchElement!.kind, ElementKind.FIELD);
|
||||
expect(results, hasLength(4));
|
||||
assertHasResult(SearchResultKind.READ, 'fff); // in m()');
|
||||
assertHasResult(SearchResultKind.WRITE, 'fff = 1;');
|
||||
|
@ -229,7 +227,7 @@ class A {
|
|||
}
|
||||
''');
|
||||
await findElementReferences('fff); // in constructor', false);
|
||||
expect(searchElement.kind, ElementKind.FIELD);
|
||||
expect(searchElement!.kind, ElementKind.FIELD);
|
||||
expect(results, hasLength(3));
|
||||
assertHasResult(SearchResultKind.WRITE, 'fff); // in constructor');
|
||||
assertHasResult(SearchResultKind.WRITE, 'fff = 2;');
|
||||
|
@ -257,7 +255,7 @@ main() {
|
|||
}
|
||||
''');
|
||||
await findElementReferences('fff; // declaration', false);
|
||||
expect(searchElement.kind, ElementKind.FIELD);
|
||||
expect(searchElement!.kind, ElementKind.FIELD);
|
||||
expect(results, hasLength(8));
|
||||
// m()
|
||||
assertHasResult(SearchResultKind.WRITE, 'fff = 2;');
|
||||
|
@ -288,7 +286,7 @@ main() {
|
|||
''');
|
||||
{
|
||||
await findElementReferences('fff =>', false);
|
||||
expect(searchElement.kind, ElementKind.FIELD);
|
||||
expect(searchElement!.kind, ElementKind.FIELD);
|
||||
expect(results, hasLength(4));
|
||||
assertHasResult(SearchResultKind.READ, 'fff); // in m()');
|
||||
assertHasResult(SearchResultKind.WRITE, 'fff = 1;');
|
||||
|
@ -322,7 +320,7 @@ main() {
|
|||
''');
|
||||
{
|
||||
await findElementReferences('fff =>', false);
|
||||
expect(searchElement.kind, ElementKind.FIELD);
|
||||
expect(searchElement!.kind, ElementKind.FIELD);
|
||||
expect(results, hasLength(4));
|
||||
assertHasResult(SearchResultKind.READ, 'fff); // in m()');
|
||||
assertHasResult(SearchResultKind.WRITE, 'fff = 1;');
|
||||
|
@ -348,7 +346,7 @@ main() {
|
|||
}
|
||||
''');
|
||||
await findElementReferences('fff(p) {}', false);
|
||||
expect(searchElement.kind, ElementKind.FUNCTION);
|
||||
expect(searchElement!.kind, ElementKind.FUNCTION);
|
||||
expect(results, hasLength(2));
|
||||
assertHasResult(SearchResultKind.INVOCATION, 'fff(1)');
|
||||
assertHasResult(SearchResultKind.REFERENCE, 'fff);');
|
||||
|
@ -372,7 +370,7 @@ main() {
|
|||
}
|
||||
''');
|
||||
await findElementReferences('fff; // in B', false);
|
||||
expect(searchElement.kind, ElementKind.FIELD);
|
||||
expect(searchElement!.kind, ElementKind.FIELD);
|
||||
assertHasResult(SearchResultKind.WRITE, 'fff = 10;');
|
||||
assertHasResult(SearchResultKind.WRITE, 'fff = 20;');
|
||||
assertHasResult(SearchResultKind.WRITE, 'fff = 30;');
|
||||
|
@ -396,7 +394,7 @@ main(A a, B b, C c) {
|
|||
}
|
||||
''');
|
||||
await findElementReferences('mmm(_) {} // in B', false);
|
||||
expect(searchElement.kind, ElementKind.METHOD);
|
||||
expect(searchElement!.kind, ElementKind.METHOD);
|
||||
assertHasResult(SearchResultKind.INVOCATION, 'mmm(10)');
|
||||
assertHasResult(SearchResultKind.INVOCATION, 'mmm(20)');
|
||||
assertHasResult(SearchResultKind.INVOCATION, 'mmm(30)');
|
||||
|
@ -420,7 +418,7 @@ main() {
|
|||
}
|
||||
''');
|
||||
await findElementReferences('mmm(_) {} // in B', false);
|
||||
expect(searchElement.kind, ElementKind.METHOD);
|
||||
expect(searchElement!.kind, ElementKind.METHOD);
|
||||
expect(results, hasLength(1));
|
||||
assertHasResult(SearchResultKind.INVOCATION, 'mmm(20)');
|
||||
}
|
||||
|
@ -443,7 +441,7 @@ main(A a, B b, C c) {
|
|||
}
|
||||
''');
|
||||
await findElementReferences('p}) {} // in B', false);
|
||||
expect(searchElement.kind, ElementKind.PARAMETER);
|
||||
expect(searchElement!.kind, ElementKind.PARAMETER);
|
||||
assertHasResult(SearchResultKind.REFERENCE, 'p: 1');
|
||||
assertHasResult(SearchResultKind.REFERENCE, 'p: 2');
|
||||
assertHasResult(SearchResultKind.REFERENCE, 'p: 3');
|
||||
|
@ -462,7 +460,7 @@ myLabel:
|
|||
}
|
||||
''');
|
||||
await findElementReferences('myLabel; // break', false);
|
||||
expect(searchElement.kind, ElementKind.LABEL);
|
||||
expect(searchElement!.kind, ElementKind.LABEL);
|
||||
expect(results, hasLength(2));
|
||||
assertHasResult(SearchResultKind.REFERENCE, 'myLabel; // continue');
|
||||
assertHasResult(SearchResultKind.REFERENCE, 'myLabel; // break');
|
||||
|
@ -479,7 +477,7 @@ main() {
|
|||
}
|
||||
''');
|
||||
await findElementReferences('vvv = 1', false);
|
||||
expect(searchElement.kind, ElementKind.LOCAL_VARIABLE);
|
||||
expect(searchElement!.kind, ElementKind.LOCAL_VARIABLE);
|
||||
expect(results, hasLength(4));
|
||||
assertHasResult(SearchResultKind.READ, 'vvv);');
|
||||
assertHasResult(SearchResultKind.READ_WRITE, 'vvv += 3');
|
||||
|
@ -502,7 +500,7 @@ main(A a) {
|
|||
}
|
||||
''');
|
||||
await findElementReferences('mmm(p) {}', false);
|
||||
expect(searchElement.kind, ElementKind.METHOD);
|
||||
expect(searchElement!.kind, ElementKind.METHOD);
|
||||
expect(results, hasLength(4));
|
||||
assertHasResult(SearchResultKind.INVOCATION, 'mmm(1);');
|
||||
assertHasResult(SearchResultKind.REFERENCE, 'mmm); // in m()');
|
||||
|
@ -524,7 +522,7 @@ main() {
|
|||
}
|
||||
''');
|
||||
await findElementReferences('foo() {}', false);
|
||||
expect(searchElement.kind, ElementKind.METHOD);
|
||||
expect(searchElement!.kind, ElementKind.METHOD);
|
||||
expect(results, hasLength(4));
|
||||
assertHasResult(SearchResultKind.INVOCATION, 'foo(); // 1');
|
||||
assertHasResult(SearchResultKind.REFERENCE, 'foo; // 2');
|
||||
|
@ -544,7 +542,7 @@ main() {
|
|||
}
|
||||
''');
|
||||
await findElementReferences('mmm(p) {}', false);
|
||||
expect(searchElement.kind, ElementKind.METHOD);
|
||||
expect(searchElement!.kind, ElementKind.METHOD);
|
||||
expect(results, hasLength(2));
|
||||
assertHasResult(SearchResultKind.INVOCATION, 'mmm(10);');
|
||||
assertHasResult(SearchResultKind.REFERENCE, 'mmm);');
|
||||
|
@ -556,7 +554,7 @@ mixin A {}
|
|||
class B extends Object with A {} // B
|
||||
''');
|
||||
await findElementReferences('A {}', false);
|
||||
expect(searchElement.kind, ElementKind.MIXIN);
|
||||
expect(searchElement!.kind, ElementKind.MIXIN);
|
||||
expect(results, hasLength(1));
|
||||
assertHasResult(SearchResultKind.REFERENCE, 'A {} // B');
|
||||
}
|
||||
|
@ -594,7 +592,7 @@ main(ppp) {
|
|||
}
|
||||
''');
|
||||
await findElementReferences('ppp) {', false);
|
||||
expect(searchElement.kind, ElementKind.PARAMETER);
|
||||
expect(searchElement!.kind, ElementKind.PARAMETER);
|
||||
expect(results, hasLength(4));
|
||||
assertHasResult(SearchResultKind.READ, 'ppp);');
|
||||
assertHasResult(SearchResultKind.READ_WRITE, 'ppp += 3');
|
||||
|
@ -801,9 +799,10 @@ main() {
|
|||
}
|
||||
''');
|
||||
await findElementReferences('ppp;', false);
|
||||
var searchElement = this.searchElement!;
|
||||
expect(searchElement.kind, ElementKind.PREFIX);
|
||||
expect(searchElement.name, 'ppp');
|
||||
expect(searchElement.location.startLine, 1);
|
||||
expect(searchElement.location!.startLine, 1);
|
||||
expect(results, hasLength(2));
|
||||
assertHasResult(SearchResultKind.REFERENCE, 'ppp.Future');
|
||||
assertHasResult(SearchResultKind.REFERENCE, 'ppp.Stream');
|
||||
|
@ -820,7 +819,7 @@ main() {
|
|||
}
|
||||
''');
|
||||
await findElementReferences('vvv = 1', false);
|
||||
expect(searchElement.kind, ElementKind.TOP_LEVEL_VARIABLE);
|
||||
expect(searchElement!.kind, ElementKind.TOP_LEVEL_VARIABLE);
|
||||
expect(results, hasLength(4));
|
||||
assertHasResult(SearchResultKind.READ, 'vvv);');
|
||||
assertHasResult(SearchResultKind.WRITE, 'vvv += 3');
|
||||
|
@ -839,7 +838,7 @@ main() {
|
|||
''');
|
||||
{
|
||||
await findElementReferences('vvv =>', false);
|
||||
expect(searchElement.kind, ElementKind.TOP_LEVEL_VARIABLE);
|
||||
expect(searchElement!.kind, ElementKind.TOP_LEVEL_VARIABLE);
|
||||
expect(results, hasLength(2));
|
||||
assertHasResult(SearchResultKind.READ, 'vvv);');
|
||||
assertHasResult(SearchResultKind.WRITE, 'vvv = 1;');
|
||||
|
@ -860,7 +859,7 @@ main() {
|
|||
}
|
||||
''');
|
||||
await findElementReferences('int a', false);
|
||||
expect(searchElement.kind, ElementKind.CLASS);
|
||||
expect(searchElement!.kind, ElementKind.CLASS);
|
||||
assertHasResult(SearchResultKind.REFERENCE, 'int a');
|
||||
assertHasResult(SearchResultKind.REFERENCE, 'int b');
|
||||
}
|
||||
|
@ -872,7 +871,7 @@ main(F f) {
|
|||
}
|
||||
''');
|
||||
await findElementReferences('F =', false);
|
||||
expect(searchElement.kind, ElementKind.TYPE_ALIAS);
|
||||
expect(searchElement!.kind, ElementKind.TYPE_ALIAS);
|
||||
expect(results, hasLength(1));
|
||||
assertHasResult(SearchResultKind.REFERENCE, 'F f');
|
||||
}
|
||||
|
@ -885,13 +884,13 @@ void(A<String> a) {}
|
|||
''');
|
||||
// Can find `A`.
|
||||
await findElementReferences('A<T> =', false);
|
||||
expect(searchElement.kind, ElementKind.TYPE_ALIAS);
|
||||
expect(searchElement!.kind, ElementKind.TYPE_ALIAS);
|
||||
expect(results, hasLength(1));
|
||||
assertHasResult(SearchResultKind.REFERENCE, 'A<String>');
|
||||
|
||||
// Can find in `A`.
|
||||
await findElementReferences('int,', false);
|
||||
expect(searchElement.kind, ElementKind.CLASS);
|
||||
expect(searchElement!.kind, ElementKind.CLASS);
|
||||
assertHasResult(SearchResultKind.REFERENCE, 'int,');
|
||||
}
|
||||
|
||||
|
@ -902,7 +901,7 @@ main(F f) {
|
|||
}
|
||||
''');
|
||||
await findElementReferences('F()', false);
|
||||
expect(searchElement.kind, ElementKind.TYPE_ALIAS);
|
||||
expect(searchElement!.kind, ElementKind.TYPE_ALIAS);
|
||||
expect(results, hasLength(1));
|
||||
assertHasResult(SearchResultKind.REFERENCE, 'F f');
|
||||
}
|
||||
|
@ -915,7 +914,7 @@ class A<T> {
|
|||
}
|
||||
''');
|
||||
await findElementReferences('T> {', false);
|
||||
expect(searchElement.kind, ElementKind.TYPE_PARAMETER);
|
||||
expect(searchElement!.kind, ElementKind.TYPE_PARAMETER);
|
||||
expect(results, hasLength(2));
|
||||
assertHasResult(SearchResultKind.REFERENCE, 'T f;');
|
||||
assertHasResult(SearchResultKind.REFERENCE, 'T m()');
|
||||
|
|
|
@ -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:analyzer_plugin/protocol/protocol_common.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
@ -20,10 +18,11 @@ void main() {
|
|||
@reflectiveTest
|
||||
class MemberDeclarationsTest extends AbstractSearchDomainTest {
|
||||
void assertHasDeclaration(ElementKind kind, String className) {
|
||||
result = findTopLevelResult(kind, className);
|
||||
var result = findTopLevelResult(kind, className);
|
||||
if (result == null) {
|
||||
fail('Not found: kind=$kind in="$className"\nin\n' + results.join('\n'));
|
||||
}
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
Future findMemberDeclarations(String name) async {
|
||||
|
@ -35,7 +34,7 @@ class MemberDeclarationsTest extends AbstractSearchDomainTest {
|
|||
return waitForSearchResults();
|
||||
}
|
||||
|
||||
SearchResult findTopLevelResult(ElementKind kind, String enclosingClass) {
|
||||
SearchResult? findTopLevelResult(ElementKind kind, String enclosingClass) {
|
||||
for (var result in results) {
|
||||
var element = result.path[0];
|
||||
var clazz = result.path[1];
|
||||
|
|
|
@ -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:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.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:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import 'declarations_test.dart' as declarations_test;
|
||||
|
|
|
@ -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:analyzer_plugin/protocol/protocol_common.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
@ -20,14 +18,15 @@ void main() {
|
|||
@reflectiveTest
|
||||
class TopLevelDeclarationsTest extends AbstractSearchDomainTest {
|
||||
void assertHasDeclaration(ElementKind kind, String name) {
|
||||
result = findTopLevelResult(kind, name);
|
||||
var result = findTopLevelResult(kind, name);
|
||||
if (result == null) {
|
||||
fail('Not found: kind=$kind name="$name"\nin\n' + results.join('\n'));
|
||||
}
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
void assertNoDeclaration(ElementKind kind, String name) {
|
||||
result = findTopLevelResult(kind, name);
|
||||
var result = findTopLevelResult(kind, name);
|
||||
if (result != null) {
|
||||
fail('Unexpected: kind=$kind name="$name"\nin\n' + results.join('\n'));
|
||||
}
|
||||
|
@ -44,7 +43,7 @@ class TopLevelDeclarationsTest extends AbstractSearchDomainTest {
|
|||
return waitForSearchResults();
|
||||
}
|
||||
|
||||
SearchResult findTopLevelResult(ElementKind kind, String name) {
|
||||
SearchResult? findTopLevelResult(ElementKind kind, String name) {
|
||||
for (var result in results) {
|
||||
var element = result.path[0];
|
||||
if (element.kind == kind && element.name == name) {
|
||||
|
|
|
@ -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:analyzer_plugin/protocol/protocol_common.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.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:analyzer_plugin/protocol/protocol_common.dart';
|
||||
import 'package:test/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:analyzer_plugin/protocol/protocol_common.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.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:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import 'completion_relevance.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:analyzer_plugin/protocol/protocol_common.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.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:analyzer_plugin/protocol/protocol_common.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.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:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import '../../../../src/utilities/mock_packages.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:analyzer_plugin/protocol/protocol_common.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.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:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import 'completion_relevance.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:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import 'bool_assignment_test.dart' as bool_assignments;
|
||||
|
|
|
@ -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:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import 'arglist_contributor_test.dart' as arglist_test;
|
||||
|
|
|
@ -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:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import 'dart/test_all.dart' as dart_all;
|
||||
|
|
|
@ -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:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import 'completion/test_all.dart' as completion_all;
|
||||
|
|
|
@ -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/computer/imported_elements_computer.dart';
|
||||
import 'package:analyzer/dart/analysis/results.dart';
|
||||
|
@ -21,9 +19,9 @@ void main() {
|
|||
|
||||
@reflectiveTest
|
||||
class ImportedElementsComputerTest extends AbstractContextTest {
|
||||
String sourcePath;
|
||||
late String sourcePath;
|
||||
|
||||
List<ImportedElements> importedElements;
|
||||
late List<ImportedElements> importedElements;
|
||||
|
||||
void assertElements(List<ImportedElements> expectedElementsList) {
|
||||
expect(importedElements, hasLength(expectedElementsList.length));
|
||||
|
@ -475,7 +473,7 @@ bool randomBool() {
|
|||
var result =
|
||||
await session.getResolvedUnit2(sourcePath) as ResolvedUnitResult;
|
||||
var computer = ImportedElementsComputer(
|
||||
result.unit, content.indexOf(selection), selection.length);
|
||||
result.unit!, content.indexOf(selection), selection.length);
|
||||
importedElements = computer.compute();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import 'closing_labels_computer_test.dart' as closing_labels_computer;
|
||||
|
|
|
@ -2,17 +2,17 @@
|
|||
// 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/domain_abstract.dart';
|
||||
import 'package:analysis_server/src/plugin/plugin_manager.dart';
|
||||
import 'package:analysis_server/src/protocol_server.dart' hide Element;
|
||||
import 'package:analyzer/instrumentation/service.dart';
|
||||
import 'package:analyzer_plugin/protocol/protocol.dart' as plugin;
|
||||
import 'package:analyzer_plugin/protocol/protocol_generated.dart' as plugin;
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import '../analysis_abstract.dart';
|
||||
import 'plugin/plugin_manager_test.dart';
|
||||
|
||||
void main() {
|
||||
defineReflectiveSuite(() {
|
||||
|
@ -38,8 +38,8 @@ class AbstractRequestHandlerTest extends AbstractAnalysisTest {
|
|||
|
||||
Future<void> test_waitForResponses_nonEmpty_noTimeout_immediate() async {
|
||||
AbstractRequestHandler handler = TestAbstractRequestHandler(server);
|
||||
PluginInfo plugin1 = DiscoveredPluginInfo('p1', '', '', null, null);
|
||||
PluginInfo plugin2 = DiscoveredPluginInfo('p2', '', '', null, null);
|
||||
var plugin1 = _pluginInfo('p1');
|
||||
var plugin2 = _pluginInfo('p2');
|
||||
var response1 = plugin.Response('1', 1);
|
||||
var response2 = plugin.Response('2', 2);
|
||||
var futures = <PluginInfo, Future<plugin.Response>>{
|
||||
|
@ -52,8 +52,8 @@ class AbstractRequestHandlerTest extends AbstractAnalysisTest {
|
|||
|
||||
Future<void> test_waitForResponses_nonEmpty_noTimeout_withError() async {
|
||||
AbstractRequestHandler handler = TestAbstractRequestHandler(server);
|
||||
PluginInfo plugin1 = DiscoveredPluginInfo('p1', '', '', null, null);
|
||||
PluginInfo plugin2 = DiscoveredPluginInfo('p2', '', '', null, null);
|
||||
var plugin1 = _pluginInfo('p1');
|
||||
var plugin2 = _pluginInfo('p2');
|
||||
var response1 = plugin.Response('1', 1);
|
||||
var response2 = plugin.Response('2', 2,
|
||||
error: plugin.RequestError(
|
||||
|
@ -68,9 +68,9 @@ class AbstractRequestHandlerTest extends AbstractAnalysisTest {
|
|||
|
||||
Future<void> test_waitForResponses_nonEmpty_timeout_someDelayed() async {
|
||||
AbstractRequestHandler handler = TestAbstractRequestHandler(server);
|
||||
PluginInfo plugin1 = DiscoveredPluginInfo('p1', '', '', null, null);
|
||||
PluginInfo plugin2 = DiscoveredPluginInfo('p2', '', '', null, null);
|
||||
PluginInfo plugin3 = DiscoveredPluginInfo('p3', '', '', null, null);
|
||||
var plugin1 = _pluginInfo('p1');
|
||||
var plugin2 = _pluginInfo('p2');
|
||||
var plugin3 = _pluginInfo('p3');
|
||||
var response1 = plugin.Response('1', 1);
|
||||
var response2 = plugin.Response('2', 2);
|
||||
var response3 = plugin.Response('3', 3);
|
||||
|
@ -82,6 +82,11 @@ class AbstractRequestHandlerTest extends AbstractAnalysisTest {
|
|||
var responses = await handler.waitForResponses(futures, timeout: 50);
|
||||
expect(responses, unorderedEquals([response2]));
|
||||
}
|
||||
|
||||
PluginInfo _pluginInfo(String path) {
|
||||
return DiscoveredPluginInfo(path, '', '', TestNotificationManager(),
|
||||
InstrumentationService.NULL_SERVICE);
|
||||
}
|
||||
}
|
||||
|
||||
class TestAbstractRequestHandler extends AbstractRequestHandler {
|
||||
|
|
|
@ -2,9 +2,8 @@
|
|||
// 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:collection/collection.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
|
@ -471,16 +470,15 @@ var stringV = 'hi';
|
|||
}
|
||||
|
||||
static void assertNoSuggestion(AvailableSuggestionSet set, String label,
|
||||
{ElementKind kind}) {
|
||||
var suggestion = set.items.singleWhere(
|
||||
(s) => s.label == label && (kind == null || s.element.kind == kind),
|
||||
orElse: () => null);
|
||||
{ElementKind? kind}) {
|
||||
var suggestion = set.items.singleWhereOrNull(
|
||||
(s) => s.label == label && (kind == null || s.element.kind == kind));
|
||||
expect(suggestion, null);
|
||||
}
|
||||
|
||||
static AvailableSuggestion _getSuggestion(
|
||||
AvailableSuggestionSet set, String label,
|
||||
{ElementKind kind}) {
|
||||
{ElementKind? kind}) {
|
||||
return set.items.singleWhere(
|
||||
(s) => s.label == label && (kind == null || s.element.kind == kind));
|
||||
}
|
||||
|
|
|
@ -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:convert';
|
||||
|
||||
import 'package:analysis_server/protocol/protocol_constants.dart';
|
||||
|
@ -45,11 +43,11 @@ class AvailableSuggestionsBase extends AbstractAnalysisTest {
|
|||
var params = CompletionAvailableSuggestionsParams.fromNotification(
|
||||
notification,
|
||||
);
|
||||
for (var set in params.changedLibraries) {
|
||||
for (var set in params.changedLibraries!) {
|
||||
idToSetMap[set.id] = set;
|
||||
uriToSetMap[set.uri] = set;
|
||||
}
|
||||
for (var id in params.removedLibraries) {
|
||||
for (var id in params.removedLibraries!) {
|
||||
var set = idToSetMap.remove(id);
|
||||
uriToSetMap.remove(set?.uri);
|
||||
}
|
||||
|
@ -69,9 +67,7 @@ class AvailableSuggestionsBase extends AbstractAnalysisTest {
|
|||
/// Remove the set with the given [uri].
|
||||
/// The set must be already received.
|
||||
void removeSet(String uri) {
|
||||
var set = uriToSetMap.remove(uri);
|
||||
expect(set, isNotNull);
|
||||
|
||||
var set = uriToSetMap.remove(uri)!;
|
||||
idToSetMap.remove(set.id);
|
||||
}
|
||||
|
||||
|
|
|
@ -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/src/protocol_server.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
|
@ -39,7 +36,7 @@ main() {} // ref
|
|||
);
|
||||
|
||||
expect(result.completion, 'MyEnum.aaa');
|
||||
_assertTestFileChange(result.change, r'''
|
||||
_assertTestFileChange(result.change!, r'''
|
||||
import 'package:test/a.dart';
|
||||
|
||||
main() {} // ref
|
||||
|
@ -63,7 +60,7 @@ main() {} // ref
|
|||
);
|
||||
|
||||
expect(result.completion, 'sin');
|
||||
_assertEmptyChange(result.change);
|
||||
_assertEmptyChange(result.change!);
|
||||
}
|
||||
|
||||
Future<void> test_existingImport_prefixed() async {
|
||||
|
@ -83,7 +80,7 @@ main() {} // ref
|
|||
);
|
||||
|
||||
expect(result.completion, 'math.sin');
|
||||
_assertEmptyChange(result.change);
|
||||
_assertEmptyChange(result.change!);
|
||||
}
|
||||
|
||||
Future<void> test_invalid_library() async {
|
||||
|
@ -92,7 +89,7 @@ main() {} // ref
|
|||
var response = await waitResponse(
|
||||
_buildRequest(id: -1, label: 'foo', offset: 0),
|
||||
);
|
||||
expect(response.error.code, RequestErrorCode.INVALID_PARAMETER);
|
||||
expect(response.error!.code, RequestErrorCode.INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
Future<void> test_newImport() async {
|
||||
|
@ -110,7 +107,7 @@ main() {} // ref
|
|||
);
|
||||
|
||||
expect(result.completion, 'sin');
|
||||
_assertTestFileChange(result.change, r'''
|
||||
_assertTestFileChange(result.change!, r'''
|
||||
import 'dart:math';
|
||||
|
||||
main() {} // ref
|
||||
|
@ -139,7 +136,7 @@ main() {} // ref
|
|||
);
|
||||
|
||||
expect(result.completion, 'sin');
|
||||
_assertTestFileChange(result.change, r'''
|
||||
_assertTestFileChange(result.change!, r'''
|
||||
library foo;
|
||||
|
||||
import 'dart:math';
|
||||
|
@ -173,7 +170,7 @@ main() {} // ref
|
|||
);
|
||||
|
||||
expect(result.completion, 'sin');
|
||||
_assertTestFileChange(result.change, r'''
|
||||
_assertTestFileChange(result.change!, r'''
|
||||
@myAnnotation
|
||||
|
||||
import 'dart:math';
|
||||
|
@ -205,7 +202,7 @@ main() {} // ref
|
|||
);
|
||||
|
||||
expect(result.completion, 'sin');
|
||||
_assertTestFileChange(result.change, r'''
|
||||
_assertTestFileChange(result.change!, r'''
|
||||
import 'dart:async';
|
||||
import 'dart:math';
|
||||
@myAnnotation
|
||||
|
@ -237,7 +234,7 @@ part 'a.dart';
|
|||
);
|
||||
|
||||
expect(result.completion, 'sin');
|
||||
_assertTestFileChange(result.change, r'''
|
||||
_assertTestFileChange(result.change!, r'''
|
||||
import 'dart:math';
|
||||
|
||||
part 'a.dart';
|
||||
|
@ -260,10 +257,10 @@ part 'a.dart';
|
|||
}
|
||||
|
||||
Request _buildRequest({
|
||||
String file,
|
||||
@required int id,
|
||||
@required String label,
|
||||
@required int offset,
|
||||
String? file,
|
||||
required int id,
|
||||
required String label,
|
||||
required int offset,
|
||||
}) {
|
||||
return CompletionGetSuggestionDetailsParams(
|
||||
file ?? testFile,
|
||||
|
|
|
@ -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';
|
||||
|
@ -36,8 +34,7 @@ import 'ht:';
|
|||
}
|
||||
|
||||
void _assertHasImport(String exportingUri, String declaringUri, String name) {
|
||||
var existingImports = fileToExistingImports[testFile];
|
||||
expect(existingImports, isNotNull);
|
||||
var existingImports = fileToExistingImports[testFile]!;
|
||||
|
||||
var existingImport = existingImports.imports.singleWhere((import) =>
|
||||
existingImports.elements.strings[import.uri] == exportingUri);
|
||||
|
@ -64,7 +61,7 @@ class GetSuggestionAvailableTest extends GetSuggestionsBase {
|
|||
var results = await _getSuggestions(testFile, 0);
|
||||
expect(results.includedElementKinds, isNotEmpty);
|
||||
|
||||
var includedIdSet = results.includedSuggestionSets.map((set) => set.id);
|
||||
var includedIdSet = results.includedSuggestionSets!.map((set) => set.id);
|
||||
expect(includedIdSet, contains(mathSet.id));
|
||||
expect(includedIdSet, contains(asyncSet.id));
|
||||
}
|
||||
|
@ -107,7 +104,7 @@ main() {
|
|||
unorderedEquals([ElementKind.CONSTRUCTOR]),
|
||||
);
|
||||
|
||||
var includedIdSet = results.includedSuggestionSets.map((set) => set.id);
|
||||
var includedIdSet = results.includedSuggestionSets!.map((set) => set.id);
|
||||
expect(includedIdSet, contains(mathSet.id));
|
||||
expect(includedIdSet, contains(asyncSet.id));
|
||||
}
|
||||
|
@ -140,7 +137,7 @@ void ggg({int aaa, @required int bbb, @required int ccc}) {}
|
|||
var results = await _getSuggestions(testPath, 0);
|
||||
|
||||
expect(
|
||||
results.includedSuggestionSets.singleWhere((set) {
|
||||
results.includedSuggestionSets!.singleWhere((set) {
|
||||
return set.id == aSet.id;
|
||||
}).displayUri,
|
||||
'../a.dart',
|
||||
|
@ -156,7 +153,7 @@ void ggg({int aaa, @required int bbb, @required int ccc}) {}
|
|||
|
||||
var results = await _getSuggestions(testPath, 0);
|
||||
expect(
|
||||
results.includedSuggestionSets.singleWhere((set) {
|
||||
results.includedSuggestionSets!.singleWhere((set) {
|
||||
return set.id == aSet.id;
|
||||
}).displayUri,
|
||||
isNull,
|
||||
|
@ -242,7 +239,7 @@ main() {
|
|||
testCode.indexOf('); // ref'),
|
||||
);
|
||||
|
||||
var includedTags = results.includedSuggestionRelevanceTags;
|
||||
var includedTags = results.includedSuggestionRelevanceTags!;
|
||||
int findBoost(String tag) {
|
||||
for (var includedTag in includedTags) {
|
||||
if (includedTag.tag == tag) {
|
||||
|
@ -276,7 +273,7 @@ void f(MyEnum e) {
|
|||
testCode.indexOf(' // ref'),
|
||||
);
|
||||
|
||||
assertJsonText(results.includedSuggestionRelevanceTags, r'''
|
||||
assertJsonText(results.includedSuggestionRelevanceTags!, r'''
|
||||
[
|
||||
{
|
||||
"tag": "ElementKind.PREFIX",
|
||||
|
@ -340,7 +337,7 @@ main() {
|
|||
testCode.indexOf('); // ref'),
|
||||
);
|
||||
|
||||
assertJsonText(results.includedSuggestionRelevanceTags, r'''
|
||||
assertJsonText(results.includedSuggestionRelevanceTags!, r'''
|
||||
[
|
||||
{
|
||||
"tag": "ElementKind.PREFIX",
|
||||
|
@ -404,7 +401,7 @@ main() {
|
|||
testCode.indexOf('); // ref'),
|
||||
);
|
||||
|
||||
assertJsonText(results.includedSuggestionRelevanceTags, r'''
|
||||
assertJsonText(results.includedSuggestionRelevanceTags!, r'''
|
||||
[
|
||||
{
|
||||
"tag": "ElementKind.MIXIN",
|
||||
|
@ -475,7 +472,7 @@ main() {
|
|||
testCode.indexOf(' // ref'),
|
||||
);
|
||||
|
||||
assertJsonText(results.includedSuggestionRelevanceTags, r'''
|
||||
assertJsonText(results.includedSuggestionRelevanceTags!, r'''
|
||||
[
|
||||
{
|
||||
"tag": "ElementKind.PREFIX",
|
||||
|
@ -535,7 +532,7 @@ int v = // ref;
|
|||
testCode.indexOf(' // ref'),
|
||||
);
|
||||
|
||||
assertJsonText(results.includedSuggestionRelevanceTags, r'''
|
||||
assertJsonText(results.includedSuggestionRelevanceTags!, r'''
|
||||
[
|
||||
{
|
||||
"tag": "ElementKind.MIXIN",
|
||||
|
@ -605,7 +602,7 @@ main() {
|
|||
testCode.indexOf(']; // ref'),
|
||||
);
|
||||
|
||||
assertJsonText(results.includedSuggestionRelevanceTags, r'''
|
||||
assertJsonText(results.includedSuggestionRelevanceTags!, r'''
|
||||
[
|
||||
{
|
||||
"tag": "dart:core::int",
|
||||
|
|
|
@ -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:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import 'available_suggestion_sets_test.dart' as available_suggestion_sets;
|
||||
|
|
|
@ -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/flutter/flutter_domain.dart';
|
||||
import 'package:analysis_server/src/protocol_server.dart';
|
||||
import 'package:test/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';
|
||||
|
@ -34,7 +32,7 @@ void main() {
|
|||
expect(property.expression, "'aaa'");
|
||||
expect(property.isRequired, isTrue);
|
||||
expect(property.editor, isNotNull);
|
||||
expect(property.value.stringValue, 'aaa');
|
||||
expect(property.value!.stringValue, 'aaa');
|
||||
}
|
||||
|
||||
Future<void> test_notInstanceCreation() async {
|
||||
|
@ -46,7 +44,7 @@ void main() {
|
|||
|
||||
var response = await getWidgetDescriptionResponse('42');
|
||||
expect(
|
||||
response.error.code,
|
||||
response.error!.code,
|
||||
RequestErrorCode.FLUTTER_GET_WIDGET_DESCRIPTION_NO_WIDGET,
|
||||
);
|
||||
}
|
||||
|
@ -60,7 +58,7 @@ void main() {
|
|||
|
||||
var response = await getWidgetDescriptionResponse('new Foo');
|
||||
expect(
|
||||
response.error.code,
|
||||
response.error!.code,
|
||||
RequestErrorCode.FLUTTER_GET_WIDGET_DESCRIPTION_NO_WIDGET,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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';
|
||||
|
@ -135,7 +133,7 @@ void main() {
|
|||
|
||||
Future<FlutterSetWidgetPropertyValueResult> _setValue(
|
||||
FlutterWidgetProperty property,
|
||||
FlutterWidgetPropertyValue value,
|
||||
FlutterWidgetPropertyValue? value,
|
||||
) async {
|
||||
var response = await _setValueResponse(property, value);
|
||||
expect(response.error, isNull);
|
||||
|
@ -144,7 +142,7 @@ void main() {
|
|||
|
||||
Future<Response> _setValueResponse(
|
||||
FlutterWidgetProperty property,
|
||||
FlutterWidgetPropertyValue value,
|
||||
FlutterWidgetPropertyValue? value,
|
||||
) async {
|
||||
var request = FlutterSetWidgetPropertyValueParams(
|
||||
property.id,
|
||||
|
|
|
@ -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:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import 'get_widget_description_test.dart' as get_widget_description;
|
||||
|
|
|
@ -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:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import 'completion/test_all.dart' as completion;
|
||||
|
|
|
@ -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';
|
||||
|
@ -25,15 +23,16 @@ void main() {
|
|||
|
||||
@reflectiveTest
|
||||
class FlutterNotificationOutlineTest extends AbstractAnalysisTest {
|
||||
Folder flutterFolder;
|
||||
late Folder flutterFolder;
|
||||
|
||||
final Map<FlutterService, List<String>> flutterSubscriptions = {};
|
||||
|
||||
final Completer<void> _outlineReceived = Completer();
|
||||
FlutterOutline outline;
|
||||
late FlutterOutline outline;
|
||||
|
||||
FlutterDomainHandler get flutterHandler =>
|
||||
server.handlers.singleWhere((handler) => handler is FlutterDomainHandler);
|
||||
server.handlers.singleWhere((handler) => handler is FlutterDomainHandler)
|
||||
as FlutterDomainHandler;
|
||||
|
||||
void addFlutterSubscription(FlutterService service, String file) {
|
||||
// add file to subscription
|
||||
|
@ -97,25 +96,25 @@ class MyWidget extends StatelessWidget {
|
|||
await prepareOutline();
|
||||
var unitOutline = outline;
|
||||
|
||||
var myWidgetOutline = unitOutline.children[0];
|
||||
var myWidgetOutline = unitOutline.children![0];
|
||||
expect(myWidgetOutline.kind, FlutterOutlineKind.DART_ELEMENT);
|
||||
expect(myWidgetOutline.dartElement.name, 'MyWidget');
|
||||
expect(myWidgetOutline.dartElement!.name, 'MyWidget');
|
||||
|
||||
var buildOutline = myWidgetOutline.children[0];
|
||||
var buildOutline = myWidgetOutline.children![0];
|
||||
expect(buildOutline.kind, FlutterOutlineKind.DART_ELEMENT);
|
||||
expect(buildOutline.dartElement.name, 'build');
|
||||
expect(buildOutline.dartElement!.name, 'build');
|
||||
|
||||
var columnOutline = buildOutline.children[0];
|
||||
var columnOutline = buildOutline.children![0];
|
||||
expect(columnOutline.kind, FlutterOutlineKind.NEW_INSTANCE);
|
||||
expect(columnOutline.className, 'Column');
|
||||
expect(columnOutline.children, hasLength(2));
|
||||
|
||||
var textOutlineA = columnOutline.children[0];
|
||||
var textOutlineA = columnOutline.children![0];
|
||||
expect(textOutlineA.kind, FlutterOutlineKind.NEW_INSTANCE);
|
||||
expect(textOutlineA.className, 'Text');
|
||||
expect(textOutlineA.offset, code.indexOf("const Text('aaa')"));
|
||||
|
||||
var textOutlineB = columnOutline.children[1];
|
||||
var textOutlineB = columnOutline.children![1];
|
||||
expect(textOutlineB.kind, FlutterOutlineKind.NEW_INSTANCE);
|
||||
expect(textOutlineB.className, 'Text');
|
||||
expect(textOutlineB.offset, code.indexOf("const Text('bbb')"));
|
||||
|
|
|
@ -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:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import 'flutter_outline_computer_test.dart' as outline_computer;
|
||||
|
|
|
@ -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_reflective_loader/test_reflective_loader.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:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import 'completion_test.dart' as completion;
|
||||
|
|
|
@ -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:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import 'dart/test_all.dart' as 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:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import 'add_type_parameter_test.dart' as add_type_parameter;
|
||||
|
|
|
@ -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/services/correction/fix/data_driven/transform_set_manager.dart';
|
||||
import 'package:analyzer/dart/analysis/results.dart';
|
||||
import 'package:analyzer/dart/analysis/session.dart';
|
||||
|
@ -38,7 +36,7 @@ class TransformSetManagerTest extends AbstractContextTest {
|
|||
var testFile = convertPath('/home/test/lib/test.dart');
|
||||
addSource(testFile, '');
|
||||
var result = await session.getResolvedLibraryValid(testFile);
|
||||
var sets = manager.forLibrary(result.element);
|
||||
var sets = manager.forLibrary(result.element!);
|
||||
expect(sets, hasLength(2));
|
||||
}
|
||||
|
||||
|
@ -49,7 +47,7 @@ class TransformSetManagerTest extends AbstractContextTest {
|
|||
var testFile = convertPath('/home/test/lib/test.dart');
|
||||
addSource(testFile, '');
|
||||
var result = await session.getResolvedLibraryValid(testFile);
|
||||
var sets = manager.forLibrary(result.element);
|
||||
var sets = manager.forLibrary(result.element!);
|
||||
expect(sets, hasLength(0));
|
||||
}
|
||||
|
||||
|
|
|
@ -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:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import 'add_async_test.dart' as add_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:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import 'assist/test_all.dart' as assist_all;
|
||||
|
|
|
@ -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:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import 'completion/test_all.dart' as completion;
|
||||
|
|
|
@ -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:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import 'cider/test_all.dart' as cider;
|
||||
|
|
Loading…
Reference in a new issue