Skip to content

Commit 712d776

Browse files
srawlinsCommit Queue
authored andcommitted
analyzer: Deprecate AnalysisResultWithErrors in favor of AnalysisResultWithDiagnostics
Change-Id: Iddad83a42a22cef32c0e36d01a9232b71862cb98 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435360 Commit-Queue: Samuel Rawlins <[email protected]> Reviewed-by: Konstantin Shcheglov <[email protected]>
1 parent 60fecac commit 712d776

File tree

6 files changed

+26
-20
lines changed

6 files changed

+26
-20
lines changed

pkg/analysis_server/lib/src/analysis_server.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1151,7 +1151,7 @@ abstract class CommonServerContextManagerCallbacks
11511151
analysisServer.sendLspNotification(message);
11521152
}
11531153

1154-
if (result is AnalysisResultWithErrors) {
1154+
if (result is AnalysisResultWithDiagnostics) {
11551155
if (analysisServer.isAnalyzed(path)) {
11561156
var serverErrors = server.doAnalysisError_listFromEngine(result);
11571157
recordAnalysisErrors(path, serverErrors);

pkg/analysis_server/lib/src/protocol_server.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export 'package:analyzer_plugin/protocol/protocol_common.dart';
3232
/// Returns a list of AnalysisErrors corresponding to the given list of Engine
3333
/// errors.
3434
List<AnalysisError> doAnalysisError_listFromEngine(
35-
engine.AnalysisResultWithErrors result,
35+
engine.AnalysisResultWithDiagnostics result,
3636
) {
3737
return mapEngineErrors(
3838
result,
@@ -111,10 +111,10 @@ String? getReturnTypeString(engine.Element element) {
111111

112112
/// Translates engine errors through the ErrorProcessor.
113113
List<T> mapEngineErrors<T>(
114-
engine.AnalysisResultWithErrors result,
114+
engine.AnalysisResultWithDiagnostics result,
115115
List<engine.Diagnostic> diagnostics,
116116
T Function(
117-
engine.AnalysisResultWithErrors result,
117+
engine.AnalysisResultWithDiagnostics result,
118118
engine.Diagnostic diagnostic, [
119119
engine.DiagnosticSeverity severity,
120120
])
@@ -144,7 +144,7 @@ List<T> mapEngineErrors<T>(
144144
/// If an [diagnosticSeverity] is specified, it will override the one in
145145
/// [diagnostic].
146146
AnalysisError newAnalysisError_fromEngine(
147-
engine.AnalysisResultWithErrors result,
147+
engine.AnalysisResultWithDiagnostics result,
148148
engine.Diagnostic diagnostic, [
149149
engine.DiagnosticSeverity? diagnosticSeverity,
150150
]) {
@@ -212,7 +212,7 @@ AnalysisError newAnalysisError_fromEngine(
212212

213213
/// Create a DiagnosticMessage based on an [engine.DiagnosticMessage].
214214
DiagnosticMessage newDiagnosticMessage(
215-
engine.AnalysisResultWithErrors result,
215+
engine.AnalysisResultWithDiagnostics result,
216216
engine.DiagnosticMessage message,
217217
) {
218218
var file = message.filePath;

pkg/analyzer/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
* Deprecate `RecordingErrorListener.errors`; use
2323
`RecordingDiagnosticListener.diagnostics` instead.
2424
* Deprecate `RecordingErrorListener.getErrorsForSource`; no longer supported.
25+
* Deprecate `AnalysisResultWithErrors`; use `AnalysisResultWithDiagnostics`
26+
instead.
2527
* Deprecate `AnalysisResultWithErrors.errors`; use
2628
`AnalysisResultWithErrors.diagnostics` instead.
2729
* Deprecate `ErrorType`; use `DiagnosticType` instead.

pkg/analyzer/api.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -444,8 +444,8 @@ package:analyzer/dart/analysis/results.dart:
444444
AnalysisResult (class extends Object):
445445
new (constructor: AnalysisResult Function())
446446
session (getter: AnalysisSession)
447-
AnalysisResultWithErrors (class extends Object implements FileResult):
448-
new (constructor: AnalysisResultWithErrors Function())
447+
AnalysisResultWithDiagnostics (class extends Object implements FileResult):
448+
new (constructor: AnalysisResultWithDiagnostics Function())
449449
diagnostics (getter: List<Diagnostic>)
450450
errors (getter: List<Diagnostic>, deprecated)
451451
CannotResolveUriResult (class extends Object implements InvalidResult, SomeLibraryElementResult, SomeParsedLibraryResult, SomeResolvedLibraryResult):
@@ -458,7 +458,7 @@ package:analyzer/dart/analysis/results.dart:
458458
node (getter: AstNode)
459459
parsedUnit (getter: ParsedUnitResult?)
460460
resolvedUnit (getter: ResolvedUnitResult?)
461-
ErrorsResult (class extends Object implements SomeErrorsResult, AnalysisResultWithErrors):
461+
ErrorsResult (class extends Object implements SomeErrorsResult, AnalysisResultWithDiagnostics):
462462
new (constructor: ErrorsResult Function())
463463
FileResult (class extends Object implements SomeFileResult, AnalysisResult):
464464
new (constructor: FileResult Function())
@@ -500,7 +500,7 @@ package:analyzer/dart/analysis/results.dart:
500500
units (getter: List<ParsedUnitResult>)
501501
getElementDeclaration2 (method: ElementDeclarationResult? Function(Fragment), deprecated, experimental)
502502
getFragmentDeclaration (method: FragmentDeclarationResult? Function(Fragment), experimental)
503-
ParsedUnitResult (class extends Object implements SomeParsedUnitResult, AnalysisResultWithErrors):
503+
ParsedUnitResult (class extends Object implements SomeParsedUnitResult, AnalysisResultWithDiagnostics):
504504
new (constructor: ParsedUnitResult Function())
505505
unit (getter: CompilationUnit)
506506
ResolvedLibraryResult (class extends Object implements ParsedLibraryResult, SomeResolvedLibraryResult):
@@ -539,6 +539,7 @@ package:analyzer/dart/analysis/results.dart:
539539
new (constructor: UnspecifiedInvalidResult Function())
540540
UriOfExternalLibraryResult (class extends Object implements InvalidResult, SomeParsedLibraryResult, SomeResolvedLibraryResult):
541541
new (constructor: UriOfExternalLibraryResult Function())
542+
AnalysisResultWithErrors (type alias for AnalysisResultWithDiagnostics, deprecated)
542543
package:analyzer/dart/analysis/session.dart:
543544
AnalysisSession (class extends Object):
544545
new (constructor: AnalysisSession Function())

pkg/analyzer/lib/dart/analysis/results.dart

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ import 'package:analyzer/file_system/file_system.dart';
1313
import 'package:analyzer/source/line_info.dart';
1414
import 'package:meta/meta.dart';
1515

16+
@Deprecated('Use AnalysisResultWithDiagnostics instead')
17+
typedef AnalysisResultWithErrors = AnalysisResultWithDiagnostics;
18+
1619
/// The result of performing some kind of analysis on a single file. Every
1720
/// result that implements this interface will also implement a sub-interface.
1821
///
@@ -22,10 +25,10 @@ abstract class AnalysisResult {
2225
AnalysisSession get session;
2326
}
2427

25-
/// An analysis result that includes the errors computed during analysis.
28+
/// An analysis result that includes the diagnostics computed during analysis.
2629
///
2730
/// Clients may not extend, implement or mix-in this class.
28-
abstract class AnalysisResultWithErrors implements FileResult {
31+
abstract class AnalysisResultWithDiagnostics implements FileResult {
2932
/// The diagnostics that were computed during analysis.
3033
List<Diagnostic> get diagnostics;
3134

@@ -83,7 +86,7 @@ abstract class ElementDeclarationResult {
8386
///
8487
/// Clients may not extend, implement or mix-in this class.
8588
abstract class ErrorsResult
86-
implements SomeErrorsResult, AnalysisResultWithErrors {}
89+
implements SomeErrorsResult, AnalysisResultWithDiagnostics {}
8790

8891
/// The result of computing some cheap information for a single file, when full
8992
/// parsed file is not required, so [ParsedUnitResult] is not necessary.
@@ -239,7 +242,7 @@ abstract class ParsedLibraryResult
239242
///
240243
/// Clients may not extend, implement or mix-in this class.
241244
abstract class ParsedUnitResult
242-
implements SomeParsedUnitResult, AnalysisResultWithErrors {
245+
implements SomeParsedUnitResult, AnalysisResultWithDiagnostics {
243246
/// The parsed, unresolved compilation unit for the [content].
244247
CompilationUnit get unit;
245248
}

pkg/analyzer/lib/src/dart/analysis/driver.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,9 +1583,9 @@ class AnalysisDriver {
15831583
events.GetErrorsFromBytes(file: file, library: library),
15841584
);
15851585
var unit = AnalysisDriverResolvedUnit.fromBuffer(bytes);
1586-
var errors = _getDiagnosticsFromSerialized(file, unit.errors);
1587-
_updateHasErrorOrWarningFlag(file, errors);
1588-
var result = _createErrorsResultImpl(file: file, diagnostics: errors);
1586+
var diagnostics = _getDiagnosticsFromSerialized(file, unit.errors);
1587+
_updateHasErrorOrWarningFlag(file, diagnostics);
1588+
var result = _createErrorsResultImpl(file: file, diagnostics: diagnostics);
15891589
return result;
15901590
}
15911591

@@ -1694,9 +1694,9 @@ class AnalysisDriver {
16941694
) {
16951695
List<Diagnostic> diagnostics = <Diagnostic>[];
16961696
for (AnalysisDriverUnitError error in serialized) {
1697-
var analysisError = ErrorEncoding.decode(file.source, error);
1698-
if (analysisError != null) {
1699-
diagnostics.add(analysisError);
1697+
var diagnostic = ErrorEncoding.decode(file.source, error);
1698+
if (diagnostic != null) {
1699+
diagnostics.add(diagnostic);
17001700
}
17011701
}
17021702
return diagnostics;

0 commit comments

Comments
 (0)