| 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/src/protocol2.dart'; | 9 import 'package:analysis_server/src/protocol2.dart'; |
| 10 import 'package:analysis_server/src/services/correction/change.dart'; | 10 import 'package:analysis_server/src/services/correction/change.dart'; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 void assertRefactoringStatusOK(RefactoringStatus status) { | 89 void assertRefactoringStatusOK(RefactoringStatus status) { |
| 90 assertRefactoringStatus(status, RefactoringStatusSeverity.OK); | 90 assertRefactoringStatus(status, RefactoringStatusSeverity.OK); |
| 91 } | 91 } |
| 92 | 92 |
| 93 /** | 93 /** |
| 94 * Asserts that [refactoringChange] contains a [FileEdit] for [testFile], and | 94 * Asserts that [refactoringChange] contains a [FileEdit] for [testFile], and |
| 95 * it results the [expectedCode]. | 95 * it results the [expectedCode]. |
| 96 */ | 96 */ |
| 97 void assertTestChangeResult(String expectedCode) { | 97 void assertTestChangeResult(String expectedCode) { |
| 98 // prepare FileEdit | 98 // prepare FileEdit |
| 99 FileEdit fileEdit = refactoringChange.getFileEdit(testFile); | 99 SourceFileEdit fileEdit = refactoringChange.getFileEdit(testFile); |
| 100 expect(fileEdit, isNotNull); | 100 expect(fileEdit, isNotNull); |
| 101 // validate resulting code | 101 // validate resulting code |
| 102 String actualCode = SourceEdit.applySequence(testCode, fileEdit.edits); | 102 String actualCode = SourceEdit.applySequence(testCode, fileEdit.edits); |
| 103 expect(actualCode, expectedCode); | 103 expect(actualCode, expectedCode); |
| 104 } | 104 } |
| 105 | 105 |
| 106 void indexTestUnit(String code) { | 106 void indexTestUnit(String code) { |
| 107 resolveTestUnit(code); | 107 resolveTestUnit(code); |
| 108 index.indexUnit(context, testUnit); | 108 index.indexUnit(context, testUnit); |
| 109 } | 109 } |
| 110 | 110 |
| 111 void indexUnit(String file, String code) { | 111 void indexUnit(String file, String code) { |
| 112 Source source = addSource(file, code); | 112 Source source = addSource(file, code); |
| 113 CompilationUnit unit = resolveLibraryUnit(source); | 113 CompilationUnit unit = resolveLibraryUnit(source); |
| 114 index.indexUnit(context, unit); | 114 index.indexUnit(context, unit); |
| 115 } | 115 } |
| 116 | 116 |
| 117 void setUp() { | 117 void setUp() { |
| 118 super.setUp(); | 118 super.setUp(); |
| 119 index = createLocalMemoryIndex(); | 119 index = createLocalMemoryIndex(); |
| 120 searchEngine = new SearchEngineImpl(index); | 120 searchEngine = new SearchEngineImpl(index); |
| 121 } | 121 } |
| 122 } | 122 } |
| OLD | NEW |