| 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.rename; | 5 library test.services.refactoring.rename; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_services/correction/change.dart'; | 9 import 'package:analysis_services/correction/change.dart'; |
| 10 import 'package:analysis_services/refactoring/refactoring.dart'; | 10 import 'package:analysis_services/refactoring/refactoring.dart'; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 | 54 |
| 55 /** | 55 /** |
| 56 * Asserts that [refactoringChange] contains a [FileEdit] for [testFile], and | 56 * Asserts that [refactoringChange] contains a [FileEdit] for [testFile], and |
| 57 * it results the [expectedCode]. | 57 * it results the [expectedCode]. |
| 58 */ | 58 */ |
| 59 void assertTestChangeResult(String expectedCode) { | 59 void assertTestChangeResult(String expectedCode) { |
| 60 // prepare FileEdit | 60 // prepare FileEdit |
| 61 FileEdit fileEdit = refactoringChange.getFileEdit(testFile); | 61 FileEdit fileEdit = refactoringChange.getFileEdit(testFile); |
| 62 expect(fileEdit, isNotNull); | 62 expect(fileEdit, isNotNull); |
| 63 // validate resulting code | 63 // validate resulting code |
| 64 // TODO(paulberry): should the code under test be responsible for sorting | 64 String actualCode = Edit.applySequence(testCode, fileEdit.edits); |
| 65 // the edits? | |
| 66 String actualCode = Edit.applySorted(testCode, fileEdit.edits); | |
| 67 expect(actualCode, expectedCode); | 65 expect(actualCode, expectedCode); |
| 68 } | 66 } |
| 69 | 67 |
| 70 /** | 68 /** |
| 71 * Creates a new [RenameRefactoring] in [refactoring] for the [Element] of | 69 * Creates a new [RenameRefactoring] in [refactoring] for the [Element] of |
| 72 * the [SimpleIdentifier] at the given [search] pattern. | 70 * the [SimpleIdentifier] at the given [search] pattern. |
| 73 */ | 71 */ |
| 74 void createRenameRefactoringAtString(String search) { | 72 void createRenameRefactoringAtString(String search) { |
| 75 SimpleIdentifier identifier = findIdentifier(search); | 73 SimpleIdentifier identifier = findIdentifier(search); |
| 76 Element element = identifier.bestElement; | 74 Element element = identifier.bestElement; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 104 // void assertChangeResult(Change change, Source source, String expected) | 102 // void assertChangeResult(Change change, Source source, String expected) |
| 105 // { | 103 // { |
| 106 // SourceChange sourceChange = getSourceChange(compositeChange, source); | 104 // SourceChange sourceChange = getSourceChange(compositeChange, source); |
| 107 // assertNotNull("No change for: " + source.toString(), sourceChange); | 105 // assertNotNull("No change for: " + source.toString(), sourceChange); |
| 108 // String sourceResult = getChangeResult(context, source, sourceChange); | 106 // String sourceResult = getChangeResult(context, source, sourceChange); |
| 109 // assertEquals(expected, sourceResult); | 107 // assertEquals(expected, sourceResult); |
| 110 //// AnalysisContext context = getAnalysisContext(); | 108 //// AnalysisContext context = getAnalysisContext(); |
| 111 //// assertChangeResult(context, compositeChange, source, expected); | 109 //// assertChangeResult(context, compositeChange, source, expected); |
| 112 // } | 110 // } |
| 113 } | 111 } |
| OLD | NEW |