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

Side by Side Diff: pkg/analysis_server/test/services/correction/assist_test.dart

Issue 2613123003: Fix the rest of Quick Assist tests with the new analysis driver. (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « no previous file | 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.correction.assist; 5 library test.services.correction.assist;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/plugin/edit/assist/assist_core.dart'; 9 import 'package:analysis_server/plugin/edit/assist/assist_core.dart';
10 import 'package:analysis_server/plugin/edit/assist/assist_dart.dart'; 10 import 'package:analysis_server/plugin/edit/assist/assist_dart.dart';
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 testCode = r''' 496 testCode = r'''
497 part of my_app; 497 part of my_app;
498 main() { 498 main() {
499 var v = getFutureInt(); 499 var v = getFutureInt();
500 } 500 }
501 '''; 501 ''';
502 // add sources 502 // add sources
503 Source appSource = addSource('/app.dart', appCode); 503 Source appSource = addSource('/app.dart', appCode);
504 testSource = addSource('/test.dart', testCode); 504 testSource = addSource('/test.dart', testCode);
505 // resolve 505 // resolve
506 context.resolveCompilationUnit2(appSource, appSource); 506 if (enableNewAnalysisDriver) {
507 testUnit = context.resolveCompilationUnit2(testSource, appSource); 507 await resolveTestUnit(testCode);
508 testUnitElement = testUnit.element; 508 } else {
509 testLibraryElement = testUnitElement.library; 509 context.resolveCompilationUnit2(appSource, appSource);
510 testUnit = context.resolveCompilationUnit2(testSource, appSource);
511 testUnitElement = testUnit.element;
512 testLibraryElement = testUnitElement.library;
513 }
510 // prepare the assist 514 // prepare the assist
511 offset = findOffset('v = '); 515 offset = findOffset('v = ');
512 assist = await _assertHasAssist(DartAssistKind.ADD_TYPE_ANNOTATION); 516 assist = await _assertHasAssist(DartAssistKind.ADD_TYPE_ANNOTATION);
513 change = assist.change; 517 change = assist.change;
514 // verify 518 // verify
515 { 519 {
516 var testFileEdit = change.getFileEdit('/app.dart'); 520 var testFileEdit = change.getFileEdit('/app.dart');
517 var resultCode = SourceEdit.applySequence(appCode, testFileEdit.edits); 521 var resultCode = SourceEdit.applySequence(appCode, testFileEdit.edits);
518 expect( 522 expect(
519 resultCode, 523 resultCode,
(...skipping 2162 matching lines...) Expand 10 before | Expand all | Expand 10 after
2682 } 2686 }
2683 '''; 2687 ''';
2684 await assertHasAssistAt( 2688 await assertHasAssistAt(
2685 'is String', DartAssistKind.INTRODUCE_LOCAL_CAST_TYPE, expected); 2689 'is String', DartAssistKind.INTRODUCE_LOCAL_CAST_TYPE, expected);
2686 await assertHasAssistAt( 2690 await assertHasAssistAt(
2687 'while (p', DartAssistKind.INTRODUCE_LOCAL_CAST_TYPE, expected); 2691 'while (p', DartAssistKind.INTRODUCE_LOCAL_CAST_TYPE, expected);
2688 } 2692 }
2689 2693
2690 test_invalidSelection() async { 2694 test_invalidSelection() async {
2691 await resolveTestUnit(''); 2695 await resolveTestUnit('');
2692 List<Assist> assists = await computeAssists(plugin, context, 2696 offset = -1;
2693 resolutionMap.elementDeclaredByCompilationUnit(testUnit).source, -1, 0); 2697 length = 0;
2698 List<Assist> assists = await _computeAssists();
2694 expect(assists, isEmpty); 2699 expect(assists, isEmpty);
2695 } 2700 }
2696 2701
2697 test_invertIfStatement_blocks() async { 2702 test_invertIfStatement_blocks() async {
2698 await resolveTestUnit(''' 2703 await resolveTestUnit('''
2699 main() { 2704 main() {
2700 if (true) { 2705 if (true) {
2701 0; 2706 0;
2702 } else { 2707 } else {
2703 1; 2708 1;
(...skipping 1502 matching lines...) Expand 10 before | Expand all | Expand 10 after
4206 void _setStartEndSelection() { 4211 void _setStartEndSelection() {
4207 offset = findOffset('// start\n') + '// start\n'.length; 4212 offset = findOffset('// start\n') + '// start\n'.length;
4208 length = findOffset('// end') - offset; 4213 length = findOffset('// end') - offset;
4209 } 4214 }
4210 } 4215 }
4211 4216
4212 @reflectiveTest 4217 @reflectiveTest
4213 class AssistProcessorTest_Driver extends AssistProcessorTest { 4218 class AssistProcessorTest_Driver extends AssistProcessorTest {
4214 @override 4219 @override
4215 bool get enableNewAnalysisDriver => true; 4220 bool get enableNewAnalysisDriver => true;
4216
4217 @failingTest
4218 @override
4219 test_addTypeAnnotation_local_OK_addImport_notLibraryUnit() {
4220 return super.test_addTypeAnnotation_local_OK_addImport_notLibraryUnit();
4221 }
4222
4223 @failingTest
4224 @override
4225 test_invalidSelection() {
4226 return super.test_invalidSelection();
4227 }
4228 } 4221 }
4229 4222
4230 class _DartAssistContextForValues implements DartAssistContext { 4223 class _DartAssistContextForValues implements DartAssistContext {
4231 @override 4224 @override
4232 final Source source; 4225 final Source source;
4233 4226
4234 @override 4227 @override
4235 final int selectionOffset; 4228 final int selectionOffset;
4236 4229
4237 @override 4230 @override
4238 final int selectionLength; 4231 final int selectionLength;
4239 4232
4240 @override 4233 @override
4241 final AnalysisContext analysisContext; 4234 final AnalysisContext analysisContext;
4242 4235
4243 @override 4236 @override
4244 final CompilationUnit unit; 4237 final CompilationUnit unit;
4245 4238
4246 _DartAssistContextForValues(this.source, this.selectionOffset, 4239 _DartAssistContextForValues(this.source, this.selectionOffset,
4247 this.selectionLength, this.analysisContext, this.unit); 4240 this.selectionLength, this.analysisContext, this.unit);
4248 } 4241 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698