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

Side by Side Diff: pkg/analysis_services/test/refactoring/rename_local_test.dart

Issue 458063002: Initial work on refactorings. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information.
7
8 library test.services.refactoring.rename_local;
9
10 import 'package:analysis_services/correction/change.dart';
11 import 'package:analysis_services/correction/status.dart';
12 import 'package:analysis_services/index/index.dart';
13 import 'package:analysis_services/index/local_memory_index.dart';
14 import 'package:analysis_services/refactoring/refactoring.dart';
15 import 'package:analysis_services/search/search_engine.dart';
16 import 'package:analysis_services/src/correction/source_range.dart';
17 import 'package:analysis_services/src/search/search_engine.dart';
18 import 'package:analysis_testing/abstract_single_unit.dart';
19 import 'package:analysis_testing/reflective_tests.dart';
20 import 'package:analyzer/src/generated/ast.dart';
21 import 'package:analyzer/src/generated/element.dart';
22 import 'package:analyzer/src/generated/source.dart';
23 import 'package:typed_mock/typed_mock.dart';
24 import 'package:unittest/unittest.dart';
25
26
27
28 main() {
29 groupSep = ' | ';
30 runReflectiveTests(RenameLocalTest);
31 }
32
33
34 @ReflectiveTestCase()
35 class RenameLocalTest extends RenameRefactoringTest {
36 void test_createChange_localVariable() {
37 indexTestUnit('''
38 main() {
39 int test = 0;
40 test = 1;
41 test += 2;
42 print(test);
43 }
44 ''');
45 // configure refactoring
46 createRenameRefactoringAtString('test = 0');
47 print(refactoring.refactoringName);
48 expect(refactoring.refactoringName, 'Rename Local Variable');
49 refactoring.newName = 'newName';
50 // validate change
51 // TODO(scheglov)
52 // assertSuccessfulRename(
53 // "// filler filler filler filler filler filler filler filler filler fil ler",
54 // "main() {",
55 // " int newName = 0;",
56 // " newName = 1;",
57 // " newName += 2;",
58 // " print(newName);",
59 // "}");
60 }
61 }
62
63
64 /**
65 * The base class for all [RenameRefactoring] tests.
66 *
67 * TODO(scheglov) extract
68 */
69 class RenameRefactoringTest extends AbstractSingleUnitTest {
70 Index index;
71 SearchEngineImpl searchEngine;
72
73 RenameRefactoring refactoring;
74 Change refactoringChange;
75
76 /**
77 * Creates a new [RenameRefactoring] in [refactoringC] for the [Element] of
78 * the [SimpleIdentifier] at the given [search] pattern.
79 */
80 void createRenameRefactoringAtString(String search) {
81 SimpleIdentifier identifier = findIdentifier(search);
82 Element element = identifier.bestElement;
83 // if (element instanceof PrefixElement) {
84 // element = IndexContributor.getImportElement(identifier);
85 // }
86 refactoring = createRenameRefactoring(searchEngine, element);
87 }
88
89 void indexTestUnit(String code) {
90 resolveTestUnit(code);
91 index.indexUnit(context, testUnit);
92 }
93
94 void setUp() {
95 super.setUp();
96 index = createLocalMemoryIndex();
97 searchEngine = new SearchEngineImpl(index);
98 }
99 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698