analyzer: Deprecate ErrorType in favor of new name, DiagnosticType
Change-Id: I552e816de6d526e3476cac9dd3ee2919fc7ec499 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425720 Commit-Queue: Samuel Rawlins <srawlins@google.com> Reviewed-by: Paul Berry <paulberry@google.com> Reviewed-by: Kevin Moore <kevmoo@google.com>
This commit is contained in:
committed by
Commit Queue
parent
0fe2a31b2a
commit
35e8b9ba0b
@@ -110,7 +110,7 @@ abstract class ErrorCode {
|
||||
/**
|
||||
* The type of the error.
|
||||
*/
|
||||
ErrorType get type;
|
||||
DiagnosticType get type;
|
||||
|
||||
/**
|
||||
* Return a URL that can be used to access documentation for diagnostics with
|
||||
@@ -207,66 +207,67 @@ class ErrorSeverity implements Comparable<ErrorSeverity> {
|
||||
String toString() => name;
|
||||
}
|
||||
|
||||
/// The type of a [DiagnosticCode].
|
||||
@AnalyzerPublicApi(message: 'exported by package:analyzer/error/error.dart')
|
||||
typedef DiagnosticType = ErrorType;
|
||||
@Deprecated("Use 'DiagnosticType' instead.")
|
||||
typedef ErrorType = DiagnosticType;
|
||||
|
||||
/**
|
||||
* The type of an [ErrorCode].
|
||||
*
|
||||
* Note that this class name, `ErrorType`, is soft-deprecated in favor of
|
||||
* the type alias, [DiagnosticType].
|
||||
* The type of a [DiagnosticCode].
|
||||
*/
|
||||
@AnalyzerPublicApi(message: 'exported by package:analyzer/error/error.dart')
|
||||
class ErrorType implements Comparable<ErrorType> {
|
||||
class DiagnosticType implements Comparable<DiagnosticType> {
|
||||
/**
|
||||
* Task (todo) comments in user code.
|
||||
*/
|
||||
static const ErrorType TODO = const ErrorType('TODO', 0, ErrorSeverity.INFO);
|
||||
static const DiagnosticType TODO =
|
||||
const DiagnosticType('TODO', 0, ErrorSeverity.INFO);
|
||||
|
||||
/**
|
||||
* Extra analysis run over the code to follow best practices, which are not in
|
||||
* the Dart Language Specification.
|
||||
*/
|
||||
static const ErrorType HINT = const ErrorType('HINT', 1, ErrorSeverity.INFO);
|
||||
static const DiagnosticType HINT =
|
||||
const DiagnosticType('HINT', 1, ErrorSeverity.INFO);
|
||||
|
||||
/**
|
||||
* Compile-time errors are errors that preclude execution. A compile time
|
||||
* error must be reported by a Dart compiler before the erroneous code is
|
||||
* executed.
|
||||
*/
|
||||
static const ErrorType COMPILE_TIME_ERROR =
|
||||
const ErrorType('COMPILE_TIME_ERROR', 2, ErrorSeverity.ERROR);
|
||||
static const DiagnosticType COMPILE_TIME_ERROR =
|
||||
const DiagnosticType('COMPILE_TIME_ERROR', 2, ErrorSeverity.ERROR);
|
||||
|
||||
/**
|
||||
* Checked mode compile-time errors are errors that preclude execution in
|
||||
* checked mode.
|
||||
*/
|
||||
static const ErrorType CHECKED_MODE_COMPILE_TIME_ERROR = const ErrorType(
|
||||
'CHECKED_MODE_COMPILE_TIME_ERROR', 3, ErrorSeverity.ERROR);
|
||||
static const DiagnosticType CHECKED_MODE_COMPILE_TIME_ERROR =
|
||||
const DiagnosticType(
|
||||
'CHECKED_MODE_COMPILE_TIME_ERROR', 3, ErrorSeverity.ERROR);
|
||||
|
||||
/**
|
||||
* Static warnings are those warnings reported by the static checker. They
|
||||
* have no effect on execution. Static warnings must be provided by Dart
|
||||
* compilers used during development.
|
||||
*/
|
||||
static const ErrorType STATIC_WARNING =
|
||||
const ErrorType('STATIC_WARNING', 4, ErrorSeverity.WARNING);
|
||||
static const DiagnosticType STATIC_WARNING =
|
||||
const DiagnosticType('STATIC_WARNING', 4, ErrorSeverity.WARNING);
|
||||
|
||||
/**
|
||||
* Syntactic errors are errors produced as a result of input that does not
|
||||
* conform to the grammar.
|
||||
*/
|
||||
static const ErrorType SYNTACTIC_ERROR =
|
||||
const ErrorType('SYNTACTIC_ERROR', 6, ErrorSeverity.ERROR);
|
||||
static const DiagnosticType SYNTACTIC_ERROR =
|
||||
const DiagnosticType('SYNTACTIC_ERROR', 6, ErrorSeverity.ERROR);
|
||||
|
||||
/**
|
||||
* Lint warnings describe style and best practice recommendations that can be
|
||||
* used to formalize a project's style guidelines.
|
||||
*/
|
||||
static const ErrorType LINT = const ErrorType('LINT', 7, ErrorSeverity.INFO);
|
||||
static const DiagnosticType LINT =
|
||||
const DiagnosticType('LINT', 7, ErrorSeverity.INFO);
|
||||
|
||||
static const List<ErrorType> values = const [
|
||||
static const List<DiagnosticType> values = const [
|
||||
TODO,
|
||||
HINT,
|
||||
COMPILE_TIME_ERROR,
|
||||
@@ -295,7 +296,7 @@ class ErrorType implements Comparable<ErrorType> {
|
||||
* Initialize a newly created error type to have the given [name] and
|
||||
* [severity].
|
||||
*/
|
||||
const ErrorType(this.name, this.ordinal, this.severity);
|
||||
const DiagnosticType(this.name, this.ordinal, this.severity);
|
||||
|
||||
String get displayName => name.toLowerCase().replaceAll('_', ' ');
|
||||
|
||||
@@ -303,7 +304,7 @@ class ErrorType implements Comparable<ErrorType> {
|
||||
int get hashCode => ordinal;
|
||||
|
||||
@override
|
||||
int compareTo(ErrorType other) => ordinal - other.ordinal;
|
||||
int compareTo(DiagnosticType other) => ordinal - other.ordinal;
|
||||
|
||||
@override
|
||||
String toString() => name;
|
||||
|
||||
@@ -205,5 +205,5 @@ class ScannerErrorCode extends ErrorCode {
|
||||
ErrorSeverity get errorSeverity => ErrorSeverity.ERROR;
|
||||
|
||||
@override
|
||||
ErrorType get type => ErrorType.SYNTACTIC_ERROR;
|
||||
DiagnosticType get type => DiagnosticType.SYNTACTIC_ERROR;
|
||||
}
|
||||
|
||||
@@ -1394,7 +1394,7 @@ class LspServerContextManagerCallbacks
|
||||
|
||||
bool _shouldSendError(protocol.AnalysisError error) {
|
||||
// Non-TODOs are always shown.
|
||||
if (error.type.name != ErrorType.TODO.name) {
|
||||
if (error.type.name != DiagnosticType.TODO.name) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -331,7 +331,7 @@ class AddDiagnosticPropertyReference extends ResolvedCorrectionProducer {
|
||||
var endOffset = startOffset + declaration.length;
|
||||
for (var error in unitResult.errors) {
|
||||
var errorCode = error.errorCode;
|
||||
if (errorCode.type == ErrorType.LINT &&
|
||||
if (errorCode.type == DiagnosticType.LINT &&
|
||||
errorCode == LinterLintCode.diagnostic_describe_all_properties &&
|
||||
error.offset > startOffset &&
|
||||
error.offset < endOffset) {
|
||||
|
||||
+1
-1
@@ -120,7 +120,7 @@ class ReplaceWithDecoratedBox extends ResolvedCorrectionProducer {
|
||||
var constructorName = expression.constructorName;
|
||||
return unitResult.errors.any((error) {
|
||||
var errorCode = error.errorCode;
|
||||
return errorCode.type == ErrorType.LINT &&
|
||||
return errorCode.type == DiagnosticType.LINT &&
|
||||
errorCode == LinterLintCode.use_decorated_box &&
|
||||
error.offset == constructorName.offset &&
|
||||
error.length == constructorName.length;
|
||||
|
||||
+1
-1
@@ -191,5 +191,5 @@ class TransformSetErrorCode extends DiagnosticCode {
|
||||
ErrorSeverity get errorSeverity => ErrorSeverity.ERROR;
|
||||
|
||||
@override
|
||||
ErrorType get type => ErrorType.COMPILE_TIME_ERROR;
|
||||
DiagnosticType get type => DiagnosticType.COMPILE_TIME_ERROR;
|
||||
}
|
||||
|
||||
@@ -236,8 +236,8 @@ class EnumTest {
|
||||
}
|
||||
|
||||
void test_AnalysisErrorType() {
|
||||
EnumTester<engine.ErrorType, AnalysisErrorType>().run(
|
||||
(engine.ErrorType engineErrorType) =>
|
||||
EnumTester<engine.DiagnosticType, AnalysisErrorType>().run(
|
||||
(engine.DiagnosticType engineErrorType) =>
|
||||
AnalysisErrorType.values.byName(engineErrorType.name),
|
||||
);
|
||||
}
|
||||
@@ -387,7 +387,7 @@ class MockAnalysisError implements engine.AnalysisError {
|
||||
|
||||
class MockDiagnosticCode implements engine.DiagnosticCode {
|
||||
@override
|
||||
engine.ErrorType type;
|
||||
engine.DiagnosticType type;
|
||||
|
||||
@override
|
||||
engine.ErrorSeverity errorSeverity;
|
||||
@@ -399,7 +399,7 @@ class MockDiagnosticCode implements engine.DiagnosticCode {
|
||||
String? url;
|
||||
|
||||
MockDiagnosticCode({
|
||||
this.type = engine.ErrorType.COMPILE_TIME_ERROR,
|
||||
this.type = engine.DiagnosticType.COMPILE_TIME_ERROR,
|
||||
this.errorSeverity = engine.ErrorSeverity.ERROR,
|
||||
this.name = 'TEST_ERROR',
|
||||
this.url,
|
||||
|
||||
+4
-4
@@ -487,7 +487,7 @@ void f(List<int> list) {
|
||||
}
|
||||
''');
|
||||
await assertNoFix(
|
||||
errorFilter: (error) => error.errorCode.type == ErrorType.LINT,
|
||||
errorFilter: (error) => error.errorCode.type == DiagnosticType.LINT,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -498,7 +498,7 @@ void f(List<int> list) {
|
||||
}
|
||||
''');
|
||||
await assertNoFix(
|
||||
errorFilter: (error) => error.errorCode.type == ErrorType.LINT,
|
||||
errorFilter: (error) => error.errorCode.type == DiagnosticType.LINT,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -509,7 +509,7 @@ void f(List<int> list, bool b) {
|
||||
}
|
||||
''');
|
||||
await assertNoFix(
|
||||
errorFilter: (error) => error.errorCode.type == ErrorType.LINT,
|
||||
errorFilter: (error) => error.errorCode.type == DiagnosticType.LINT,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -525,6 +525,6 @@ void f(List<int> list) {
|
||||
<int>{x};
|
||||
}
|
||||
}
|
||||
''', errorFilter: (error) => error.errorCode.type == ErrorType.LINT);
|
||||
''', errorFilter: (error) => error.errorCode.type == DiagnosticType.LINT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,8 @@ Future<void> main() async {
|
||||
|
||||
var hintEntries = registeredFixGenerators.nonLintProducers.entries.where(
|
||||
(e) =>
|
||||
e.key.type == ErrorType.HINT || e.key.type == ErrorType.STATIC_WARNING,
|
||||
e.key.type == DiagnosticType.HINT ||
|
||||
e.key.type == DiagnosticType.STATIC_WARNING,
|
||||
);
|
||||
|
||||
var diagnostics = [
|
||||
|
||||
@@ -3,11 +3,12 @@
|
||||
* Remove deprecated `DartType.isStructurallyEqualTo`.
|
||||
* Remove deprecated `RecordType.positionalTypes`.
|
||||
* Remove deprecated `RecordType.sortedNamedTypes`.
|
||||
* Remove `ElementLocation` class, its values are not returned anymore.
|
||||
* Deprecated `element2.dart` library, import `element.dart`.
|
||||
* Deprecated `XyzElement2` classes, use `XyzElement` instead.
|
||||
* Remove `ElementLocation` class; its values are not returned anymore.
|
||||
* Deprecate `element2.dart` library; import `element.dart`.
|
||||
* Deprecate `XyzElement2` classes; use `XyzElement` instead.
|
||||
* Deprecate `AnalysisError.correction` field; use
|
||||
`AnalysisError.correctionMessage` instead.
|
||||
* Deprecate `ErrorType`; use `DiagnosticType` instead.
|
||||
|
||||
## 7.4.1
|
||||
* Restore `InstanceElement.augmented` getter.
|
||||
|
||||
+20
-20
@@ -4364,6 +4364,23 @@ package:analyzer/error/error.dart:
|
||||
source (getter: Source)
|
||||
== (method: bool Function(Object))
|
||||
toString (method: String Function())
|
||||
DiagnosticType (class extends Object implements Comparable<DiagnosticType>):
|
||||
CHECKED_MODE_COMPILE_TIME_ERROR (static getter: DiagnosticType)
|
||||
COMPILE_TIME_ERROR (static getter: DiagnosticType)
|
||||
HINT (static getter: DiagnosticType)
|
||||
LINT (static getter: DiagnosticType)
|
||||
STATIC_WARNING (static getter: DiagnosticType)
|
||||
SYNTACTIC_ERROR (static getter: DiagnosticType)
|
||||
TODO (static getter: DiagnosticType)
|
||||
values (static getter: List<DiagnosticType>)
|
||||
new (constructor: DiagnosticType Function(String, int, ErrorSeverity))
|
||||
displayName (getter: String)
|
||||
hashCode (getter: int)
|
||||
name (getter: String)
|
||||
ordinal (getter: int)
|
||||
severity (getter: ErrorSeverity)
|
||||
compareTo (method: int Function(DiagnosticType))
|
||||
toString (method: String Function())
|
||||
ErrorCode (class extends Object):
|
||||
new (constructor: ErrorCode Function({String? correctionMessage, bool hasPublishedDocs, bool isUnresolvedIdentifier, required String name, required String problemMessage, required String uniqueName}))
|
||||
correctionMessage (getter: String?)
|
||||
@@ -4374,7 +4391,7 @@ package:analyzer/error/error.dart:
|
||||
name (getter: String)
|
||||
numParameters (getter: int)
|
||||
problemMessage (getter: String)
|
||||
type (getter: ErrorType)
|
||||
type (getter: DiagnosticType)
|
||||
uniqueName (getter: String)
|
||||
url (getter: String?)
|
||||
toString (method: String Function())
|
||||
@@ -4393,33 +4410,16 @@ package:analyzer/error/error.dart:
|
||||
compareTo (method: int Function(ErrorSeverity))
|
||||
max (method: ErrorSeverity Function(ErrorSeverity))
|
||||
toString (method: String Function())
|
||||
ErrorType (class extends Object implements Comparable<ErrorType>):
|
||||
CHECKED_MODE_COMPILE_TIME_ERROR (static getter: ErrorType)
|
||||
COMPILE_TIME_ERROR (static getter: ErrorType)
|
||||
HINT (static getter: ErrorType)
|
||||
LINT (static getter: ErrorType)
|
||||
STATIC_WARNING (static getter: ErrorType)
|
||||
SYNTACTIC_ERROR (static getter: ErrorType)
|
||||
TODO (static getter: ErrorType)
|
||||
values (static getter: List<ErrorType>)
|
||||
new (constructor: ErrorType Function(String, int, ErrorSeverity))
|
||||
displayName (getter: String)
|
||||
hashCode (getter: int)
|
||||
name (getter: String)
|
||||
ordinal (getter: int)
|
||||
severity (getter: ErrorSeverity)
|
||||
compareTo (method: int Function(ErrorType))
|
||||
toString (method: String Function())
|
||||
LintCode (class extends ErrorCode):
|
||||
new (constructor: LintCode Function(String, String, {String? correctionMessage, bool hasPublishedDocs, String? uniqueName}))
|
||||
errorSeverity (getter: ErrorSeverity)
|
||||
hashCode (getter: int)
|
||||
type (getter: ErrorType)
|
||||
type (getter: DiagnosticType)
|
||||
url (getter: String?)
|
||||
== (method: bool Function(Object))
|
||||
DiagnosticCode (type alias for ErrorCode)
|
||||
DiagnosticSeverity (type alias for ErrorSeverity)
|
||||
DiagnosticType (type alias for ErrorType)
|
||||
ErrorType (type alias for DiagnosticType, deprecated)
|
||||
package:analyzer/error/listener.dart:
|
||||
AnalysisErrorListener (class extends Object):
|
||||
NULL_LISTENER (static getter: AnalysisErrorListener)
|
||||
|
||||
@@ -36,7 +36,7 @@ void main(List<String> args) async {
|
||||
var errorsResult = await context.currentSession.getErrors(filePath);
|
||||
if (errorsResult is ErrorsResult) {
|
||||
for (var error in errorsResult.errors) {
|
||||
if (error.errorCode.type != ErrorType.TODO) {
|
||||
if (error.errorCode.type != DiagnosticType.TODO) {
|
||||
print(
|
||||
' \u001b[1m${error.source.shortName}\u001b[0m ${error.message}',
|
||||
);
|
||||
|
||||
@@ -18,6 +18,8 @@ export 'package:_fe_analyzer_shared/src/base/errors.dart'
|
||||
DiagnosticType,
|
||||
ErrorCode,
|
||||
ErrorSeverity,
|
||||
// Continue exporting the deleted element until it is removed.
|
||||
// ignore: deprecated_member_use
|
||||
ErrorType;
|
||||
export 'package:analyzer/src/dart/error/lint_codes.dart' show LintCode;
|
||||
export 'package:analyzer/src/error/error_code_values.g.dart';
|
||||
|
||||
@@ -62,7 +62,7 @@ class AnalysisOptionsErrorCode extends ErrorCode {
|
||||
ErrorSeverity get errorSeverity => ErrorSeverity.ERROR;
|
||||
|
||||
@override
|
||||
ErrorType get type => ErrorType.COMPILE_TIME_ERROR;
|
||||
DiagnosticType get type => DiagnosticType.COMPILE_TIME_ERROR;
|
||||
}
|
||||
|
||||
class AnalysisOptionsWarningCode extends ErrorCode {
|
||||
@@ -326,5 +326,5 @@ class AnalysisOptionsWarningCode extends ErrorCode {
|
||||
ErrorSeverity get errorSeverity => ErrorSeverity.WARNING;
|
||||
|
||||
@override
|
||||
ErrorType get type => ErrorType.STATIC_WARNING;
|
||||
DiagnosticType get type => DiagnosticType.STATIC_WARNING;
|
||||
}
|
||||
|
||||
@@ -536,8 +536,8 @@ class FfiCode extends ErrorCode {
|
||||
);
|
||||
|
||||
@override
|
||||
ErrorSeverity get errorSeverity => ErrorType.COMPILE_TIME_ERROR.severity;
|
||||
ErrorSeverity get errorSeverity => DiagnosticType.COMPILE_TIME_ERROR.severity;
|
||||
|
||||
@override
|
||||
ErrorType get type => ErrorType.COMPILE_TIME_ERROR;
|
||||
DiagnosticType get type => DiagnosticType.COMPILE_TIME_ERROR;
|
||||
}
|
||||
|
||||
@@ -121,8 +121,8 @@ class HintCode extends ErrorCode {
|
||||
);
|
||||
|
||||
@override
|
||||
ErrorSeverity get errorSeverity => ErrorType.HINT.severity;
|
||||
ErrorSeverity get errorSeverity => DiagnosticType.HINT.severity;
|
||||
|
||||
@override
|
||||
ErrorType get type => ErrorType.HINT;
|
||||
DiagnosticType get type => DiagnosticType.HINT;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ class LintCode extends ErrorCode {
|
||||
int get hashCode => uniqueName.hashCode;
|
||||
|
||||
@override
|
||||
ErrorType get type => ErrorType.LINT;
|
||||
DiagnosticType get type => DiagnosticType.LINT;
|
||||
|
||||
@override
|
||||
String? get url => null;
|
||||
|
||||
@@ -2075,5 +2075,5 @@ class ParserErrorCode extends ErrorCode {
|
||||
ErrorSeverity get errorSeverity => ErrorSeverity.ERROR;
|
||||
|
||||
@override
|
||||
ErrorType get type => ErrorType.SYNTACTIC_ERROR;
|
||||
DiagnosticType get type => DiagnosticType.SYNTACTIC_ERROR;
|
||||
}
|
||||
|
||||
@@ -89,5 +89,5 @@ class TodoCode extends ErrorCode {
|
||||
ErrorSeverity get errorSeverity => ErrorSeverity.INFO;
|
||||
|
||||
@override
|
||||
ErrorType get type => ErrorType.TODO;
|
||||
DiagnosticType get type => DiagnosticType.TODO;
|
||||
}
|
||||
|
||||
@@ -6060,10 +6060,10 @@ class CompileTimeErrorCode extends ErrorCode {
|
||||
);
|
||||
|
||||
@override
|
||||
ErrorSeverity get errorSeverity => ErrorType.COMPILE_TIME_ERROR.severity;
|
||||
ErrorSeverity get errorSeverity => DiagnosticType.COMPILE_TIME_ERROR.severity;
|
||||
|
||||
@override
|
||||
ErrorType get type => ErrorType.COMPILE_TIME_ERROR;
|
||||
DiagnosticType get type => DiagnosticType.COMPILE_TIME_ERROR;
|
||||
}
|
||||
|
||||
class StaticWarningCode extends ErrorCode {
|
||||
@@ -6192,7 +6192,7 @@ class StaticWarningCode extends ErrorCode {
|
||||
ErrorSeverity get errorSeverity => ErrorSeverity.WARNING;
|
||||
|
||||
@override
|
||||
ErrorType get type => ErrorType.STATIC_WARNING;
|
||||
DiagnosticType get type => DiagnosticType.STATIC_WARNING;
|
||||
}
|
||||
|
||||
class WarningCode extends ErrorCode {
|
||||
@@ -7782,5 +7782,5 @@ class WarningCode extends ErrorCode {
|
||||
ErrorSeverity get errorSeverity => ErrorSeverity.WARNING;
|
||||
|
||||
@override
|
||||
ErrorType get type => ErrorType.STATIC_WARNING;
|
||||
DiagnosticType get type => DiagnosticType.STATIC_WARNING;
|
||||
}
|
||||
|
||||
@@ -65,9 +65,9 @@ class IgnoredDiagnosticType implements IgnoredElement {
|
||||
bool _matches(ErrorCode errorCode, {String? pluginName}) {
|
||||
// Ignore 'pluginName'; it is irrelevant in an IgnoredDiagnosticType.
|
||||
return switch (errorCode.type) {
|
||||
ErrorType.HINT => type == 'hint',
|
||||
ErrorType.LINT => type == 'lint',
|
||||
ErrorType.STATIC_WARNING => type == 'warning',
|
||||
DiagnosticType.HINT => type == 'hint',
|
||||
DiagnosticType.LINT => type == 'lint',
|
||||
DiagnosticType.STATIC_WARNING => type == 'warning',
|
||||
// Only errors with one of the above types can be ignored via the type.
|
||||
_ => false,
|
||||
};
|
||||
|
||||
@@ -130,5 +130,5 @@ class ManifestWarningCode extends ErrorCode {
|
||||
ErrorSeverity get errorSeverity => ErrorSeverity.WARNING;
|
||||
|
||||
@override
|
||||
ErrorType get type => ErrorType.STATIC_WARNING;
|
||||
DiagnosticType get type => DiagnosticType.STATIC_WARNING;
|
||||
}
|
||||
|
||||
@@ -265,5 +265,5 @@ class PubspecWarningCode extends ErrorCode {
|
||||
ErrorSeverity get errorSeverity => ErrorSeverity.WARNING;
|
||||
|
||||
@override
|
||||
ErrorType get type => ErrorType.STATIC_WARNING;
|
||||
DiagnosticType get type => DiagnosticType.STATIC_WARNING;
|
||||
}
|
||||
|
||||
@@ -48,8 +48,8 @@ class MockSdkTest extends PubPackageResolutionTest {
|
||||
resolvedUnit.errors
|
||||
.where(
|
||||
(element) =>
|
||||
element.errorCode.type != ErrorType.HINT &&
|
||||
element.errorCode.type != ErrorType.STATIC_WARNING,
|
||||
element.errorCode.type != DiagnosticType.HINT &&
|
||||
element.errorCode.type != DiagnosticType.STATIC_WARNING,
|
||||
)
|
||||
.toList();
|
||||
assertErrorsInList(notHints, []);
|
||||
|
||||
@@ -104,7 +104,8 @@ Future<void> _analyzeFiles(AnalysisContextCollectionImpl collection) async {
|
||||
errorsResult.errors
|
||||
.where(
|
||||
(element) =>
|
||||
element.errorCode.type == ErrorType.COMPILE_TIME_ERROR,
|
||||
element.errorCode.type ==
|
||||
DiagnosticType.COMPILE_TIME_ERROR,
|
||||
)
|
||||
.toList();
|
||||
if (errors.isNotEmpty) {
|
||||
|
||||
@@ -447,7 +447,7 @@ class ErrorClassInfo {
|
||||
}
|
||||
|
||||
/// Generates the code to compute the type of errors of this class.
|
||||
String get typeCode => 'ErrorType.$type';
|
||||
String get typeCode => 'DiagnosticType.$type';
|
||||
}
|
||||
|
||||
/// In-memory representation of error code information obtained from either the
|
||||
|
||||
@@ -173,7 +173,7 @@ library;
|
||||
);
|
||||
out.writeln();
|
||||
out.writeln('@override');
|
||||
out.writeln('ErrorType get type => ${errorClass.typeCode};');
|
||||
out.writeln('DiagnosticType get type => ${errorClass.typeCode};');
|
||||
out.writeln('}');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -300,8 +300,8 @@ class HumanErrorFormatter extends ErrorFormatter {
|
||||
// Get display name; translate INFOs into LINTS and HINTS.
|
||||
var errorType = severity.displayName;
|
||||
if (severity == ErrorSeverity.INFO) {
|
||||
if (error.errorCode.type == ErrorType.HINT ||
|
||||
error.errorCode.type == ErrorType.LINT) {
|
||||
if (error.errorCode.type == DiagnosticType.HINT ||
|
||||
error.errorCode.type == DiagnosticType.LINT) {
|
||||
errorType = error.errorCode.type.displayName;
|
||||
}
|
||||
}
|
||||
@@ -492,9 +492,9 @@ class MachineErrorFormatter extends ErrorFormatter {
|
||||
stats.errorCount++;
|
||||
} else if (severity == ErrorSeverity.WARNING) {
|
||||
stats.warnCount++;
|
||||
} else if (error.errorCode.type == ErrorType.HINT) {
|
||||
} else if (error.errorCode.type == DiagnosticType.HINT) {
|
||||
stats.hintCount++;
|
||||
} else if (error.errorCode.type == ErrorType.LINT) {
|
||||
} else if (error.errorCode.type == DiagnosticType.LINT) {
|
||||
stats.lintCount++;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ ErrorSeverity? determineProcessedSeverity(
|
||||
) {
|
||||
var severity = computeSeverity(error, commandLineOptions, analysisOptions);
|
||||
// Skip TODOs categorically unless escalated to ERROR or HINT (#26215).
|
||||
if (error.errorCode.type == ErrorType.TODO &&
|
||||
if (error.errorCode.type == DiagnosticType.TODO &&
|
||||
severity == ErrorSeverity.INFO) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ class MockCommandLineOptions implements CommandLineOptions {
|
||||
|
||||
class MockErrorCode implements ErrorCode {
|
||||
@override
|
||||
ErrorType type;
|
||||
DiagnosticType type;
|
||||
|
||||
@override
|
||||
ErrorSeverity errorSeverity;
|
||||
|
||||
@@ -45,7 +45,10 @@ void main() {
|
||||
});
|
||||
|
||||
test('error', () async {
|
||||
var error = mockResult(ErrorType.SYNTACTIC_ERROR, ErrorSeverity.ERROR);
|
||||
var error = mockResult(
|
||||
DiagnosticType.SYNTACTIC_ERROR,
|
||||
ErrorSeverity.ERROR,
|
||||
);
|
||||
await reporter.formatErrors([error]);
|
||||
reporter.flush();
|
||||
|
||||
@@ -56,7 +59,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('hint', () async {
|
||||
var error = mockResult(ErrorType.HINT, ErrorSeverity.INFO);
|
||||
var error = mockResult(DiagnosticType.HINT, ErrorSeverity.INFO);
|
||||
await reporter.formatErrors([error]);
|
||||
reporter.flush();
|
||||
|
||||
@@ -67,7 +70,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('stats', () async {
|
||||
var error = mockResult(ErrorType.HINT, ErrorSeverity.INFO);
|
||||
var error = mockResult(DiagnosticType.HINT, ErrorSeverity.INFO);
|
||||
await reporter.formatErrors([error]);
|
||||
reporter.flush();
|
||||
stats.print(out);
|
||||
@@ -85,7 +88,10 @@ void main() {
|
||||
});
|
||||
|
||||
test('error', () async {
|
||||
var error = mockResult(ErrorType.SYNTACTIC_ERROR, ErrorSeverity.ERROR);
|
||||
var error = mockResult(
|
||||
DiagnosticType.SYNTACTIC_ERROR,
|
||||
ErrorSeverity.ERROR,
|
||||
);
|
||||
await reporter.formatErrors([error]);
|
||||
reporter.flush();
|
||||
|
||||
@@ -103,7 +109,7 @@ void main() {
|
||||
});
|
||||
}
|
||||
|
||||
ErrorsResultImpl mockResult(ErrorType type, ErrorSeverity severity) {
|
||||
ErrorsResultImpl mockResult(DiagnosticType type, ErrorSeverity severity) {
|
||||
// ErrorInfo
|
||||
var location = CharacterLocation(3, 3);
|
||||
var lineInfo = MockLineInfo(defaultLocation: location);
|
||||
|
||||
@@ -181,7 +181,7 @@ class AnalyzerConverter {
|
||||
|
||||
/// Convert the error [type] from the 'analyzer' package to an analysis error
|
||||
/// type defined by the plugin API.
|
||||
plugin.AnalysisErrorType convertErrorType(analyzer.ErrorType type) =>
|
||||
plugin.AnalysisErrorType convertErrorType(analyzer.DiagnosticType type) =>
|
||||
plugin.AnalysisErrorType.values.byName(type.name);
|
||||
|
||||
String getElementDisplayName(analyzer.Element element) {
|
||||
|
||||
@@ -629,7 +629,7 @@ typedef A<T> = Map<int, T>;
|
||||
}
|
||||
|
||||
void test_convertErrorType() {
|
||||
for (var type in analyzer.ErrorType.values) {
|
||||
for (var type in analyzer.DiagnosticType.values) {
|
||||
expect(converter.convertErrorType(type), isNotNull, reason: type.name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ void defineTests() {
|
||||
setUp(() async {
|
||||
var lineInfo = LineInfo([3, 6, 9]);
|
||||
|
||||
var type = MockErrorType()..displayName = 'test';
|
||||
var type = MockDiagnosticType()..displayName = 'test';
|
||||
|
||||
var code = TestErrorCode('mock_code', 'MSG')..type = type;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import 'package:analyzer/error/error.dart';
|
||||
import 'package:analyzer/src/generated/engine.dart';
|
||||
import 'package:analyzer/src/generated/source.dart';
|
||||
|
||||
class MockErrorType implements ErrorType {
|
||||
class MockDiagnosticType implements DiagnosticType {
|
||||
@override
|
||||
late String displayName;
|
||||
|
||||
@@ -23,7 +23,7 @@ class MockErrorType implements ErrorType {
|
||||
late ErrorSeverity severity;
|
||||
|
||||
@override
|
||||
int compareTo(ErrorType other) => 0;
|
||||
int compareTo(DiagnosticType other) => 0;
|
||||
|
||||
@override
|
||||
String toString() => 'MockErrorType';
|
||||
@@ -85,7 +85,7 @@ class TestErrorCode extends ErrorCode {
|
||||
late ErrorSeverity errorSeverity;
|
||||
|
||||
@override
|
||||
late ErrorType type;
|
||||
late DiagnosticType type;
|
||||
|
||||
TestErrorCode(String name, String message)
|
||||
: super(
|
||||
|
||||
@@ -115,7 +115,7 @@ Future<bool> verifyFile(
|
||||
|
||||
// Throw if there are syntactic errors.
|
||||
var syntacticErrors = parseResult.errors.where((error) {
|
||||
return error.errorCode.type == ErrorType.SYNTACTIC_ERROR;
|
||||
return error.errorCode.type == DiagnosticType.SYNTACTIC_ERROR;
|
||||
}).toList();
|
||||
if (syntacticErrors.isNotEmpty) {
|
||||
throw Exception(syntacticErrors);
|
||||
|
||||
Reference in New Issue
Block a user