Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion flutter-candidate.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
dd671fae53d37eb15e0f8fc94cd52c2f2ff147ee
63903561033d7fc2f33b67239f2002d0ee529b48
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ extension PropertyEditorSidebar on Never {
required String argType,
}) => 'applyEditRequest-$argType-$argName';

/// Analytics event for a "Wrap with" refactor request.
static String applyWrapWithRefactorRequest({required String refactorName}) =>
'wrapWithRefactor-$refactorName';

/// Analytics event on completion of an edit.
static String applyEditComplete({
required String argName,
Expand Down
20 changes: 15 additions & 5 deletions packages/devtools_app/lib/src/shared/ui/common_widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -612,12 +612,14 @@ class ToolbarAction extends StatelessWidget {
super.key,
this.size,
this.style,
this.buttonStyle,
this.color,
this.gaScreen,
this.gaSelection,
}) : assert((gaScreen == null) == (gaSelection == null));

final TextStyle? style;
final ButtonStyle? buttonStyle;
final IconData icon;
final Color? color;
final String? tooltip;
Expand All @@ -632,6 +634,7 @@ class ToolbarAction extends StatelessWidget {
onPressed: onPressed,
tooltip: tooltip,
style: style,
buttonStyle: buttonStyle,
gaScreen: gaScreen,
gaSelection: gaSelection,
child: Icon(
Expand All @@ -650,11 +653,13 @@ class SmallAction extends StatelessWidget {
this.tooltip,
super.key,
this.style,
this.buttonStyle,
this.gaScreen,
this.gaSelection,
}) : assert((gaScreen == null) == (gaSelection == null));

final TextStyle? style;
final ButtonStyle? buttonStyle;
final Widget child;
final String? tooltip;
final VoidCallback? onPressed;
Expand All @@ -664,11 +669,13 @@ class SmallAction extends StatelessWidget {
@override
Widget build(BuildContext context) {
final button = TextButton(
style: TextButton.styleFrom(
padding: EdgeInsets.zero,
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
textStyle: style,
),
style:
buttonStyle ??
TextButton.styleFrom(
padding: EdgeInsets.zero,
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
textStyle: style,
),
onPressed: () {
if (gaScreen != null && gaSelection != null) {
ga.select(gaScreen!, gaSelection!);
Expand Down Expand Up @@ -2126,6 +2133,7 @@ class ContextMenuButton extends StatelessWidget {
this.gaItem,
this.buttonWidth = defaultWidth,
this.icon = Icons.more_vert,
this.style,
double? iconSize,
}) : iconSize = iconSize ?? tableIconSize;

Expand All @@ -2138,6 +2146,7 @@ class ContextMenuButton extends StatelessWidget {
final List<Widget> menuChildren;
final IconData icon;
final double iconSize;
final ButtonStyle? style;
final double buttonWidth;

@override
Expand All @@ -2152,6 +2161,7 @@ class ContextMenuButton extends StatelessWidget {
icon: icon,
size: iconSize,
color: color,
buttonStyle: style,
onPressed: () {
if (gaScreen != null && gaItem != null) {
ga.select(gaScreen!, gaItem!);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,17 @@ class PropertyEditorController extends DisposableController
);
}

Future<GenericApiResponse?> executeCommand({
required String commandName,
required List<Object?> commandArgs,
}) {
return editorClient.executeCommand(
commandName: commandName,
commandArgs: commandArgs,
screenId: gac.PropertyEditorSidebar.id,
);
}

int hashProperty(EditableProperty property) {
final widgetData = editableWidgetData.value;
if (widgetData == null) {
Expand Down Expand Up @@ -212,14 +223,18 @@ class PropertyEditorController extends DisposableController
CodeActionResult? refactorsResult;
// TODO(https://github.com/flutter/devtools/issues/8652): Enable refactors
// in the Property Editor by default.
if (FeatureFlags.propertyEditorRefactors) {
// Get any supported refactors for the current position.
if (editableArgsResult != null && FeatureFlags.propertyEditorRefactors) {
// Fetch the refactors using the start of the editable arguments' range,
// which corresponds to the widget constructor name. This ensures that the
// refactors are always available, even when the cursor is within the
// parameter list. See https://github.com/flutter/devtools/issues/9221.
final position = editableArgsResult.range?.start ?? cursorPosition;
// TODO(elliette): Consider updating the widget data immediately without
// waiting for the refactors result, then updating the refactor buttons
// once the refactors result is available.
refactorsResult = await editorClient.getRefactors(
textDocument: textDocument,
range: EditorRange(start: cursorPosition, end: cursorPosition),
range: EditorRange(start: position, end: position),
screenId: gac.PropertyEditorSidebar.id,
);
}
Expand Down Expand Up @@ -275,6 +290,7 @@ class PropertyEditorController extends DisposableController
TextDocument? document,
CursorPosition? cursorPosition,
EditorRange? range,
List<CodeActionCommand>? refactors,
Comment thread
elliette marked this conversation as resolved.
}) {
setActiveFilter();
if (editableArgsResult != null) {
Expand All @@ -283,9 +299,7 @@ class PropertyEditorController extends DisposableController
.map(argToProperty)
.nonNulls
.toList(),
// TODO(https://github.com/flutter/devtools/issues/8652): Add tests for
// refactors.
refactors: [],
refactors: refactors ?? [],
name: editableArgsResult.name,
documentation: editableArgsResult.documentation,
fileUri: document?.uriAsString,
Expand Down
Loading