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

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

Issue 1059133003: Issue 23091. Fix for adding import prefix before string-interpolated identifier. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix for identifier in curly brackets. Created 5 years, 8 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
« no previous file with comments | « pkg/analysis_server/lib/src/services/refactoring/rename_import.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_import; 5 library test.services.refactoring.rename_import;
6 6
7 import 'package:analysis_server/src/protocol.dart'; 7 import 'package:analysis_server/src/protocol.dart';
8 import 'package:analyzer/src/generated/ast.dart'; 8 import 'package:analyzer/src/generated/ast.dart';
9 import 'package:unittest/unittest.dart'; 9 import 'package:unittest/unittest.dart';
10 10
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 import 'dart:async'; 59 import 'dart:async';
60 import 'dart:math' as newName show Random, min hide max; 60 import 'dart:math' as newName show Random, min hide max;
61 main() { 61 main() {
62 Future f; 62 Future f;
63 newName.Random r; 63 newName.Random r;
64 newName.min(1, 2); 64 newName.min(1, 2);
65 } 65 }
66 '''); 66 ''');
67 } 67 }
68 68
69 test_createChange_add_interpolationExpression_hasCurlyBrackets() {
70 indexTestUnit(r'''
71 import 'dart:async';
72 main() {
73 Future f;
74 print('Future type: ${Future}');
75 }
76 ''');
77 // configure refactoring
78 _createRefactoring("import 'dart:async");
79 expect(refactoring.refactoringName, 'Rename Import Prefix');
80 refactoring.newName = 'newName';
81 // validate change
82 return assertSuccessfulRefactoring(r'''
83 import 'dart:async' as newName;
84 main() {
85 newName.Future f;
86 print('Future type: ${newName.Future}');
87 }
88 ''');
89 }
90
91 test_createChange_add_interpolationExpression_noCurlyBrackets() {
92 indexTestUnit(r'''
93 import 'dart:async';
94 main() {
95 Future f;
96 print('Future type: $Future');
97 }
98 ''');
99 // configure refactoring
100 _createRefactoring("import 'dart:async");
101 expect(refactoring.refactoringName, 'Rename Import Prefix');
102 refactoring.newName = 'newName';
103 // validate change
104 return assertSuccessfulRefactoring(r'''
105 import 'dart:async' as newName;
106 main() {
107 newName.Future f;
108 print('Future type: ${newName.Future}');
109 }
110 ''');
111 }
112
69 test_createChange_change_className() { 113 test_createChange_change_className() {
70 indexTestUnit(''' 114 indexTestUnit('''
71 import 'dart:math' as test; 115 import 'dart:math' as test;
72 import 'dart:async' as test; 116 import 'dart:async' as test;
73 main() { 117 main() {
74 test.Future f; 118 test.Future f;
75 } 119 }
76 '''); 120 ''');
77 // configure refactoring 121 // configure refactoring
78 _createRefactoring("import 'dart:async"); 122 _createRefactoring("import 'dart:async");
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 expect(refactoring.refactoringName, 'Rename Import Prefix'); 221 expect(refactoring.refactoringName, 'Rename Import Prefix');
178 expect(refactoring.oldName, ''); 222 expect(refactoring.oldName, '');
179 } 223 }
180 224
181 void _createRefactoring(String search) { 225 void _createRefactoring(String search) {
182 ImportDirective directive = 226 ImportDirective directive =
183 findNodeAtString(search, (node) => node is ImportDirective); 227 findNodeAtString(search, (node) => node is ImportDirective);
184 createRenameRefactoringForElement(directive.element); 228 createRenameRefactoringForElement(directive.element);
185 } 229 }
186 } 230 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/services/refactoring/rename_import.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698