Index: pkg/analysis_server/lib/src/services/correction/fix_internal.dart |
diff --git a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart |
index 3fdd5f9a3db8a3b7a43e2afc1012365455acbf5e..dada281823dbb821c776c84e5badb4865106410a 100644 |
--- a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart |
+++ b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart |
@@ -32,6 +32,7 @@ import 'package:analyzer/src/dart/ast/token.dart'; |
import 'package:analyzer/src/dart/element/element.dart'; |
import 'package:analyzer/src/dart/element/member.dart'; |
import 'package:analyzer/src/dart/element/type.dart'; |
+import 'package:analyzer/src/dart/scanner/scanner.dart'; |
scheglov
2016/03/04 18:55:20
Do we need this import?
pquitslund
2016/03/04 19:09:39
We don't! That was dead. Removed.
|
import 'package:analyzer/src/generated/ast.dart'; |
import 'package:analyzer/src/generated/engine.dart'; |
import 'package:analyzer/src/generated/error.dart'; |
@@ -143,6 +144,15 @@ class FixProcessor { |
new NodeLocator2(errorOffset, errorEnd - 1).searchWithin(unit); |
// analyze ErrorCode |
ErrorCode errorCode = error.errorCode; |
+ // add ignore fix for ignorable errors. |
+ // note that this fix needs to be added before fixes that side-effect |
+ // the utils instance. |
+ if (errorCode is StaticWarningCode || |
+ errorCode is StaticTypeWarningCode || |
+ errorCode is HintCode || |
+ errorCode is LintCode) { |
+ _addFix_ignore(errorCode); |
+ } |
if (errorCode == StaticWarningCode.UNDEFINED_CLASS_BOOLEAN) { |
_addFix_boolInsteadOfBoolean(); |
} |
@@ -1383,6 +1393,18 @@ class FixProcessor { |
} |
} |
+ void _addFix_ignore(ErrorCode errorCode) { |
+ int offset = node.offset; |
+ int lineOffset = utils.getLineThis(offset); |
+ |
+ exitPosition = new Position(file, lineOffset - 1); |
+ String indent = utils.getLinePrefix(offset); |
+ String errorCodeName = errorCode.name.toLowerCase(); |
+ String content = '$indent//ignore: $errorCodeName$eol'; |
+ _addReplaceEdit(rf.rangeStartLength(lineOffset, 0), content); |
+ _addFix(DartFixKind.IGNORE_ERROR, [errorCodeName]); |
+ } |
+ |
void _addFix_illegalAsyncReturnType() { |
// prepare the existing type |
TypeName typeName = node.getAncestor((n) => n is TypeName); |