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

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

Issue 497393002: Make more use of generated code in analysis server. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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 SourceChange,
10 SourceFileEdit; 10 SourceEdit, SourceFileEdit;
11 import 'package:analysis_server/src/services/correction/change.dart';
12 import 'package:analysis_server/src/services/correction/namespace.dart'; 11 import 'package:analysis_server/src/services/correction/namespace.dart';
13 import 'package:analysis_server/src/services/refactoring/refactoring.dart'; 12 import 'package:analysis_server/src/services/refactoring/refactoring.dart';
14 import 'package:analyzer/file_system/file_system.dart'; 13 import 'package:analyzer/file_system/file_system.dart';
15 import 'package:analyzer/src/generated/ast.dart'; 14 import 'package:analyzer/src/generated/ast.dart';
16 import 'package:analyzer/src/generated/element.dart'; 15 import 'package:analyzer/src/generated/element.dart';
17 import 'package:analyzer/src/generated/source.dart'; 16 import 'package:analyzer/src/generated/source.dart';
18 import 'package:unittest/unittest.dart'; 17 import 'package:unittest/unittest.dart';
19 18
20 import 'abstract_refactoring.dart'; 19 import 'abstract_refactoring.dart';
21 20
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 // all potential offsets are marked as such 69 // all potential offsets are marked as such
71 expect(expectedOffsets, isEmpty); 70 expect(expectedOffsets, isEmpty);
72 } 71 }
73 72
74 /** 73 /**
75 * Checks that all conditions are OK and the result of applying the [Change] 74 * Checks that all conditions are OK and the result of applying the [Change]
76 * to [testUnit] is [expectedCode]. 75 * to [testUnit] is [expectedCode].
77 */ 76 */
78 Future assertSuccessfulRename(String expectedCode) { 77 Future assertSuccessfulRename(String expectedCode) {
79 return assertRefactoringConditionsOK().then((_) { 78 return assertRefactoringConditionsOK().then((_) {
80 return refactoring.createChange().then((Change refactoringChange) { 79 return refactoring.createChange().then((SourceChange refactoringChange) {
81 this.refactoringChange = refactoringChange; 80 this.refactoringChange = refactoringChange;
82 assertTestChangeResult(expectedCode); 81 assertTestChangeResult(expectedCode);
83 }); 82 });
84 }); 83 });
85 } 84 }
86 85
87 /** 86 /**
88 * Creates a new [RenameRefactoring] in [refactoring] for the [Element] of 87 * Creates a new [RenameRefactoring] in [refactoring] for the [Element] of
89 * the [SimpleIdentifier] at the given [search] pattern. 88 * the [SimpleIdentifier] at the given [search] pattern.
90 */ 89 */
(...skipping 12 matching lines...) Expand all
103 */ 102 */
104 void createRenameRefactoringForElement(Element element) { 103 void createRenameRefactoringForElement(Element element) {
105 refactoring = new RenameRefactoring(searchEngine, element); 104 refactoring = new RenameRefactoring(searchEngine, element);
106 expect(refactoring, isNotNull, reason: "No refactoring for '$element'."); 105 expect(refactoring, isNotNull, reason: "No refactoring for '$element'.");
107 } 106 }
108 107
109 /** 108 /**
110 * Returns the [Edit] with the given [id], maybe `null`. 109 * Returns the [Edit] with the given [id], maybe `null`.
111 */ 110 */
112 SourceEdit findEditById(String id) { 111 SourceEdit findEditById(String id) {
113 for (SourceFileEdit fileEdit in refactoringChange.fileEdits) { 112 for (SourceFileEdit fileEdit in refactoringChange.edits) {
114 for (SourceEdit edit in fileEdit.edits) { 113 for (SourceEdit edit in fileEdit.edits) {
115 if (edit.id == id) { 114 if (edit.id == id) {
116 return edit; 115 return edit;
117 } 116 }
118 } 117 }
119 } 118 }
120 return null; 119 return null;
121 } 120 }
122 121
123 // /** 122 // /**
(...skipping 10 matching lines...) Expand all
134 // void assertChangeResult(Change change, Source source, String expected) 133 // void assertChangeResult(Change change, Source source, String expected)
135 // { 134 // {
136 // SourceChange sourceChange = getSourceChange(compositeChange, source); 135 // SourceChange sourceChange = getSourceChange(compositeChange, source);
137 // assertNotNull("No change for: " + source.toString(), sourceChange); 136 // assertNotNull("No change for: " + source.toString(), sourceChange);
138 // String sourceResult = getChangeResult(context, source, sourceChange); 137 // String sourceResult = getChangeResult(context, source, sourceChange);
139 // assertEquals(expected, sourceResult); 138 // assertEquals(expected, sourceResult);
140 //// AnalysisContext context = getAnalysisContext(); 139 //// AnalysisContext context = getAnalysisContext();
141 //// assertChangeResult(context, compositeChange, source, expected); 140 //// assertChangeResult(context, compositeChange, source, expected);
142 // } 141 // }
143 } 142 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698