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

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

Issue 1786013004: Start using the new index in Analysis Server. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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
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_library; 5 library test.services.refactoring.rename_library;
6 6
7 import 'package:analysis_server/plugin/protocol/protocol.dart'; 7 import 'package:analysis_server/plugin/protocol/protocol.dart';
8 import 'package:analyzer/src/generated/source.dart'; 8 import 'package:analyzer/src/generated/source.dart';
9 import 'package:test_reflective_loader/test_reflective_loader.dart'; 9 import 'package:test_reflective_loader/test_reflective_loader.dart';
10 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 test_createChange() async { 45 test_createChange() async {
46 Source unitSource = addSource( 46 Source unitSource = addSource(
47 '/part.dart', 47 '/part.dart',
48 ''' 48 '''
49 part of my.app; 49 part of my.app;
50 '''); 50 ''');
51 indexTestUnit(''' 51 indexTestUnit('''
52 library my.app; 52 library my.app;
53 part 'part.dart'; 53 part 'part.dart';
54 '''); 54 ''');
55 index.index( 55 index.indexUnit(context.resolveCompilationUnit2(unitSource, testSource));
56 context, context.resolveCompilationUnit2(unitSource, testSource));
57 // configure refactoring 56 // configure refactoring
58 _createRenameRefactoring(); 57 _createRenameRefactoring();
59 expect(refactoring.refactoringName, 'Rename Library'); 58 expect(refactoring.refactoringName, 'Rename Library');
60 expect(refactoring.elementKindName, 'library'); 59 expect(refactoring.elementKindName, 'library');
61 refactoring.newName = 'the.new.name'; 60 refactoring.newName = 'the.new.name';
62 // validate change 61 // validate change
63 await assertSuccessfulRefactoring(''' 62 await assertSuccessfulRefactoring('''
64 library the.new.name; 63 library the.new.name;
65 part 'part.dart'; 64 part 'part.dart';
66 '''); 65 ''');
67 assertFileChangeResult( 66 assertFileChangeResult(
68 '/part.dart', 67 '/part.dart',
69 ''' 68 '''
70 part of the.new.name; 69 part of the.new.name;
71 '''); 70 ''');
72 } 71 }
73 72
74 test_createChange_hasWhitespaces() async { 73 test_createChange_hasWhitespaces() async {
75 Source unitSource = addSource( 74 Source unitSource = addSource(
76 '/part.dart', 75 '/part.dart',
77 ''' 76 '''
78 part of my . app; 77 part of my . app;
79 '''); 78 ''');
80 indexTestUnit(''' 79 indexTestUnit('''
81 library my . app; 80 library my . app;
82 part 'part.dart'; 81 part 'part.dart';
83 '''); 82 ''');
84 index.index( 83 index.indexUnit(context.resolveCompilationUnit2(unitSource, testSource));
85 context, context.resolveCompilationUnit2(unitSource, testSource));
86 // configure refactoring 84 // configure refactoring
87 _createRenameRefactoring(); 85 _createRenameRefactoring();
88 expect(refactoring.refactoringName, 'Rename Library'); 86 expect(refactoring.refactoringName, 'Rename Library');
89 expect(refactoring.elementKindName, 'library'); 87 expect(refactoring.elementKindName, 'library');
90 refactoring.newName = 'the.new.name'; 88 refactoring.newName = 'the.new.name';
91 // validate change 89 // validate change
92 await assertSuccessfulRefactoring(''' 90 await assertSuccessfulRefactoring('''
93 library the.new.name; 91 library the.new.name;
94 part 'part.dart'; 92 part 'part.dart';
95 '''); 93 ''');
96 assertFileChangeResult( 94 assertFileChangeResult(
97 '/part.dart', 95 '/part.dart',
98 ''' 96 '''
99 part of the.new.name; 97 part of the.new.name;
100 '''); 98 ''');
101 } 99 }
102 100
103 void _createRenameRefactoring() { 101 void _createRenameRefactoring() {
104 createRenameRefactoringForElement(testUnitElement.library); 102 createRenameRefactoringForElement(testUnitElement.library);
105 } 103 }
106 } 104 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698