-
Notifications
You must be signed in to change notification settings - Fork 344
[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
[Property Editor] Add APIs to support refactors from the Property Editor #9202
Conversation
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
for (final method in LspMethod.values) { | ||
if (method.methodName == methodName) return method; | ||
} | ||
return null; |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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];`
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, done!
There was a problem hiding this 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.
for (final method in LspMethod.values) { | ||
if (method.methodName == methodName) return method; | ||
} | ||
return null; |
There was a problem hiding this comment.
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];`
...evtools_app/lib/src/standalone_ui/ide_shared/property_editor/property_editor_controller.dart
Show resolved
Hide resolved
...evtools_app/lib/src/standalone_ui/ide_shared/property_editor/property_editor_controller.dart
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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 :-)
Work towards #8652
This PR:
editor_client
andapi_classes
to call the APIs added in https://dart-review.googlesource.com/c/sdk/+/428784 to support refactorsThis 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.