Skip to content

Commit 952d768

Browse files
srawlinsCommit Queue
authored andcommitted
analyzer_testing: Add comment about awaiting various APIs.
Change-Id: I8761223d45756ddea4ed21c59530239b8414855e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/451122 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Samuel Rawlins <[email protected]>
1 parent eb938ee commit 952d768

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

pkg/analyzer_testing/lib/analysis_rule/analysis_rule.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
/// @docImport 'package:analyzer/dart/analysis/results.dart';
6+
library;
7+
58
import 'dart:convert' show json;
69

710
import 'package:analyzer/analysis_rule/analysis_rule.dart';
@@ -32,13 +35,19 @@ abstract class AnalysisRuleTest extends PubPackageResolutionTest {
3235
String get analysisRule;
3336

3437
/// Asserts that no diagnostics are reported when resolving [content].
38+
///
39+
/// Note: Be sure to `await` any use of this API, to avoid stale analysis
40+
/// results (See [DisposedAnalysisContextResult]).
3541
Future<void> assertNoPubspecDiagnostics(String content) async {
3642
newFile(testPackagePubspecPath, content);
3743
var errors = await _analyzePubspecFile(content);
3844
assertDiagnosticsIn(errors, []);
3945
}
4046

4147
/// Asserts that [expectedDiagnostics] are reported when resolving [content].
48+
///
49+
/// Note: Be sure to `await` any use of this API, to avoid stale analysis
50+
/// results (See [DisposedAnalysisContextResult]).
4251
Future<void> assertPubspecDiagnostics(
4352
String content,
4453
List<ExpectedDiagnostic> expectedDiagnostics,

pkg/analyzer_testing/lib/src/analysis_rule/pub_package_resolution.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,9 @@ class PubPackageResolutionTest with MockPackagesMixin, ResourceProviderMixin {
195195
/// descriptions and locations.
196196
///
197197
/// The order in which the diagnostics were gathered is ignored.
198+
///
199+
/// Note: Be sure to `await` any use of this API, to avoid stale analysis
200+
/// results (See [DisposedAnalysisContextResult]).
198201
Future<void> assertDiagnostics(
199202
String content,
200203
List<ExpectedDiagnostic> expectedDiagnostics,
@@ -205,6 +208,9 @@ class PubPackageResolutionTest with MockPackagesMixin, ResourceProviderMixin {
205208
}
206209

207210
/// Asserts that the diagnostics in [diagnostics] match [expectedDiagnostics].
211+
///
212+
/// Note: Be sure to `await` any use of this API, to avoid stale analysis
213+
/// results (See [DisposedAnalysisContextResult]).
208214
void assertDiagnosticsIn(
209215
List<Diagnostic> diagnostics,
210216
List<ExpectedDiagnostic> expectedDiagnostics,
@@ -269,6 +275,9 @@ class PubPackageResolutionTest with MockPackagesMixin, ResourceProviderMixin {
269275
/// expected error descriptions and locations.
270276
///
271277
/// The order in which the diagnostics were gathered is ignored.
278+
///
279+
/// Note: Be sure to `await` any use of this API, to avoid stale analysis
280+
/// results (See [DisposedAnalysisContextResult]).
272281
Future<void> assertDiagnosticsInFile(
273282
String path,
274283
List<ExpectedDiagnostic> expectedDiagnostics,
@@ -282,6 +291,9 @@ class PubPackageResolutionTest with MockPackagesMixin, ResourceProviderMixin {
282291
///
283292
/// The unit at each path needs to have already been written to the file
284293
/// system before calling this method.
294+
///
295+
/// Note: Be sure to `await` any use of this API, to avoid stale analysis
296+
/// results (See [DisposedAnalysisContextResult]).
285297
Future<void> assertDiagnosticsInUnits(
286298
List<(String path, List<ExpectedDiagnostic> expectedDiagnostics)>
287299
unitsAndDiagnostics,
@@ -293,10 +305,16 @@ class PubPackageResolutionTest with MockPackagesMixin, ResourceProviderMixin {
293305
}
294306

295307
/// Asserts that there are no diagnostics in the given [content].
308+
///
309+
/// Note: Be sure to `await` any use of this API, to avoid stale analysis
310+
/// results (See [DisposedAnalysisContextResult]).
296311
Future<void> assertNoDiagnostics(String content) async =>
297312
assertDiagnostics(content, const []);
298313

299314
/// Asserts that there are no diagnostics in the file at the given [path].
315+
///
316+
/// Note: Be sure to `await` any use of this API, to avoid stale analysis
317+
/// results (See [DisposedAnalysisContextResult]).
300318
Future<void> assertNoDiagnosticsInFile(String path) async =>
301319
assertDiagnosticsInFile(path, const []);
302320

0 commit comments

Comments
 (0)