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

Unified Diff: pkg/analysis_server/lib/src/services/correction/fix.dart

Issue 1385523002: AnalysisError `hasFix` attr (Implements #23874). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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/analysis_server/lib/src/services/correction/fix.dart
diff --git a/pkg/analysis_server/lib/src/services/correction/fix.dart b/pkg/analysis_server/lib/src/services/correction/fix.dart
index e1f81f641a1f8c561b41587a752098c60d5f3e7e..cd1900a1f76c88cfead8cb8b7620f77f7e255a90 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix.dart
@@ -10,6 +10,7 @@ import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/error.dart';
import 'package:analyzer/src/generated/java_engine.dart';
+import 'package:analyzer/src/generated/parser.dart';
/**
* Compute and return the fixes available for the given [error]. The error was
@@ -38,6 +39,77 @@ List<Fix> computeFixes(ServerPlugin plugin, ResourceProvider resourceProvider,
}
/**
+ * Return true if this [errorCode] is likely to have a fix associated with it.
+ */
+bool hasFix(ErrorCode errorCode) {
+ switch (errorCode) {
+ case StaticWarningCode.UNDEFINED_CLASS_BOOLEAN:
+ case StaticWarningCode.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER:
+ case StaticWarningCode.EXTRA_POSITIONAL_ARGUMENTS:
+ case StaticWarningCode.NEW_WITH_UNDEFINED_CONSTRUCTOR:
+ case StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE:
+ case StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_TWO:
+ case StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_THREE:
+ case StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_FOUR:
+ case StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_FIVE_PLUS:
+ case StaticWarningCode.CAST_TO_NON_TYPE:
+ case StaticWarningCode.TYPE_TEST_WITH_UNDEFINED_NAME:
+ case StaticWarningCode.UNDEFINED_CLASS:
+ case StaticWarningCode.FINAL_NOT_INITIALIZED:
+ case StaticWarningCode.FINAL_NOT_INITIALIZED_CONSTRUCTOR_1:
+ case StaticWarningCode.FINAL_NOT_INITIALIZED_CONSTRUCTOR_2:
+ case StaticWarningCode.FINAL_NOT_INITIALIZED_CONSTRUCTOR_3_PLUS:
+ case StaticWarningCode.UNDEFINED_IDENTIFIER:
+ return true;
+ }
+
+ switch (errorCode) {
+ case CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE:
+ case CompileTimeErrorCode.INVALID_ANNOTATION:
+ case CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_EXPLICIT:
+ case CompileTimeErrorCode.PART_OF_NON_PART:
+ case CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT:
+ case CompileTimeErrorCode.URI_DOES_NOT_EXIST:
+ return true;
+ }
+
+ switch (errorCode) {
+ case HintCode.DEAD_CODE:
+ case HintCode.DIVISION_OPTIMIZATION:
+ case HintCode.TYPE_CHECK_IS_NOT_NULL:
+ case HintCode.TYPE_CHECK_IS_NULL:
+ case HintCode.UNDEFINED_GETTER:
+ case HintCode.UNDEFINED_SETTER:
+ case HintCode.UNNECESSARY_CAST:
+ case HintCode.UNUSED_CATCH_CLAUSE:
+ case HintCode.UNUSED_CATCH_STACK:
+ case HintCode.UNUSED_IMPORT:
+ case HintCode.UNDEFINED_METHOD:
+ return true;
+ }
+
+ switch (errorCode) {
+ case ParserErrorCode.EXPECTED_TOKEN:
+ case ParserErrorCode.GETTER_WITH_PARAMETERS:
+ case ParserErrorCode.VAR_AS_TYPE_NAME:
+ return true;
+ }
+
+ switch (errorCode) {
+ case StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE:
+ case StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER:
+ case StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION:
+ case StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT:
+ case StaticTypeWarningCode.UNDEFINED_FUNCTION:
+ case StaticTypeWarningCode.UNDEFINED_GETTER:
+ case StaticTypeWarningCode.UNDEFINED_METHOD:
+ case StaticTypeWarningCode.UNDEFINED_SETTER:
+ return true;
+ }
+ return false;
+}
+
+/**
* An enumeration of possible quick fix kinds.
*/
class DartFixKind {

Powered by Google App Engine
This is Rietveld 408576698