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

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

Issue 1161333002: Issue 23239. Fix for 'Create Class' Quick Fix i case of prefixed names. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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 | « pkg/analysis_server/lib/src/services/correction/fix_internal.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.correction.fix; 5 library test.services.correction.fix;
6 6
7 import 'package:analysis_server/edit/fix/fix_core.dart'; 7 import 'package:analysis_server/edit/fix/fix_core.dart';
8 import 'package:analysis_server/src/protocol.dart' hide AnalysisError; 8 import 'package:analysis_server/src/protocol.dart' hide AnalysisError;
9 import 'package:analysis_server/src/services/correction/fix.dart'; 9 import 'package:analysis_server/src/services/correction/fix.dart';
10 import 'package:analysis_server/src/services/correction/fix_internal.dart'; 10 import 'package:analysis_server/src/services/correction/fix_internal.dart';
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 main() { 382 main() {
383 Test v = null; 383 Test v = null;
384 } 384 }
385 385
386 class Test { 386 class Test {
387 } 387 }
388 '''); 388 ''');
389 _assertLinkedGroup(change.linkedEditGroups[0], ['Test v =', 'Test {']); 389 _assertLinkedGroup(change.linkedEditGroups[0], ['Test v =', 'Test {']);
390 } 390 }
391 391
392 void test_createClass_inLibraryOfPrefix() {
393 // TODO
394 String libCode = r'''
395 library my.lib;
396
397 class A {}
398 ''';
399 addSource('/lib.dart', libCode);
400 resolveTestUnit('''
401 import 'lib.dart' as lib;
402
403 main() {
404 lib.A a = null;
405 lib.Test t = null;
406 }
407 ''');
408 AnalysisError error = _findErrorToFix();
409 fix = _assertHasFix(DartFixKind.CREATE_CLASS, error);
410 change = fix.change;
411 // apply to "lib.dart"
412 List<SourceFileEdit> fileEdits = change.edits;
413 expect(fileEdits, hasLength(1));
414 SourceFileEdit fileEdit = change.edits[0];
415 expect(fileEdit.file, '/lib.dart');
416 expect(SourceEdit.applySequence(libCode, fileEdit.edits), r'''
417 library my.lib;
418
419 class A {}
420
421 class Test {
422 }
423 ''');
424 expect(change.linkedEditGroups, isEmpty);
425 }
426
392 void test_createClass_innerLocalFunction() { 427 void test_createClass_innerLocalFunction() {
393 resolveTestUnit(''' 428 resolveTestUnit('''
394 f() { 429 f() {
395 g() { 430 g() {
396 Test v = null; 431 Test v = null;
397 } 432 }
398 } 433 }
399 '''); 434 ''');
400 assertHasFix(DartFixKind.CREATE_CLASS, ''' 435 assertHasFix(DartFixKind.CREATE_CLASS, '''
401 f() { 436 f() {
(...skipping 3323 matching lines...) Expand 10 before | Expand all | Expand 10 after
3725 3760
3726 List<Position> _findResultPositions(List<String> searchStrings) { 3761 List<Position> _findResultPositions(List<String> searchStrings) {
3727 List<Position> positions = <Position>[]; 3762 List<Position> positions = <Position>[];
3728 for (String search in searchStrings) { 3763 for (String search in searchStrings) {
3729 int offset = resultCode.indexOf(search); 3764 int offset = resultCode.indexOf(search);
3730 positions.add(new Position(testFile, offset)); 3765 positions.add(new Position(testFile, offset));
3731 } 3766 }
3732 return positions; 3767 return positions;
3733 } 3768 }
3734 } 3769 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/services/correction/fix_internal.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698