Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Unified Diff: pkg/analyzer_experimental/lib/src/generated/error.dart

Issue 18129004: Simplify constructors translation, improve code style. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer_experimental/lib/src/generated/error.dart
diff --git a/pkg/analyzer_experimental/lib/src/generated/error.dart b/pkg/analyzer_experimental/lib/src/generated/error.dart
index e2faa621c503f84d7585368ff615c614da6ec1d6..0c694b223fdd79b80c8735bb2ff02f9c3dc42618 100644
--- a/pkg/analyzer_experimental/lib/src/generated/error.dart
+++ b/pkg/analyzer_experimental/lib/src/generated/error.dart
@@ -107,11 +107,7 @@ class AnalysisErrorWithProperties extends AnalysisError {
* @param errorCode the error code to be associated with this error
* @param arguments the arguments used to build the error message
*/
- AnalysisErrorWithProperties.con1(Source source, ErrorCode errorCode, List<Object> arguments) : super.con1(source, errorCode, arguments) {
- _jtd_constructor_134_impl(source, errorCode, arguments);
- }
- _jtd_constructor_134_impl(Source source, ErrorCode errorCode, List<Object> arguments) {
- }
+ AnalysisErrorWithProperties.con1(Source source, ErrorCode errorCode, List<Object> arguments) : super.con1(source, errorCode, arguments);
/**
* Initialize a newly created analysis error for the specified source at the given location.
@@ -122,11 +118,7 @@ class AnalysisErrorWithProperties extends AnalysisError {
* @param errorCode the error code to be associated with this error
* @param arguments the arguments used to build the error message
*/
- AnalysisErrorWithProperties.con2(Source source, int offset, int length, ErrorCode errorCode, List<Object> arguments) : super.con2(source, offset, length, errorCode, arguments) {
- _jtd_constructor_135_impl(source, offset, length, errorCode, arguments);
- }
- _jtd_constructor_135_impl(Source source, int offset, int length, ErrorCode errorCode, List<Object> arguments) {
- }
+ AnalysisErrorWithProperties.con2(Source source, int offset, int length, ErrorCode errorCode, List<Object> arguments) : super.con2(source, offset, length, errorCode, arguments);
Object getProperty(ErrorProperty property) => _propertyMap[property];
/**
@@ -141,45 +133,6 @@ class AnalysisErrorWithProperties extends AnalysisError {
}
}
/**
- * The enumeration `AuditCode` defines the audits and coding recommendations for best
- * practices which are not mentioned in the Dart Language Specification.
- */
-class AuditCode implements Comparable<AuditCode>, ErrorCode {
-
- /**
- * Dead code is code that is never reached, this can happen for instance if a statement follows a
- * return statement.
- */
- static final AuditCode DEAD_CODE = new AuditCode('DEAD_CODE', 0, "Dead code");
- static final List<AuditCode> values = [DEAD_CODE];
-
- /// The name of this enum constant, as declared in the enum declaration.
- final String name;
-
- /// The position in the enum declaration.
- final int ordinal;
-
- /**
- * The message template used to create the message to be displayed for this error.
- */
- String _message;
-
- /**
- * Initialize a newly created error code to have the given message.
- *
- * @param message the message template used to create the message to be displayed for the error
- */
- AuditCode(this.name, this.ordinal, String message) {
- this._message = message;
- }
- ErrorSeverity get errorSeverity => ErrorType.AUDIT.severity;
- String get message => _message;
- ErrorType get type => ErrorType.AUDIT;
- int compareTo(AuditCode other) => ordinal - other.ordinal;
- int get hashCode => ordinal;
- String toString() => name;
-}
-/**
* Instances of the class `ErrorReporter` wrap an error listener with utility methods used to
* create the errors being reported.
*
@@ -353,13 +306,10 @@ class AnalysisError {
* @param errorCode the error code to be associated with this error
* @param arguments the arguments used to build the error message
*/
- AnalysisError.con1(Source source2, ErrorCode errorCode2, List<Object> arguments) {
- _jtd_constructor_132_impl(source2, errorCode2, arguments);
- }
- _jtd_constructor_132_impl(Source source2, ErrorCode errorCode2, List<Object> arguments) {
- this._source = source2;
- this._errorCode = errorCode2;
- this._message = JavaString.format(errorCode2.message, arguments);
+ AnalysisError.con1(Source source, ErrorCode errorCode, List<Object> arguments) {
+ this._source = source;
+ this._errorCode = errorCode;
+ this._message = JavaString.format(errorCode.message, arguments);
}
/**
@@ -371,15 +321,12 @@ class AnalysisError {
* @param errorCode the error code to be associated with this error
* @param arguments the arguments used to build the error message
*/
- AnalysisError.con2(Source source2, int offset2, int length2, ErrorCode errorCode2, List<Object> arguments) {
- _jtd_constructor_133_impl(source2, offset2, length2, errorCode2, arguments);
- }
- _jtd_constructor_133_impl(Source source2, int offset2, int length2, ErrorCode errorCode2, List<Object> arguments) {
- this._source = source2;
- this._offset = offset2;
- this._length = length2;
- this._errorCode = errorCode2;
- this._message = JavaString.format(errorCode2.message, arguments);
+ AnalysisError.con2(Source source, int offset, int length, ErrorCode errorCode, List<Object> arguments) {
+ this._source = source;
+ this._offset = offset;
+ this._length = length;
+ this._errorCode = errorCode;
+ this._message = JavaString.format(errorCode.message, arguments);
}
/**
@@ -472,13 +419,66 @@ class ErrorProperty implements Comparable<ErrorProperty> {
/// The position in the enum declaration.
final int ordinal;
- ErrorProperty(this.name, this.ordinal) {
- }
+ ErrorProperty(this.name, this.ordinal);
int compareTo(ErrorProperty other) => ordinal - other.ordinal;
int get hashCode => ordinal;
String toString() => name;
}
/**
+ * The enumeration `HintCode` defines the hints and coding recommendations for best practices
+ * which are not mentioned in the Dart Language Specification.
+ */
+class HintCode implements Comparable<HintCode>, ErrorCode {
+
+ /**
+ * Dead code is code that is never reached, this can happen for instance if a statement follows a
+ * return statement.
+ */
+ static final HintCode DEAD_CODE = new HintCode('DEAD_CODE', 0, "Dead code");
+
+ /**
+ * Dead code is code that is never reached. This case covers cases where the user has catch
+ * clauses after `catch (e)` or `on Object catch (e)`.
+ */
+ static final HintCode DEAD_CODE_CATCH_FOLLOWING_CATCH = new HintCode('DEAD_CODE_CATCH_FOLLOWING_CATCH', 1, "Dead code, catch clauses after a 'catch (e)' or an 'on Object catch (e)' are never reached");
+
+ /**
+ * Dead code is code that is never reached. This case covers cases where the user has an on-catch
+ * clause such as `on A catch (e)`, where a supertype of `A` was already caught.
+ *
+ * @param subtypeName name of the subtype
+ * @param supertypeName name of the supertype
+ */
+ static final HintCode DEAD_CODE_ON_CATCH_SUBTYPE = new HintCode('DEAD_CODE_ON_CATCH_SUBTYPE', 2, "Dead code, this on-catch block will never be executed since '%s' is a subtype of '%s'");
+ static final List<HintCode> values = [DEAD_CODE, DEAD_CODE_CATCH_FOLLOWING_CATCH, DEAD_CODE_ON_CATCH_SUBTYPE];
+
+ /// The name of this enum constant, as declared in the enum declaration.
+ final String name;
+
+ /// The position in the enum declaration.
+ final int ordinal;
+
+ /**
+ * The message template used to create the message to be displayed for this error.
+ */
+ String _message;
+
+ /**
+ * Initialize a newly created error code to have the given message.
+ *
+ * @param message the message template used to create the message to be displayed for the error
+ */
+ HintCode(this.name, this.ordinal, String message) {
+ this._message = message;
+ }
+ ErrorSeverity get errorSeverity => ErrorType.HINT.severity;
+ String get message => _message;
+ ErrorType get type => ErrorType.HINT;
+ int compareTo(HintCode other) => ordinal - other.ordinal;
+ int get hashCode => ordinal;
+ String toString() => name;
+}
+/**
* The interface `ErrorCode` defines the behavior common to objects representing error codes
* associated with [AnalysisError].
*
@@ -515,10 +515,10 @@ abstract class ErrorCode {
class ErrorType implements Comparable<ErrorType> {
/**
- * Extra audits run over the code to follow best practices, which are not in the Dart Language
+ * Extra analysis run over the code to follow best practices, which are not in the Dart Language
* Specification.
*/
- static final ErrorType AUDIT = new ErrorType('AUDIT', 0, ErrorSeverity.SUGGESTION);
+ static final ErrorType HINT = new ErrorType('HINT', 0, ErrorSeverity.SUGGESTION);
/**
* Compile-time errors are errors that preclude execution. A compile time error must be reported
@@ -548,7 +548,7 @@ class ErrorType implements Comparable<ErrorType> {
* Syntactic errors are errors produced as a result of input that does not conform to the grammar.
*/
static final ErrorType SYNTACTIC_ERROR = new ErrorType('SYNTACTIC_ERROR', 5, ErrorSeverity.ERROR);
- static final List<ErrorType> values = [AUDIT, COMPILE_TIME_ERROR, PUB_SUGGESTION, STATIC_WARNING, STATIC_TYPE_WARNING, SYNTACTIC_ERROR];
+ static final List<ErrorType> values = [HINT, COMPILE_TIME_ERROR, PUB_SUGGESTION, STATIC_WARNING, STATIC_TYPE_WARNING, SYNTACTIC_ERROR];
/// The name of this enum constant, as declared in the enum declaration.
final String name;

Powered by Google App Engine
This is Rietveld 408576698