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

Side by Side Diff: pkg/analyzer/lib/src/task/strong/checker.dart

Issue 2784473004: Take analysis options into account when computing the severity of a strong mode "error". (Closed)
Patch Set: Use ?:. Created 3 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 // TODO(jmesserly): this was ported from package:dev_compiler, and needs to be 5 // TODO(jmesserly): this was ported from package:dev_compiler, and needs to be
6 // refactored to fit into analyzer. 6 // refactored to fit into analyzer.
7 library analyzer.src.task.strong.checker; 7 library analyzer.src.task.strong.checker;
8 8
9 import 'package:analyzer/analyzer.dart'; 9 import 'package:analyzer/analyzer.dart';
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
11 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; 11 import 'package:analyzer/dart/ast/standard_resolution_map.dart';
12 import 'package:analyzer/dart/ast/token.dart' show TokenType; 12 import 'package:analyzer/dart/ast/token.dart' show TokenType;
13 import 'package:analyzer/dart/ast/token.dart'; 13 import 'package:analyzer/dart/ast/token.dart';
14 import 'package:analyzer/dart/ast/visitor.dart'; 14 import 'package:analyzer/dart/ast/visitor.dart';
15 import 'package:analyzer/dart/element/element.dart'; 15 import 'package:analyzer/dart/element/element.dart';
16 import 'package:analyzer/dart/element/type.dart'; 16 import 'package:analyzer/dart/element/type.dart';
17 import 'package:analyzer/source/error_processor.dart' show ErrorProcessor;
17 import 'package:analyzer/src/dart/element/element.dart'; 18 import 'package:analyzer/src/dart/element/element.dart';
18 import 'package:analyzer/src/dart/element/type.dart'; 19 import 'package:analyzer/src/dart/element/type.dart';
19 import 'package:analyzer/src/error/codes.dart' show StrongModeCode; 20 import 'package:analyzer/src/error/codes.dart' show StrongModeCode;
20 import 'package:analyzer/src/generated/engine.dart' show AnalysisOptionsImpl; 21 import 'package:analyzer/src/generated/engine.dart' show AnalysisOptionsImpl;
21 import 'package:analyzer/src/generated/resolver.dart' show TypeProvider; 22 import 'package:analyzer/src/generated/resolver.dart' show TypeProvider;
22 import 'package:analyzer/src/generated/type_system.dart'; 23 import 'package:analyzer/src/generated/type_system.dart';
23 import 'package:analyzer/src/summary/idl.dart'; 24 import 'package:analyzer/src/summary/idl.dart';
24 25
25 import 'ast_properties.dart'; 26 import 'ast_properties.dart';
26 27
(...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 _recordMessage(expr, errorCode, [from, to]); 1032 _recordMessage(expr, errorCode, [from, to]);
1032 if (opAssign) { 1033 if (opAssign) {
1033 setImplicitAssignmentCast(expr, to); 1034 setImplicitAssignmentCast(expr, to);
1034 } else { 1035 } else {
1035 setImplicitCast(expr, to); 1036 setImplicitCast(expr, to);
1036 } 1037 }
1037 _hasImplicitCasts = true; 1038 _hasImplicitCasts = true;
1038 } 1039 }
1039 1040
1040 void _recordMessage(AstNode node, ErrorCode errorCode, List arguments) { 1041 void _recordMessage(AstNode node, ErrorCode errorCode, List arguments) {
1041 var severity = errorCode.errorSeverity; 1042 // Compute the right severity taking the analysis options into account.
1043 // We construct a dummy error to make the common case where we end up
1044 // ignoring the strong mode message cheaper.
1045 var processor = ErrorProcessor.getProcessor(_options,
1046 new AnalysisError.forValues(null, -1, 0, errorCode, null, null));
1047 var severity =
1048 (processor != null) ? processor.severity : errorCode.errorSeverity;
Brian Wilkerson 2017/03/29 13:44:22 If this works, then I suppose it's fine, but I don
1049
1042 if (severity == ErrorSeverity.ERROR) _failure = true; 1050 if (severity == ErrorSeverity.ERROR) _failure = true;
1043 if (severity != ErrorSeverity.INFO || _options.strongModeHints) { 1051 if (severity != ErrorSeverity.INFO || _options.strongModeHints) {
1044 int begin = node is AnnotatedNode 1052 int begin = node is AnnotatedNode
1045 ? node.firstTokenAfterCommentAndMetadata.offset 1053 ? node.firstTokenAfterCommentAndMetadata.offset
1046 : node.offset; 1054 : node.offset;
1047 int length = node.end - begin; 1055 int length = node.end - begin;
1048 var source = resolutionMap 1056 var source = resolutionMap
1049 .elementDeclaredByCompilationUnit(node.root as CompilationUnit) 1057 .elementDeclaredByCompilationUnit(node.root as CompilationUnit)
1050 .source; 1058 .source;
1051 var error = 1059 var error =
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
1549 var visited = new Set<InterfaceType>(); 1557 var visited = new Set<InterfaceType>();
1550 do { 1558 do {
1551 visited.add(current); 1559 visited.add(current);
1552 current.mixins.reversed.forEach( 1560 current.mixins.reversed.forEach(
1553 (m) => _checkIndividualOverridesFromClass(node, m, seen, true)); 1561 (m) => _checkIndividualOverridesFromClass(node, m, seen, true));
1554 _checkIndividualOverridesFromClass(node, current.superclass, seen, true); 1562 _checkIndividualOverridesFromClass(node, current.superclass, seen, true);
1555 current = current.superclass; 1563 current = current.superclass;
1556 } while (!current.isObject && !visited.contains(current)); 1564 } while (!current.isObject && !visited.contains(current));
1557 } 1565 }
1558 } 1566 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698