Improve flutter wrap assists when caret is at the offset of an argument list
Bug: https://github.com/Dart-Code/Dart-Code/issues/2492 Change-Id: I296f9396b3eedcbd1a63f272ed34c65f9d95d83b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152521 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Danny Tuppeny <danny@tuppeny.com>
This commit is contained in:
committed by
commit-bot@chromium.org
parent
898f2cc6c7
commit
87d431e8de
@@ -46,7 +46,19 @@ class FlutterWrap extends MultiCorrectionProducer {
|
||||
widgetExpressions.add(selectedNode);
|
||||
}
|
||||
} else {
|
||||
var widget = flutter.identifyWidgetExpression(analyzer.coveringNode);
|
||||
var coveringNode = analyzer.coveringNode;
|
||||
|
||||
// If the coveringNode is an argument list but the caret is exactly at the
|
||||
// start (before the opening paren) we should use the parent instead
|
||||
// as the user associates this location with the widget name:
|
||||
//
|
||||
// Text^('foo')
|
||||
if (coveringNode is ArgumentList &&
|
||||
coveringNode.offset == selectionOffset) {
|
||||
coveringNode = coveringNode.parent;
|
||||
}
|
||||
|
||||
var widget = flutter.identifyWidgetExpression(coveringNode);
|
||||
if (widget != null) {
|
||||
widgetExpressions.add(widget);
|
||||
}
|
||||
|
||||
@@ -118,6 +118,36 @@ class FakeFlutter {
|
||||
]);
|
||||
}
|
||||
}
|
||||
''');
|
||||
}
|
||||
|
||||
Future<void> test_endOfWidgetName() async {
|
||||
addFlutterPackage();
|
||||
await resolveTestUnit('''
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
class FakeFlutter {
|
||||
main() {
|
||||
return Container(
|
||||
child: Text/*caret*/('aaa'),
|
||||
);
|
||||
}
|
||||
}
|
||||
''');
|
||||
await assertHasAssist('''
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
class FakeFlutter {
|
||||
main() {
|
||||
return Container(
|
||||
child: Column(
|
||||
children: [
|
||||
Text('aaa'),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
''');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user