| 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.refactoring; | 5 library test.services.refactoring; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/plugin/protocol/protocol.dart' | 9 import 'package:analysis_server/plugin/protocol/protocol.dart' |
| 10 show | 10 show |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 /** | 55 /** |
| 56 * Asserts that [refactoringChange] contains a [FileEdit] for the file | 56 * Asserts that [refactoringChange] contains a [FileEdit] for the file |
| 57 * with the given [path], and it results the [expectedCode]. | 57 * with the given [path], and it results the [expectedCode]. |
| 58 */ | 58 */ |
| 59 void assertFileChangeResult(String path, String expectedCode) { | 59 void assertFileChangeResult(String path, String expectedCode) { |
| 60 // prepare FileEdit | 60 // prepare FileEdit |
| 61 SourceFileEdit fileEdit = refactoringChange.getFileEdit(path); | 61 SourceFileEdit fileEdit = refactoringChange.getFileEdit(path); |
| 62 expect(fileEdit, isNotNull, reason: 'No file edit for $path'); | 62 expect(fileEdit, isNotNull, reason: 'No file edit for $path'); |
| 63 // validate resulting code | 63 // validate resulting code |
| 64 File file = provider.getResource(path); | 64 File file = provider.getResource(path); |
| 65 Source source = file.createSource(); | 65 String ini = file.readAsStringSync(); |
| 66 String ini = context.getContents(source).data; | |
| 67 String actualCode = SourceEdit.applySequence(ini, fileEdit.edits); | 66 String actualCode = SourceEdit.applySequence(ini, fileEdit.edits); |
| 68 expect(actualCode, expectedCode); | 67 expect(actualCode, expectedCode); |
| 69 } | 68 } |
| 70 | 69 |
| 71 /** | 70 /** |
| 72 * Asserts that [refactoringChange] does not contain a [FileEdit] for the file | 71 * Asserts that [refactoringChange] does not contain a [FileEdit] for the file |
| 73 * with the given [path]. | 72 * with the given [path]. |
| 74 */ | 73 */ |
| 75 void assertNoFileChange(String path) { | 74 void assertNoFileChange(String path) { |
| 76 SourceFileEdit fileEdit = refactoringChange.getFileEdit(path); | 75 SourceFileEdit fileEdit = refactoringChange.getFileEdit(path); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 void setUp() { | 179 void setUp() { |
| 181 super.setUp(); | 180 super.setUp(); |
| 182 if (enableNewAnalysisDriver) { | 181 if (enableNewAnalysisDriver) { |
| 183 searchEngine = new SearchEngineImpl2([driver]); | 182 searchEngine = new SearchEngineImpl2([driver]); |
| 184 } else { | 183 } else { |
| 185 index = createMemoryIndex(); | 184 index = createMemoryIndex(); |
| 186 searchEngine = new SearchEngineImpl(index); | 185 searchEngine = new SearchEngineImpl(index); |
| 187 } | 186 } |
| 188 } | 187 } |
| 189 } | 188 } |
| OLD | NEW |