Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(470)

Side by Side Diff: pkg/analysis_server/test/services/refactoring/abstract_rename.dart

Issue 489973002: Initial 'Extract Local' implementation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: tweaks Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_server/src/protocol2.dart' show SourceEdit; 9 import 'package:analysis_server/src/protocol2.dart' show SourceEdit;
10 import 'package:analysis_server/src/services/correction/change.dart'; 10 import 'package:analysis_server/src/services/correction/change.dart';
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 Future assertSuccessfulRename(String expectedCode) { 77 Future assertSuccessfulRename(String expectedCode) {
78 return assertRefactoringConditionsOK().then((_) { 78 return assertRefactoringConditionsOK().then((_) {
79 return refactoring.createChange().then((Change refactoringChange) { 79 return refactoring.createChange().then((Change refactoringChange) {
80 this.refactoringChange = refactoringChange; 80 this.refactoringChange = refactoringChange;
81 assertTestChangeResult(expectedCode); 81 assertTestChangeResult(expectedCode);
82 }); 82 });
83 }); 83 });
84 } 84 }
85 85
86 /** 86 /**
87 * Asserts that [refactoringChange] contains a [FileEdit] for [testFile], and
88 * it results the [expectedCode].
89 */
90 void assertTestChangeResult(String expectedCode) {
91 // prepare FileEdit
92 FileEdit fileEdit = refactoringChange.getFileEdit(testFile);
93 expect(fileEdit, isNotNull);
94 // validate resulting code
95 String actualCode = applySequence(testCode, fileEdit.edits);
96 expect(actualCode, expectedCode);
97 }
98
99 /**
100 * Creates a new [RenameRefactoring] in [refactoring] for the [Element] of 87 * Creates a new [RenameRefactoring] in [refactoring] for the [Element] of
101 * the [SimpleIdentifier] at the given [search] pattern. 88 * the [SimpleIdentifier] at the given [search] pattern.
102 */ 89 */
103 void createRenameRefactoringAtString(String search) { 90 void createRenameRefactoringAtString(String search) {
104 SimpleIdentifier identifier = findIdentifier(search); 91 SimpleIdentifier identifier = findIdentifier(search);
105 Element element = identifier.bestElement; 92 Element element = identifier.bestElement;
106 if (element is PrefixElement) { 93 if (element is PrefixElement) {
107 element = getImportElement(identifier); 94 element = getImportElement(identifier);
108 } 95 }
109 createRenameRefactoringForElement(element); 96 createRenameRefactoringForElement(element);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 // void assertChangeResult(Change change, Source source, String expected) 133 // void assertChangeResult(Change change, Source source, String expected)
147 // { 134 // {
148 // SourceChange sourceChange = getSourceChange(compositeChange, source); 135 // SourceChange sourceChange = getSourceChange(compositeChange, source);
149 // assertNotNull("No change for: " + source.toString(), sourceChange); 136 // assertNotNull("No change for: " + source.toString(), sourceChange);
150 // String sourceResult = getChangeResult(context, source, sourceChange); 137 // String sourceResult = getChangeResult(context, source, sourceChange);
151 // assertEquals(expected, sourceResult); 138 // assertEquals(expected, sourceResult);
152 //// AnalysisContext context = getAnalysisContext(); 139 //// AnalysisContext context = getAnalysisContext();
153 //// assertChangeResult(context, compositeChange, source, expected); 140 //// assertChangeResult(context, compositeChange, source, expected);
154 // } 141 // }
155 } 142 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698