Skip to content

[Property Editor] Add APIs to support refactors from the Property Editor #9202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
May 27, 2025

Conversation

elliette
Copy link
Member

Work towards #8652

This PR:

This does not update the UI to show the available refactors. That will be follow-up.

Note: Fetching the available refactors is currently protected by the propertyEditorRefactors feature flag.

@elliette elliette requested a review from a team as a code owner May 21, 2025 20:31
@elliette elliette requested review from bkonyi and removed request for a team May 21, 2025 20:31
@elliette elliette requested review from kenzieschmoll and removed request for bkonyi May 21, 2025 23:08
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Goldens change due to Flutter SDK update

@@ -821,7 +821,7 @@ class _RenderScrollSemantics extends RenderProxyBox {
if (child.isTagged(RenderViewport.excludeFromScrolling)) {
excluded.add(child);
} else {
if (!child.hasFlag(SemanticsFlag.isHidden)) {
if (!child.flagsCollection.isHidden) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hasFlag is deprecated in latest Flutter version, see flutter/flutter#166101

@kenzieschmoll kenzieschmoll requested a review from DanTup May 22, 2025 22:09
Comment on lines 45 to 48
for (final method in LspMethod.values) {
if (method.methodName == methodName) return method;
}
return null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this be return LspMethod.values.firstWhereOrNull((method) => method.methodName == methodName)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For a minor perf increase I think you could also add something like:

static nameMap = LspMethod.values.asNameMap();

And then look it up as:

return nameMap[methodName];`

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Though we need the method name map instead of the name map, so I've added a static map for method name -> method to use for the look-up.

@@ -501,6 +528,105 @@ class EditableArgumentsResult with Serializable {
};
}

/// Constants for [CodeAction] prefixes used to filter the results returned by
/// an [LspMethod.codeAction] request.
abstract class CodeActionPrefixes {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add unit tests for all of the new logic in this file?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, added editor_client_test (also added test cases for editArgument and editableArguments)

@@ -99,6 +96,7 @@ void main() {
mockEditorClient.getEditableArguments(
textDocument: location.document,
position: location.position,
screenId: 'propertyEditorSidebar',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use the analytics constant here instead of the raw string?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, done!

Copy link
Contributor

@DanTup DanTup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a few comments. Mostly minor stuff, but the deserializing of command arguments I do think we need to remove because that's not public API, it should just be round-tripped whatever it is.

Comment on lines 45 to 48
for (final method in LspMethod.values) {
if (method.methodName == methodName) return method;
}
return null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For a minor perf increase I think you could also add something like:

static nameMap = LspMethod.values.asNameMap();

And then look it up as:

return nameMap[methodName];`

Copy link
Contributor

@DanTup DanTup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes from my comments all lgtm :-)

@elliette elliette added the autosubmit Merge PR when tree becomes green via auto submit App label May 27, 2025
@auto-submit auto-submit bot merged commit 2e5f834 into flutter:master May 27, 2025
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App release-notes-not-required
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants