mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 12:24:24 +00:00
[analysis_server] Fix "Move Top Level" when multi-selection includes an unnamed extension
Fixes https://github.com/dart-lang/sdk/issues/53888 Change-Id: I034473d3a37b835c5dd81b76950b4b46d2cbc59d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332428 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
parent
8473e65472
commit
7e8ba2a708
2 changed files with 29 additions and 1 deletions
|
@ -238,7 +238,7 @@ class MoveTopLevelToFile extends RefactoringProducer {
|
|||
} else if (node is EnumDeclaration && validSelection(node.name)) {
|
||||
name = node.name.lexeme;
|
||||
} else if (node is ExtensionDeclaration && validSelection(node.name)) {
|
||||
name = node.name!.lexeme;
|
||||
name = node.name?.lexeme;
|
||||
} else if (node is FunctionDeclaration &&
|
||||
node.parent is CompilationUnit &&
|
||||
validSelection(node.name)) {
|
||||
|
|
|
@ -1122,6 +1122,34 @@ class B {}
|
|||
);
|
||||
}
|
||||
|
||||
Future<void> test_multiple_withUnnamedExtension() async {
|
||||
var originalSource = '''
|
||||
class A {}
|
||||
|
||||
[!class ClassToMove1 {}
|
||||
extension on Int {}
|
||||
class ClassToMove2 {}!]
|
||||
|
||||
class B {}
|
||||
''';
|
||||
|
||||
var expected = '''
|
||||
>>>>>>>>>> lib/class_to_move1.dart created
|
||||
class ClassToMove1 {}
|
||||
extension on Int {}
|
||||
class ClassToMove2 {}
|
||||
>>>>>>>>>> lib/main.dart
|
||||
class A {}
|
||||
|
||||
class B {}
|
||||
''';
|
||||
await _multipleDeclarations(
|
||||
originalSource: originalSource,
|
||||
expected: expected,
|
||||
count: 3,
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> test_none_comment() async {
|
||||
addTestSource('''
|
||||
// Comm^ent
|
||||
|
|
Loading…
Reference in a new issue