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.completion.support; | 5 library test.completion.support; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection'; | 8 import 'dart:collection'; |
9 | 9 |
10 import 'package:analysis_server/plugin/protocol/protocol.dart'; | 10 import 'package:analysis_server/plugin/protocol/protocol.dart'; |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 LocationSpec test = new LocationSpec(id); | 144 LocationSpec test = new LocationSpec(id); |
145 tests[id] = test; | 145 tests[id] = test; |
146 test.testLocation = index; | 146 test.testLocation = index; |
147 } else { | 147 } else { |
148 modifiedPosition = index + 1; | 148 modifiedPosition = index + 1; |
149 } | 149 } |
150 modifiedSource = modifiedSource.substring(0, index) + | 150 modifiedSource = modifiedSource.substring(0, index) + |
151 modifiedSource.substring(index + n); | 151 modifiedSource.substring(index + n); |
152 } | 152 } |
153 if (modifiedSource == originalSource) { | 153 if (modifiedSource == originalSource) { |
154 throw new IllegalStateException("No tests in source: " + originalSource); | 154 throw new StateError("No tests in source: " + originalSource); |
155 } | 155 } |
156 for (String result in validationStrings) { | 156 for (String result in validationStrings) { |
157 if (result.length < 3) { | 157 if (result.length < 3) { |
158 throw new IllegalStateException("Invalid location result: " + result); | 158 throw new StateError("Invalid location result: " + result); |
159 } | 159 } |
160 String id = result.substring(0, 1); | 160 String id = result.substring(0, 1); |
161 String sign = result.substring(1, 2); | 161 String sign = result.substring(1, 2); |
162 String value = result.substring(2); | 162 String value = result.substring(2); |
163 LocationSpec test = tests[id]; | 163 LocationSpec test = tests[id]; |
164 if (test == null) { | 164 if (test == null) { |
165 throw new IllegalStateException( | 165 throw new StateError( |
166 "Invalid location result id: $id for: $result"); | 166 "Invalid location result id: $id for: $result"); |
167 } | 167 } |
168 test.source = modifiedSource; | 168 test.source = modifiedSource; |
169 if (sign == '+') { | 169 if (sign == '+') { |
170 test.positiveResults.add(value); | 170 test.positiveResults.add(value); |
171 } else if (sign == '-') { | 171 } else if (sign == '-') { |
172 test.negativeResults.add(value); | 172 test.negativeResults.add(value); |
173 } else { | 173 } else { |
174 String err = "Invalid location result sign: $sign for: $result"; | 174 String err = "Invalid location result sign: $sign for: $result"; |
175 throw new IllegalStateException(err); | 175 throw new StateError(err); |
176 } | 176 } |
177 } | 177 } |
178 List<String> badPoints = <String>[]; | 178 List<String> badPoints = <String>[]; |
179 List<String> badResults = <String>[]; | 179 List<String> badResults = <String>[]; |
180 for (LocationSpec test in tests.values) { | 180 for (LocationSpec test in tests.values) { |
181 if (test.testLocation == -1) { | 181 if (test.testLocation == -1) { |
182 badPoints.add(test.id); | 182 badPoints.add(test.id); |
183 } | 183 } |
184 if (test.positiveResults.isEmpty && test.negativeResults.isEmpty) { | 184 if (test.positiveResults.isEmpty && test.negativeResults.isEmpty) { |
185 badResults.add(test.id); | 185 badResults.add(test.id); |
186 } | 186 } |
187 } | 187 } |
188 if (!(badPoints.isEmpty && badResults.isEmpty)) { | 188 if (!(badPoints.isEmpty && badResults.isEmpty)) { |
189 StringBuffer err = new StringBuffer(); | 189 StringBuffer err = new StringBuffer(); |
190 if (!badPoints.isEmpty) { | 190 if (!badPoints.isEmpty) { |
191 err.write("No test location for tests:"); | 191 err.write("No test location for tests:"); |
192 for (String ch in badPoints) { | 192 for (String ch in badPoints) { |
193 err..write(' ')..write(ch); | 193 err..write(' ')..write(ch); |
194 } | 194 } |
195 err.write(' '); | 195 err.write(' '); |
196 } | 196 } |
197 if (!badResults.isEmpty) { | 197 if (!badResults.isEmpty) { |
198 err.write("No results for tests:"); | 198 err.write("No results for tests:"); |
199 for (String ch in badResults) { | 199 for (String ch in badResults) { |
200 err..write(' ')..write(ch); | 200 err..write(' ')..write(ch); |
201 } | 201 } |
202 } | 202 } |
203 throw new IllegalStateException(err.toString()); | 203 throw new StateError(err.toString()); |
204 } | 204 } |
205 return tests.values.toList(); | 205 return tests.values.toList(); |
206 } | 206 } |
207 } | 207 } |
OLD | NEW |