| 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.integration.analysis.domain; | 5 library test.integration.analysis.domain; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_testing/reflective_tests.dart'; | 9 import 'package:analysis_testing/reflective_tests.dart'; |
| 10 import 'package:path/path.dart'; | 10 import 'package:path/path.dart'; |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 String goodText = r''' | 192 String goodText = r''' |
| 193 main() { | 193 main() { |
| 194 print("Hello, world!"); | 194 print("Hello, world!"); |
| 195 }'''; | 195 }'''; |
| 196 String badText = goodText.replaceAll(';', ''); | 196 String badText = goodText.replaceAll(';', ''); |
| 197 writeFile(pathname, badText); | 197 writeFile(pathname, badText); |
| 198 standardAnalysisRoot(); | 198 standardAnalysisRoot(); |
| 199 return analysisFinished.then((_) { | 199 return analysisFinished.then((_) { |
| 200 // The contents on disk (badText) are missing a semicolon. | 200 // The contents on disk (badText) are missing a semicolon. |
| 201 expect(currentAnalysisErrors[pathname], isNot(isEmpty)); | 201 expect(currentAnalysisErrors[pathname], isNot(isEmpty)); |
| 202 var contentChange = { | 202 |
| 203 'content': goodText | |
| 204 }; | |
| 205 if (includeOffsetAndLengths) { | 203 if (includeOffsetAndLengths) { |
| 206 contentChange['offset'] = goodText.indexOf(';'); | 204 // Before we send a ChangeContentOverlay directive we need to send an |
| 207 contentChange['oldLength'] = 0; | 205 // AddContentOverlay directive. So send that with badText. |
| 208 contentChange['newLength'] = 1; | 206 return sendAnalysisUpdateContent({ |
| 207 pathname: { |
| 208 'type': 'add', |
| 209 'content': badText |
| 210 } |
| 211 }).then((_) => analysisFinished); |
| 209 } | 212 } |
| 210 return sendAnalysisUpdateContent({ | 213 }).then((_) { |
| 211 pathname: contentChange | 214 if (includeOffsetAndLengths) { |
| 212 }); | 215 return sendAnalysisUpdateContent({ |
| 216 pathname: { |
| 217 'type': 'change', |
| 218 'offset': goodText.indexOf(';'), |
| 219 'oldLength': 0, |
| 220 'replacement': ';' |
| 221 } |
| 222 }); |
| 223 } else { |
| 224 return sendAnalysisUpdateContent({ |
| 225 pathname: { |
| 226 'type': 'add', |
| 227 'content': goodText |
| 228 } |
| 229 }); |
| 230 } |
| 213 }).then((result) => analysisFinished).then((_) { | 231 }).then((result) => analysisFinished).then((_) { |
| 214 // There should be no errors now because the contents on disk have been | 232 // There should be no errors now because the contents on disk have been |
| 215 // overriden with goodText. | 233 // overriden with goodText. |
| 216 expect(currentAnalysisErrors[pathname], isEmpty); | 234 expect(currentAnalysisErrors[pathname], isEmpty); |
| 217 // TODO(paulberry): passing "checkTypes: false" to work around the fact | 235 // TODO(paulberry): passing "checkTypes: false" to work around the fact |
| 218 // that isContentChange doesn't permit 'content' to be null. | 236 // that isContentChange doesn't permit 'content' to be null. |
| 219 return sendAnalysisUpdateContent({ | 237 return sendAnalysisUpdateContent({ |
| 220 pathname: { | 238 pathname: { |
| 221 'content': null | 239 'type': 'remove' |
| 222 } | 240 } |
| 223 }, checkTypes: false); | 241 }); |
| 224 }).then((result) => analysisFinished).then((_) { | 242 }).then((result) => analysisFinished).then((_) { |
| 225 // Now there should be errors again, because the contents on disk are no | 243 // Now there should be errors again, because the contents on disk are no |
| 226 // longer overridden. | 244 // longer overridden. |
| 227 expect(currentAnalysisErrors[pathname], isNot(isEmpty)); | 245 expect(currentAnalysisErrors[pathname], isNot(isEmpty)); |
| 228 }); | 246 }); |
| 229 } | 247 } |
| 230 } | 248 } |
| 231 | 249 |
| 232 main() { | 250 main() { |
| 233 runReflectiveTests(AnalysisDomainIntegrationTest); | 251 runReflectiveTests(AnalysisDomainIntegrationTest); |
| 234 } | 252 } |
| OLD | NEW |