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

Side by Side Diff: pkg/analyzer/lib/src/generated/error.dart

Issue 2060013002: Refactor strong mode to use standard Analyzer errors (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: fix hasImplicitCasts on the CompilationUnit Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.src.generated.error; 5 library analyzer.src.generated.error;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/dart/ast/ast.dart' show AstNode; 9 import 'package:analyzer/dart/ast/ast.dart' show AstNode;
10 import 'package:analyzer/dart/ast/token.dart'; 10 import 'package:analyzer/dart/ast/token.dart';
(...skipping 2833 matching lines...) Expand 10 before | Expand all | Expand 10 after
2844 StaticWarningCode.UNDEFINED_CLASS_BOOLEAN, 2844 StaticWarningCode.UNDEFINED_CLASS_BOOLEAN,
2845 StaticWarningCode.UNDEFINED_GETTER, 2845 StaticWarningCode.UNDEFINED_GETTER,
2846 StaticWarningCode.UNDEFINED_IDENTIFIER, 2846 StaticWarningCode.UNDEFINED_IDENTIFIER,
2847 StaticWarningCode.UNDEFINED_NAMED_PARAMETER, 2847 StaticWarningCode.UNDEFINED_NAMED_PARAMETER,
2848 StaticWarningCode.UNDEFINED_SETTER, 2848 StaticWarningCode.UNDEFINED_SETTER,
2849 StaticWarningCode.UNDEFINED_STATIC_METHOD_OR_GETTER, 2849 StaticWarningCode.UNDEFINED_STATIC_METHOD_OR_GETTER,
2850 StaticWarningCode.UNDEFINED_SUPER_GETTER, 2850 StaticWarningCode.UNDEFINED_SUPER_GETTER,
2851 StaticWarningCode.UNDEFINED_SUPER_SETTER, 2851 StaticWarningCode.UNDEFINED_SUPER_SETTER,
2852 StaticWarningCode.VOID_RETURN_FOR_GETTER, 2852 StaticWarningCode.VOID_RETURN_FOR_GETTER,
2853 StaticWarningCode.MISSING_ENUM_CONSTANT_IN_SWITCH, 2853 StaticWarningCode.MISSING_ENUM_CONSTANT_IN_SWITCH,
2854 StrongModeCode.ASSIGNMENT_CAST,
2855 StrongModeCode.DOWN_CAST_COMPOSITE,
2856 StrongModeCode.DOWN_CAST_IMPLICIT,
2857 StrongModeCode.DYNAMIC_CAST,
2858 StrongModeCode.DYNAMIC_INVOKE,
2859 StrongModeCode.INFERRED_TYPE,
2860 StrongModeCode.INFERRED_TYPE_ALLOCATION,
2861 StrongModeCode.INFERRED_TYPE_CLOSURE,
2862 StrongModeCode.INFERRED_TYPE_LITERAL,
2863 StrongModeCode.INVALID_FIELD_OVERRIDE,
2864 StrongModeCode.INVALID_METHOD_OVERRIDE,
2865 StrongModeCode.INVALID_METHOD_OVERRIDE_FROM_BASE,
2866 StrongModeCode.INVALID_METHOD_OVERRIDE_FROM_MIXIN,
2867 StrongModeCode.INVALID_PARAMETER_DECLARATION,
2868 StrongModeCode.INVALID_SUPER_INVOCATION,
2869 StrongModeCode.NON_GROUND_TYPE_CHECK_INFO,
2870 StrongModeCode.STATIC_TYPE_ERROR,
2871
2854 TodoCode.TODO, 2872 TodoCode.TODO,
2855 2873
2856 // 2874 //
2857 // parser.dart: 2875 // parser.dart:
2858 // 2876 //
2859 ParserErrorCode.ABSTRACT_CLASS_MEMBER, 2877 ParserErrorCode.ABSTRACT_CLASS_MEMBER,
2860 ParserErrorCode.ABSTRACT_ENUM, 2878 ParserErrorCode.ABSTRACT_ENUM,
2861 ParserErrorCode.ABSTRACT_STATIC_METHOD, 2879 ParserErrorCode.ABSTRACT_STATIC_METHOD,
2862 ParserErrorCode.ABSTRACT_TOP_LEVEL_FUNCTION, 2880 ParserErrorCode.ABSTRACT_TOP_LEVEL_FUNCTION,
2863 ParserErrorCode.ABSTRACT_TOP_LEVEL_VARIABLE, 2881 ParserErrorCode.ABSTRACT_TOP_LEVEL_VARIABLE,
(...skipping 2936 matching lines...) Expand 10 before | Expand all | Expand 10 after
5800 : super(name, message, correction); 5818 : super(name, message, correction);
5801 5819
5802 @override 5820 @override
5803 ErrorSeverity get errorSeverity => ErrorType.STATIC_WARNING.severity; 5821 ErrorSeverity get errorSeverity => ErrorType.STATIC_WARNING.severity;
5804 5822
5805 @override 5823 @override
5806 ErrorType get type => ErrorType.STATIC_WARNING; 5824 ErrorType get type => ErrorType.STATIC_WARNING;
5807 } 5825 }
5808 5826
5809 /** 5827 /**
5828 * This class has Strong Mode specific error codes.
5829 *
5830 * These error codes tend to use the same message across different severity
5831 * levels, so they are grouped for clarity.
5832 *
5833 * All of these error codes also use the "STRONG_MODE_" prefix in their name.
5834 */
5835 class StrongModeCode extends ErrorCode {
5836 static const String _implicitCastMessage =
5837 'Unsound implicit cast from {0} to {1}';
5838
5839 static const String _typeCheckMessage =
5840 'Type check failed: {0} is not of type {1}';
5841
5842 static const String _invalidOverrideMessage =
5843 'The type of {0}.{1} ({2}) is not a '
5844 'subtype of {3}.{1} ({4}).';
5845
5846 static const String _inferredTypeMessage = '{0} has inferred type {1}';
5847
5848 static const StrongModeCode DOWN_CAST_COMPOSITE = const StrongModeCode(
5849 ErrorType.STATIC_WARNING, 'DOWN_CAST_COMPOSITE', _implicitCastMessage);
5850
5851 static const StrongModeCode DOWN_CAST_IMPLICIT = const StrongModeCode(
5852 ErrorType.HINT, 'DOWN_CAST_IMPLICIT', _implicitCastMessage);
5853
5854 static const StrongModeCode DYNAMIC_CAST = const StrongModeCode(
5855 ErrorType.HINT, 'DYNAMIC_CAST', _implicitCastMessage);
5856
5857 static const StrongModeCode ASSIGNMENT_CAST = const StrongModeCode(
5858 ErrorType.HINT, 'ASSIGNMENT_CAST', _implicitCastMessage);
5859
5860 static const StrongModeCode INVALID_PARAMETER_DECLARATION =
5861 const StrongModeCode(ErrorType.COMPILE_TIME_ERROR,
5862 'INVALID_PARAMETER_DECLARATION', _typeCheckMessage);
5863
5864 static const StrongModeCode INFERRED_TYPE = const StrongModeCode(
5865 ErrorType.HINT, 'INFERRED_TYPE', _inferredTypeMessage);
5866
5867 static const StrongModeCode INFERRED_TYPE_LITERAL = const StrongModeCode(
5868 ErrorType.HINT, 'INFERRED_TYPE_LITERAL', _inferredTypeMessage);
5869
5870 static const StrongModeCode INFERRED_TYPE_ALLOCATION = const StrongModeCode(
5871 ErrorType.HINT, 'INFERRED_TYPE_ALLOCATION', _inferredTypeMessage);
5872
5873 static const StrongModeCode INFERRED_TYPE_CLOSURE = const StrongModeCode(
5874 ErrorType.HINT, 'INFERRED_TYPE_CLOSURE', _inferredTypeMessage);
5875
5876 static const StrongModeCode STATIC_TYPE_ERROR = const StrongModeCode(
5877 ErrorType.COMPILE_TIME_ERROR,
5878 'STATIC_TYPE_ERROR',
5879 'Type check failed: {0} ({1}) is not of type {2}');
5880
5881 static const StrongModeCode INVALID_SUPER_INVOCATION = const StrongModeCode(
5882 ErrorType.COMPILE_TIME_ERROR,
5883 'INVALID_SUPER_INVOCATION',
5884 "super call must be last in an initializer "
5885 "list (see https://goo.gl/EY6hDP): {0}");
5886
5887 static const StrongModeCode NON_GROUND_TYPE_CHECK_INFO = const StrongModeCode(
5888 ErrorType.HINT,
5889 'NON_GROUND_TYPE_CHECK_INFO',
5890 "Runtime check on non-ground type {0} may throw StrongModeError");
5891
5892 static const StrongModeCode DYNAMIC_INVOKE = const StrongModeCode(
5893 ErrorType.HINT, 'DYNAMIC_INVOKE', '{0} requires a dynamic invoke');
5894
5895 static const StrongModeCode INVALID_METHOD_OVERRIDE = const StrongModeCode(
5896 ErrorType.COMPILE_TIME_ERROR,
5897 'INVALID_METHOD_OVERRIDE',
5898 'Invalid override. $_invalidOverrideMessage');
5899
5900 static const StrongModeCode INVALID_METHOD_OVERRIDE_FROM_BASE =
5901 const StrongModeCode(
5902 ErrorType.COMPILE_TIME_ERROR,
5903 'INVALID_METHOD_OVERRIDE_FROM_BASE',
5904 'Base class introduces an invalid override. '
5905 '$_invalidOverrideMessage');
5906
5907 static const StrongModeCode INVALID_METHOD_OVERRIDE_FROM_MIXIN =
5908 const StrongModeCode(
5909 ErrorType.COMPILE_TIME_ERROR,
5910 'INVALID_METHOD_OVERRIDE_FROM_MIXIN',
5911 'Mixin introduces an invalid override. $_invalidOverrideMessage');
5912
5913 static const StrongModeCode INVALID_FIELD_OVERRIDE = const StrongModeCode(
5914 ErrorType.COMPILE_TIME_ERROR,
5915 'INVALID_FIELD_OVERRIDE',
5916 'Field declaration {3}.{1} cannot be '
5917 'overridden in {0}.');
5918
5919 @override
5920 final ErrorType type;
5921
5922 /**
5923 * Initialize a newly created error code to have the given [type] and [name].
5924 *
5925 * The message associated with the error will be created from the given
5926 * [message] template. The correction associated with the error will be
5927 * created from the optional [correction] template.
5928 */
5929 const StrongModeCode(ErrorType type, String name, String message,
5930 [String correction])
5931 : type = type,
5932 super('STRONG_MODE_$name', message, correction);
5933
5934 @override
5935 ErrorSeverity get errorSeverity => type.severity;
5936 }
5937
5938 /**
5810 * The error code indicating a marker in code for work that needs to be finished 5939 * The error code indicating a marker in code for work that needs to be finished
5811 * or revisited. 5940 * or revisited.
5812 */ 5941 */
5813 class TodoCode extends ErrorCode { 5942 class TodoCode extends ErrorCode {
5814 /** 5943 /**
5815 * The single enum of TodoCode. 5944 * The single enum of TodoCode.
5816 */ 5945 */
5817 static const TodoCode TODO = const TodoCode('TODO'); 5946 static const TodoCode TODO = const TodoCode('TODO');
5818 5947
5819 /** 5948 /**
(...skipping 16 matching lines...) Expand all
5836 * Initialize a newly created error code to have the given [name]. 5965 * Initialize a newly created error code to have the given [name].
5837 */ 5966 */
5838 const TodoCode(String name) : super(name, "{0}"); 5967 const TodoCode(String name) : super(name, "{0}");
5839 5968
5840 @override 5969 @override
5841 ErrorSeverity get errorSeverity => ErrorSeverity.INFO; 5970 ErrorSeverity get errorSeverity => ErrorSeverity.INFO;
5842 5971
5843 @override 5972 @override
5844 ErrorType get type => ErrorType.TODO; 5973 ErrorType get type => ErrorType.TODO;
5845 } 5974 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/error_verifier.dart » ('j') | pkg/analyzer/lib/src/generated/type_system.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698