OLD | NEW |
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 test.services.src.index.abstract_single_file; | 5 library test.services.src.index.abstract_single_file; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'package:analyzer/dart/ast/ast.dart'; | 8 import 'package:analyzer/dart/ast/ast.dart'; |
9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
10 import 'package:analyzer/error/error.dart'; | 10 import 'package:analyzer/error/error.dart'; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 return length; | 95 return length; |
96 } | 96 } |
97 | 97 |
98 Future<Null> resolveTestUnit(String code) async { | 98 Future<Null> resolveTestUnit(String code) async { |
99 addTestSource(code); | 99 addTestSource(code); |
100 if (enableNewAnalysisDriver) { | 100 if (enableNewAnalysisDriver) { |
101 var result = await driver.getResult(testFile); | 101 var result = await driver.getResult(testFile); |
102 testUnit = (result).unit; | 102 testUnit = (result).unit; |
103 if (verifyNoTestUnitErrors) { | 103 if (verifyNoTestUnitErrors) { |
104 expect(result.errors.where((AnalysisError error) { | 104 expect(result.errors.where((AnalysisError error) { |
105 return | 105 return error.errorCode != HintCode.DEAD_CODE && |
106 error.errorCode != HintCode.DEAD_CODE && | 106 error.errorCode != HintCode.UNUSED_CATCH_CLAUSE && |
107 error.errorCode != HintCode.UNUSED_CATCH_CLAUSE && | |
108 error.errorCode != HintCode.UNUSED_CATCH_STACK && | 107 error.errorCode != HintCode.UNUSED_CATCH_STACK && |
109 error.errorCode != HintCode.UNUSED_ELEMENT && | 108 error.errorCode != HintCode.UNUSED_ELEMENT && |
110 error.errorCode != HintCode.UNUSED_FIELD && | 109 error.errorCode != HintCode.UNUSED_FIELD && |
111 error.errorCode != HintCode.UNUSED_IMPORT && | 110 error.errorCode != HintCode.UNUSED_IMPORT && |
112 error.errorCode != HintCode.UNUSED_LOCAL_VARIABLE; | 111 error.errorCode != HintCode.UNUSED_LOCAL_VARIABLE; |
113 }), isEmpty); | 112 }), isEmpty); |
114 } | 113 } |
115 } else { | 114 } else { |
116 testUnit = await resolveLibraryUnit(testSource); | 115 testUnit = await resolveLibraryUnit(testSource); |
117 if (verifyNoTestUnitErrors) { | 116 if (verifyNoTestUnitErrors) { |
118 expect(context.getErrors(testSource).errors, isEmpty); | 117 expect(context.getErrors(testSource).errors, isEmpty); |
119 } | 118 } |
120 } | 119 } |
121 testUnitElement = testUnit.element; | 120 testUnitElement = testUnit.element; |
122 testLibraryElement = testUnitElement.library; | 121 testLibraryElement = testUnitElement.library; |
123 } | 122 } |
124 } | 123 } |
OLD | NEW |