Migrate pkg/analysis_server/test/integration/analysis/

Change-Id: I6dc636c06e13d1ac1da6caf2e33443baca08315d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194001
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
Konstantin Shcheglov
2021-04-05 07:46:16 +00:00
committed by commit-bot@chromium.org
parent 1c25329091
commit 3ea23d2f55
30 changed files with 161 additions and 207 deletions
@@ -12,6 +12,7 @@ import 'package:analysis_server/src/computer/computer_hover.dart';
import 'package:analysis_server/src/computer/computer_signature.dart';
import 'package:analysis_server/src/computer/imported_elements_computer.dart';
import 'package:analysis_server/src/domain_abstract.dart';
import 'package:analysis_server/src/domain_analysis_flags.dart';
import 'package:analysis_server/src/plugin/request_converter.dart';
import 'package:analysis_server/src/plugin/result_merger.dart';
import 'package:analysis_server/src/protocol/protocol_internal.dart';
@@ -22,9 +23,6 @@ import 'package:analyzer_plugin/protocol/protocol_generated.dart' as plugin;
import 'package:analyzer_plugin/src/utilities/navigation/navigation.dart';
import 'package:analyzer_plugin/utilities/navigation/navigation_dart.dart';
// TODO(devoncarew): See #31456 for the tracking issue to remove this flag.
final bool disableManageImportsOnPaste = true;
/// Instances of the class [AnalysisDomainHandler] implement a [RequestHandler]
/// that handles requests in the `analysis` domain.
class AnalysisDomainHandler extends AbstractRequestHandler {
@@ -0,0 +1,6 @@
// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// TODO(devoncarew): See #31456 for the tracking issue to remove this flag.
final bool disableManageImportsOnPaste = true;
@@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// @dart = 2.9
import 'package:analyzer/src/util/file_paths.dart' as file_paths;
import 'package:analyzer_plugin/protocol/protocol_common.dart';
import 'package:test/test.dart';
@@ -38,7 +36,7 @@ linter:
await analysisFinished;
expect(currentAnalysisErrors[options], isList);
var errors = currentAnalysisErrors[options];
var errors = existingErrorsForFile(options);
expect(errors, hasLength(1));
var error = errors[0];
expect(error.location.file, options);
@@ -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';
@@ -33,7 +31,7 @@ main() {
await analysisFinished;
expect(currentAnalysisErrors[filePath], isList);
var errors = currentAnalysisErrors[filePath];
var errors = existingErrorsForFile(filePath);
expect(errors, hasLength(1));
expect(errors[0].location.file, equals(filePath));
}
@@ -47,7 +45,7 @@ main() {
standardAnalysisSetup();
return analysisFinished.then((_) {
expect(currentAnalysisErrors[pathname], isList);
var errors = currentAnalysisErrors[pathname];
var errors = existingErrorsForFile(pathname);
expect(errors, hasLength(1));
expect(errors[0].location.file, equals(pathname));
});
@@ -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:path/path.dart' as path;
@@ -78,7 +76,7 @@ final LIBRARIES = const <String, LibraryInfo> {
}
@override
Future startServer({int diagnosticPort, int servicesPort}) {
Future startServer({int? diagnosticPort, int? servicesPort}) {
var sdkPath = createNonStandardSdk();
return server.start(
diagnosticPort: diagnosticPort,
@@ -95,7 +93,7 @@ import 'dart:fake';
writeFile(pathname, text);
standardAnalysisSetup();
await analysisFinished;
var errors = currentAnalysisErrors[pathname];
var errors = existingErrorsForFile(pathname);
expect(errors, hasLength(1));
expect(errors[0].code, 'unused_import');
}
@@ -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/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:analysis_server/protocol/protocol_generated.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';
@@ -21,7 +19,7 @@ void main() {
class AnalysisGetHoverIntegrationTest
extends AbstractAnalysisServerIntegrationTest {
/// Pathname of the file containing Dart code.
String pathname;
late String pathname;
/// Dart code under test.
final String text = r'''
@@ -55,17 +53,17 @@ main() {
/// literal value. [parameterRegexps] means is a set of regexps which should
/// match the hover parameters. [propagatedType], if specified, is the
/// expected propagated type of the element.
Future<AnalysisGetHoverResult> checkHover(
Future<AnalysisGetHoverResult?> checkHover(
String target,
int length,
List<String> descriptionRegexps,
String kind,
List<String> staticTypeRegexps, {
List<String>? descriptionRegexps,
String? kind,
List<String>? staticTypeRegexps, {
bool isLocal = false,
bool isCore = false,
String docRegexp,
String? docRegexp,
bool isLiteral = false,
List<String> parameterRegexps,
List<String>? parameterRegexps,
}) {
var offset = text.indexOf(target);
return sendAnalysisGetHover(pathname, offset).then((result) async {
@@ -74,7 +72,7 @@ main() {
expect(info.offset, equals(offset));
expect(info.length, equals(length));
if (isCore) {
expect(path.basename(info.containingLibraryPath), equals('core.dart'));
expect(path.basename(info.containingLibraryPath!), equals('core.dart'));
expect(info.containingLibraryName, equals('dart:core'));
} else if (isLocal || isLiteral) {
expect(info.containingLibraryPath, isNull);
@@ -2,10 +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/protocol/protocol_generated.dart';
import 'package:analysis_server/src/domain_analysis.dart';
import 'package:analysis_server/src/domain_analysis_flags.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -22,10 +20,10 @@ void main() {
class AnalysisGetImportedElementsIntegrationTest
extends AbstractAnalysisServerIntegrationTest {
/// Pathname of the file containing Dart code.
String pathname;
late String pathname;
/// Dart code under test.
String text;
late String text;
/// Check that an analysis.getImportedElements request on the region starting
/// with the first character that matches [target] and having the given
@@ -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/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -41,7 +39,7 @@ class Bar {
expect(libraries.any((String lib) => lib.endsWith('core/core.dart')), true);
expect(packageMaps.keys, hasLength(1));
var map = packageMaps[packageMaps.keys.first];
var map = packageMaps[packageMaps.keys.first]!;
expect(map.keys, isEmpty);
}
}
@@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// @dart = 2.9
import 'package:analyzer_plugin/protocol/protocol_common.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 'dart:io';
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/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 AnalysisHighlightsTest extends AbstractAnalysisServerIntegrationTest {
Map<HighlightRegionType, Set<String>> highlights;
late Map<HighlightRegionType, Set<String>> highlights;
void check(HighlightRegionType type, List<String> expected) {
expect(highlights[type], equals(expected.toSet()));
@@ -41,10 +39,7 @@ class AnalysisHighlightsTest extends AbstractAnalysisServerIntegrationTest {
var endIndex = startIndex + region.length;
var highlightedText = text.substring(startIndex, endIndex);
var type = region.type;
if (!highlights.containsKey(type)) {
highlights[type] = <String>{};
}
highlights[type].add(highlightedText);
highlights.putIfAbsent(type, () => {}).add(highlightedText);
}
});
await analysisFinished;
@@ -52,8 +47,8 @@ class AnalysisHighlightsTest extends AbstractAnalysisServerIntegrationTest {
@override
Future startServer({
int diagnosticPort,
int servicesPort,
int? diagnosticPort,
int? servicesPort,
}) {
return server.start(
diagnosticPort: diagnosticPort,
@@ -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/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:analyzer/src/util/file_paths.dart' as file_paths;
import 'package:analyzer_plugin/protocol/protocol_common.dart';
import 'package:test/test.dart';
@@ -50,7 +48,7 @@ class a { // lint: not CamelCase
await analysisFinished;
expect(currentAnalysisErrors[source], isList);
var errors = currentAnalysisErrors[source];
var errors = existingErrorsForFile(source);
expect(errors, hasLength(1));
var error = errors[0];
expect(error.location.file, source);
@@ -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';
@@ -60,22 +58,19 @@ part of foo;
sendAnalysisSetSubscriptions({
AnalysisService.NAVIGATION: [pathname1]
});
List<NavigationRegion> regions;
List<NavigationTarget> targets;
List<String> targetFiles;
onAnalysisNavigation.listen((AnalysisNavigationParams params) {
expect(params.file, equals(pathname1));
regions = params.regions;
targets = params.targets;
targetFiles = params.files;
});
await analysisFinished;
// There should be a single error, due to the fact that 'dart:async' is not
// used.
await analysisFinished;
expect(currentAnalysisErrors[pathname1], hasLength(1));
expect(currentAnalysisErrors[pathname2], isEmpty);
var params = await onAnalysisNavigation.first;
expect(params.file, equals(pathname1));
var regions = params.regions;
var targets = params.targets;
var targetFiles = params.files;
NavigationTarget findTargetElement(int index) {
for (var region in regions) {
if (region.offset <= index && index < region.offset + region.length) {
@@ -2,10 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// @dart = 2.9
import 'package:analysis_server/protocol/protocol_generated.dart';
import 'package:analyzer_plugin/protocol/protocol_common.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -19,7 +16,7 @@ void main() {
@reflectiveTest
class OccurrencesTest extends AbstractAnalysisServerIntegrationTest {
Future<void> test_occurrences() {
Future<void> test_occurrences() async {
var pathname = sourcePath('test.dart');
var text = r'''
main() {
@@ -37,33 +34,33 @@ main() {
sendAnalysisSetSubscriptions({
AnalysisService.OCCURRENCES: [pathname]
});
List<Occurrences> occurrences;
onAnalysisOccurrences.listen((AnalysisOccurrencesParams params) {
expect(params.file, equals(pathname));
occurrences = params.occurrences;
});
return analysisFinished.then((_) {
expect(currentAnalysisErrors[pathname], isEmpty);
Set<int> findOffsets(String elementName) {
for (var occurrence in occurrences) {
if (occurrence.element.name == elementName) {
return occurrence.offsets.toSet();
}
await analysisFinished;
expect(currentAnalysisErrors[pathname], isEmpty);
var params = await onAnalysisOccurrences.first;
expect(params.file, equals(pathname));
var occurrences = params.occurrences;
Set<int> findOffsets(String elementName) {
for (var occurrence in occurrences) {
if (occurrence.element.name == elementName) {
return occurrence.offsets.toSet();
}
fail('No element found matching $elementName');
}
fail('No element found matching $elementName');
}
void check(String elementName, Iterable<String> expectedOccurrences) {
var expectedOffsets = expectedOccurrences
.map((String substring) => text.indexOf(substring))
.toSet();
var foundOffsets = findOffsets(elementName);
expect(foundOffsets, equals(expectedOffsets));
}
void check(String elementName, Iterable<String> expectedOccurrences) {
var expectedOffsets = expectedOccurrences
.map((String substring) => text.indexOf(substring))
.toSet();
var foundOffsets = findOffsets(elementName);
expect(foundOffsets, equals(expectedOffsets));
}
check('i', ['i = 0', 'i < 10', 'i++', 'i;']);
check('j', ['j = 0', 'j < i', 'j++', 'j;']);
check('sum', ['sum = 0', 'sum +=', 'sum)']);
});
check('i', ['i = 0', 'i < 10', 'i++', 'i;']);
check('j', ['j = 0', 'j < i', 'j++', 'j;']);
check('sum', ['sum = 0', 'sum +=', 'sum)']);
}
}
@@ -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 OutlineTest extends AbstractAnalysisServerIntegrationTest {
Future<void> test_outline() {
Future<void> test_outline() async {
var pathname = sourcePath('test.dart');
var text = r'''
class Class1 {
@@ -47,27 +45,26 @@ class Class2 {
sendAnalysisSetSubscriptions({
AnalysisService.OUTLINE: [pathname]
});
Outline outline;
onAnalysisOutline.listen((AnalysisOutlineParams params) {
expect(params.file, equals(pathname));
outline = params.outline;
});
return analysisFinished.then((_) {
expect(outline.element.kind, equals(ElementKind.COMPILATION_UNIT));
expect(outline.offset, equals(0));
expect(outline.length, equals(text.length));
var classes = outline.children;
expect(classes, hasLength(2));
expect(classes[0].element.name, equals('Class1'));
expect(classes[1].element.name, equals('Class2'));
var members = classes[0].children;
expect(members, hasLength(5));
expect(members[0].element.name, equals('field'));
expect(members[1].element.name, equals('method'));
expect(members[2].element.name, equals('staticMethod'));
expect(members[3].element.name, equals('getter'));
expect(members[4].element.name, equals('setter'));
});
var params = await onAnalysisOutline.first;
expect(params.file, equals(pathname));
var outline = params.outline;
expect(outline.element.kind, equals(ElementKind.COMPILATION_UNIT));
expect(outline.offset, equals(0));
expect(outline.length, equals(text.length));
var classes = outline.children!;
expect(classes, hasLength(2));
expect(classes[0].element.name, equals('Class1'));
expect(classes[1].element.name, equals('Class2'));
var members = classes[0].children!;
expect(members, hasLength(5));
expect(members[0].element.name, equals('field'));
expect(members[1].element.name, equals('method'));
expect(members[2].element.name, equals('staticMethod'));
expect(members[3].element.name, equals('getter'));
expect(members[4].element.name, equals('setter'));
}
}
@@ -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';
@@ -18,7 +16,7 @@ void main() {
@reflectiveTest
class OverridesTest extends AbstractAnalysisServerIntegrationTest {
Future<void> test_overrides() {
Future<void> test_overrides() async {
var pathname = sourcePath('test.dart');
var text = r'''
abstract class Interface1 {
@@ -58,67 +56,69 @@ class Target extends Base implements Interface1, Interface2 {
sendAnalysisSetSubscriptions({
AnalysisService.OVERRIDES: [pathname]
});
List<Override> overrides;
onAnalysisOverrides.listen((AnalysisOverridesParams params) {
expect(params.file, equals(pathname));
overrides = params.overrides;
});
return analysisFinished.then((_) {
var targetOffset = text.indexOf('Target');
Override findOverride(String methodName) {
var methodOffset = text.indexOf(methodName, targetOffset);
for (var override in overrides) {
if (override.offset == methodOffset) {
return override;
}
}
return null;
}
void checkOverrides(String methodName, bool expectedOverridesBase,
List<String> expectedOverridesInterfaces) {
var override = findOverride(methodName);
if (!expectedOverridesBase && expectedOverridesInterfaces.isEmpty) {
// This method overrides nothing, so it should not appear in the
// overrides list.
expect(override, isNull);
return;
} else {
expect(override, isNotNull);
}
expect(override.length, equals(methodName.length));
var superclassMember = override.superclassMember;
if (expectedOverridesBase) {
expect(superclassMember.element.name, equals(methodName));
expect(superclassMember.className, equals('Base'));
} else {
expect(superclassMember, isNull);
}
var interfaceMembers = override.interfaceMembers;
if (expectedOverridesInterfaces.isNotEmpty) {
expect(interfaceMembers, isNotNull);
var actualOverridesInterfaces = <String>{};
for (var overriddenMember in interfaceMembers) {
expect(overriddenMember.element.name, equals(methodName));
var className = overriddenMember.className;
var wasAdded = actualOverridesInterfaces.add(className);
expect(wasAdded, isTrue);
}
expect(actualOverridesInterfaces,
equals(expectedOverridesInterfaces.toSet()));
} else {
expect(interfaceMembers, isNull);
var params = await onAnalysisOverrides.first;
expect(params.file, equals(pathname));
var overrides = params.overrides;
var targetOffset = text.indexOf('Target');
Override? findOverride(String methodName) {
var methodOffset = text.indexOf(methodName, targetOffset);
for (var override in overrides) {
if (override.offset == methodOffset) {
return override;
}
}
return null;
}
checkOverrides('method0', true, ['Interface1', 'Interface2']);
checkOverrides('method1', false, ['Interface1', 'Interface2']);
checkOverrides('method2', true, ['Interface1']);
checkOverrides('method3', false, ['Interface1']);
checkOverrides('method4', true, ['Interface2']);
checkOverrides('method5', false, ['Interface2']);
checkOverrides('method6', true, []);
checkOverrides('method7', false, []);
});
void checkOverrides(String methodName, bool expectedOverridesBase,
List<String> expectedOverridesInterfaces) {
var override = findOverride(methodName);
if (!expectedOverridesBase && expectedOverridesInterfaces.isEmpty) {
// This method overrides nothing, so it should not appear in the
// overrides list.
expect(override, isNull);
return;
} else {
override!;
}
expect(override.length, equals(methodName.length));
var superclassMember = override.superclassMember;
if (expectedOverridesBase) {
superclassMember!;
expect(superclassMember.element.name, equals(methodName));
expect(superclassMember.className, equals('Base'));
} else {
expect(superclassMember, isNull);
}
var interfaceMembers = override.interfaceMembers;
if (expectedOverridesInterfaces.isNotEmpty) {
interfaceMembers!;
var actualOverridesInterfaces = <String>{};
for (var overriddenMember in interfaceMembers) {
expect(overriddenMember.element.name, equals(methodName));
var className = overriddenMember.className;
var wasAdded = actualOverridesInterfaces.add(className);
expect(wasAdded, isTrue);
}
expect(actualOverridesInterfaces,
equals(expectedOverridesInterfaces.toSet()));
} else {
expect(interfaceMembers, isNull);
}
}
checkOverrides('method0', true, ['Interface1', 'Interface2']);
checkOverrides('method1', false, ['Interface1', 'Interface2']);
checkOverrides('method2', true, ['Interface1']);
checkOverrides('method3', false, ['Interface1']);
checkOverrides('method4', true, ['Interface2']);
checkOverrides('method5', false, ['Interface2']);
checkOverrides('method6', true, []);
checkOverrides('method7', false, []);
}
}
@@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// @dart = 2.9
import 'package:analysis_server/protocol/protocol_generated.dart';
import 'package:analyzer_plugin/protocol/protocol_common.dart';
import 'package:path/path.dart' as path;
@@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// @dart = 2.9
/// This test verifies that if reanalysis is performed while reanalysis is in
/// progress, no problems occur.
///
@@ -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';
@@ -27,10 +25,9 @@ class ReanalyzeTest extends AbstractAnalysisServerIntegrationTest {
// Make sure that reanalyze causes analysis to restart.
var analysisRestarted = false;
onServerStatus.listen((ServerStatusParams data) {
if (data.analysis != null) {
if (data.analysis.isAnalyzing) {
analysisRestarted = true;
}
var analysisStatus = data.analysis;
if (analysisStatus != null && analysisStatus.isAnalyzing) {
analysisRestarted = true;
}
});
sendAnalysisReanalyze();
@@ -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/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:analysis_server/protocol/protocol_generated.dart';
import 'package:path/path.dart' show join;
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:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -26,6 +24,7 @@ class SetPriorityFilesTest extends AbstractAnalysisServerIntegrationTest {
await sendAnalysisSetPriorityFiles([pathname]);
var status = await analysisFinished;
expect(status.analysis.isAnalyzing, false);
var analysisStatus = status.analysis;
expect(analysisStatus != null && analysisStatus.isAnalyzing, false);
}
}
@@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// @dart = 2.9
import 'package: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 'analysis_options_test.dart' as analysis_options_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:analyzer_plugin/protocol/protocol_common.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:analyzer_plugin/protocol/protocol_common.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -78,7 +76,7 @@ void main() {
standardAnalysisSetup();
await analysisFinished;
expect(currentAnalysisErrors[pathname], isList);
var errors1 = currentAnalysisErrors[pathname];
var errors1 = existingErrorsForFile(pathname);
expect(errors1, hasLength(1));
expect(errors1[0].location.file, equals(pathname));
@@ -99,7 +97,7 @@ void main() {
});
await analysisFinished;
expect(currentAnalysisErrors[pathname], isList);
var errors2 = currentAnalysisErrors[pathname];
var errors2 = existingErrorsForFile(pathname);
expect(errors2, hasLength(1));
expect(errors2[0].location.file, equals(pathname));
}
@@ -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';
@@ -139,6 +139,16 @@ abstract class AbstractAnalysisServerIntegrationTest
server.debugStdio();
}
/// If there was a set of errors (might be empty) received for the file
/// with the given [path], return it. If no errors - fail.
List<AnalysisError> existingErrorsForFile(String path) {
var errors = currentAnalysisErrors[path];
if (errors == null) {
fail('Expected errors for: $path');
}
return errors;
}
List<AnalysisError>? getErrors(String pathname) =>
currentAnalysisErrors[pathname];