OLD | NEW |
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 file needs to be refactored, it's a port from | 5 // TODO(jmesserly): this file needs to be refactored, it's a port from |
6 // package:dev_compiler's tests | 6 // package:dev_compiler's tests |
7 library analyzer.test.src.task.strong.strong_test_helper; | 7 library analyzer.test.src.task.strong.strong_test_helper; |
8 | 8 |
9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
10 import 'package:analyzer/dart/ast/token.dart'; | 10 import 'package:analyzer/dart/ast/token.dart'; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 for (var lib in allLibraries) { | 80 for (var lib in allLibraries) { |
81 for (var unit in lib.units) { | 81 for (var unit in lib.units) { |
82 var errors = <AnalysisError>[]; | 82 var errors = <AnalysisError>[]; |
83 collector.errors = errors; | 83 collector.errors = errors; |
84 | 84 |
85 var source = unit.source; | 85 var source = unit.source; |
86 if (source.uri.scheme == 'dart') continue; | 86 if (source.uri.scheme == 'dart') continue; |
87 | 87 |
88 var librarySource = context.getLibrariesContaining(source).single; | 88 var librarySource = context.getLibrariesContaining(source).single; |
89 var resolved = context.resolveCompilationUnit2(source, librarySource); | 89 var resolved = context.resolveCompilationUnit2(source, librarySource); |
90 errors.addAll(context.getErrors(source).errors.where((e) => | 90 |
| 91 errors.addAll(context.computeErrors(source).where((e) => |
| 92 // TODO(jmesserly): these are usually intentional dynamic calls. |
| 93 e.errorCode.name != 'UNDEFINED_METHOD' && |
| 94 // We don't care about any of these: |
| 95 e.errorCode != HintCode.UNNECESSARY_CAST && |
| 96 e.errorCode != HintCode.UNUSED_ELEMENT && |
| 97 e.errorCode != HintCode.UNUSED_FIELD && |
| 98 e.errorCode != HintCode.UNUSED_IMPORT && |
91 e.errorCode != HintCode.UNUSED_LOCAL_VARIABLE && | 99 e.errorCode != HintCode.UNUSED_LOCAL_VARIABLE && |
92 // TODO(jmesserly): these are usually intentional dynamic calls. | 100 e.errorCode != TodoCode.TODO)); |
93 e.errorCode.name != 'UNDEFINED_METHOD')); | |
94 | |
95 _expectErrors(resolved, errors); | 101 _expectErrors(resolved, errors); |
96 } | 102 } |
97 } | 103 } |
98 | 104 |
99 return initialLibrary; | 105 return initialLibrary; |
100 } | 106 } |
101 | 107 |
102 /// Adds a file using [addFile] and calls [check]. | 108 /// Adds a file using [addFile] and calls [check]. |
103 /// | 109 /// |
104 /// Also returns the resolved compilation unit. | 110 /// Also returns the resolved compilation unit. |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 | 390 |
385 @override | 391 @override |
386 Source resolveAbsolute(Uri uri, [Uri actualUri]) { | 392 Source resolveAbsolute(Uri uri, [Uri actualUri]) { |
387 if (uri.scheme == 'package') { | 393 if (uri.scheme == 'package') { |
388 return (provider.getResource('/packages/' + uri.path) as File) | 394 return (provider.getResource('/packages/' + uri.path) as File) |
389 .createSource(uri); | 395 .createSource(uri); |
390 } | 396 } |
391 return super.resolveAbsolute(uri, actualUri); | 397 return super.resolveAbsolute(uri, actualUri); |
392 } | 398 } |
393 } | 399 } |
OLD | NEW |