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

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

Issue 530123002: Impements 'names', 'offsets' and 'lengths' for ExtractMethodRefactoring. (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
« no previous file with comments | « pkg/analysis_server/lib/src/services/refactoring/extract_method.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.extract_method; 5 library test.services.refactoring.extract_method;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/protocol.dart'; 9 import 'package:analysis_server/src/protocol.dart';
10 import 'package:analysis_server/src/services/refactoring/extract_method.dart'; 10 import 'package:analysis_server/src/services/refactoring/extract_method.dart';
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 class A { 1003 class A {
1004 main() { 1004 main() {
1005 print(1 + 2); 1005 print(1 + 2);
1006 } 1006 }
1007 } 1007 }
1008 '''); 1008 ''');
1009 _createRefactoringForString('1 + 2'); 1009 _createRefactoringForString('1 + 2');
1010 expect(refactoring.refactoringName, 'Extract Method'); 1010 expect(refactoring.refactoringName, 'Extract Method');
1011 } 1011 }
1012 1012
1013 test_names_singleExpression() {
1014 indexTestUnit('''
1015 class TreeItem {}
1016 TreeItem getSelectedItem() => null;
1017 process(my) {}
1018 main() {
1019 process(getSelectedItem()); // marker
1020 int treeItem = 0;
1021 }
1022 ''');
1023 _createRefactoringWithSuffix('getSelectedItem()', '); // marker');
1024 // check names
1025 return refactoring.checkInitialConditions().then((_) {
1026 expect(
1027 refactoring.names,
1028 unorderedEquals(['selectedItem', 'item', 'my', 'treeItem2']));
1029 });
1030 }
1031
1032 test_offsets_lengths() {
1033 indexTestUnit('''
1034 main() {
1035 main() {
1036 int a = 1 + 2;
1037 int b = 1 + 2;
1038 }
1039 }
1040 ''');
1041 _createRefactoringForString('1 + 2');
1042 // apply refactoring
1043 return refactoring.checkInitialConditions().then((_) {
1044 expect(
1045 refactoring.offsets,
1046 unorderedEquals([findOffset('1 + 2'), findOffset('1 + 2')]));
1047 expect(refactoring.lengths, unorderedEquals([5, 6]));
1048 });
1049 }
1050
1013 test_setExtractGetter() { 1051 test_setExtractGetter() {
1014 indexTestUnit(''' 1052 indexTestUnit('''
1015 main() { 1053 main() {
1016 int a = 1 + 2; 1054 int a = 1 + 2;
1017 } 1055 }
1018 '''); 1056 ''');
1019 _createRefactoringForString('1 + 2'); 1057 _createRefactoringForString('1 + 2');
1020 // apply refactoring 1058 // apply refactoring
1021 return assertRefactoringConditionsOK().then((_) { 1059 return assertRefactoringConditionsOK().then((_) {
1022 expect(refactoring.canCreateGetter, true); 1060 expect(refactoring.canCreateGetter, true);
(...skipping 1194 matching lines...) Expand 10 before | Expand all | Expand 10 after
2217 int length = search.length; 2255 int length = search.length;
2218 _createRefactoring(offset, length); 2256 _createRefactoring(offset, length);
2219 } 2257 }
2220 2258
2221 void _createRefactoringWithSuffix(String selectionSearch, String suffix) { 2259 void _createRefactoringWithSuffix(String selectionSearch, String suffix) {
2222 int offset = findOffset(selectionSearch + suffix); 2260 int offset = findOffset(selectionSearch + suffix);
2223 int length = selectionSearch.length; 2261 int length = selectionSearch.length;
2224 _createRefactoring(offset, length); 2262 _createRefactoring(offset, length);
2225 } 2263 }
2226 } 2264 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/services/refactoring/extract_method.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698