-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[pigeon] Adds SwiftFunction annotation #2304
[pigeon] Adds SwiftFunction annotation #2304
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.
The code and the tests looks good to me. The design for SwiftFunction looks good to me too. The docstrings just need a bit of cleanup. Awesome work.
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.
lgtm thanks!
|
Validations Fail. |
# Conflicts: # packages/pigeon/CHANGELOG.md
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.
The analyzer warnings are because the analysis settings for the repository changed recently, sorry for the churn.
/// ie the name of function e the strings between the semicolons. | ||
/// Example: | ||
/// _swiftMethod('@SwiftFunction('add(_:with:)') void add(int x, int y)') | ||
/// will return 'void add(int _ x, int with y)' |
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.
Why remap the Dart APIs to a hybrid string that will never be used (and has no meaning in either language), only to re-extract the components later, instead of doing the mapping at the point of constructing the Swift code (as is done in the ObjC generator)?
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.
I followed this approach to minimize the changes. But, if this is not the better way, I could change to be similar with ObjC.
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.
I think having this intermediate format will likely make it harder to understand what's happening, and there's more potential for strange side effects (e.g., some new code trying to use the methods, and it not being obvious why they don't match the original source), so I'm concerned about the maintenance impact. I would much rather this transformation happen at the usage point even if it's more code in the short term.
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, I agree. I'll work on this update.
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.
@ailtonvivaz What is the status of this update?
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.
Fixed this. Is this approach better?
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.
Looks like I forgot to set the review state when I replied last time; updating the state to match the open comment above about moving when the name modification happens.
# Conflicts: # packages/pigeon/CHANGELOG.md # packages/pigeon/lib/ast.dart # packages/pigeon/test/swift_generator_test.dart
It appears you've broken some swift code/tests. Also, make sure to run the formatter cl tool with
to clean up the generated files before uploading them. |
…ckages into swift-function-annotation
Sorry, I was wrong about the breaking change. I reverted it back to 6.0.4. |
…ckages into swift-function-annotation
I think if you can fix these last few nits, and merge with main again, we should be able to land this shortly :) Thank you for the time and effort you put into this pr! |
# Conflicts: # packages/pigeon/CHANGELOG.md # packages/pigeon/lib/generator_tools.dart # packages/pigeon/mock_handler_tester/test/message.dart # packages/pigeon/mock_handler_tester/test/test.dart # packages/pigeon/pigeons/core_tests.dart # packages/pigeon/platform_tests/alternate_language_test_plugin/android/src/main/java/com/example/alternate_language_test_plugin/CoreTests.java # packages/pigeon/platform_tests/alternate_language_test_plugin/ios/Classes/CoreTests.gen.h # packages/pigeon/platform_tests/alternate_language_test_plugin/ios/Classes/CoreTests.gen.m # packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/core_tests.gen.dart # packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/flutter_unittests.gen.dart # packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/multiple_arity.gen.dart # packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/non_null_fields.gen.dart # packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/null_fields.gen.dart # packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/nullable_returns.gen.dart # packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/primitive.gen.dart # packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/core_tests.gen.dart # packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/CoreTests.gen.kt # packages/pigeon/platform_tests/test_plugin/ios/Classes/CoreTests.gen.swift # packages/pigeon/platform_tests/test_plugin/ios/Classes/TestPlugin.swift # packages/pigeon/platform_tests/test_plugin/macos/Classes/CoreTests.gen.swift # packages/pigeon/platform_tests/test_plugin/macos/Classes/TestPlugin.swift # packages/pigeon/platform_tests/test_plugin/windows/pigeon/core_tests.gen.cpp # packages/pigeon/platform_tests/test_plugin/windows/pigeon/core_tests.gen.h # packages/pigeon/pubspec.yaml
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.
Good work!
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.
LGTM with one comment nit. Thanks!
* main: (479 commits) removes raw ArrayLists (flutter#3101) Roll Flutter from c9affdb to 27f8ebd (15 revisions) (flutter#3098) [ci] Fix the new LUCI iOS build-all tasks (flutter#3099) [pigeon] [ObjC] Removes unused GetNullableObject function (flutter#3100) [pigeon] Swift host error handling (flutter#3084) Roll Flutter from a815ee6 to c9affdb (23 revisions) (flutter#3093) [ci] Enable min SDK version checks (flutter#3095) [pigeon] Fix C++ config handling (flutter#3094) [ci] Add LUCI version of iOS build-all (flutter#3096) [pigeon] Adds SwiftFunction annotation (flutter#2304) [flutter_adaptive_scaffold] Change `selectedIndex` on `standardNavigationRail` to allow null value. (flutter#3088) [pigeon] requires analyzer 5.2.0 (flutter#3090) Roll Flutter from c35efda to a815ee6 (22 revisions) (flutter#3089) [ci] Update legacy Flutter version tests (flutter#3087) Roll Flutter (stable) from 135454af3247 to b06b8b271095 (2551 revisions) (flutter#3086) [flutter_adaptive_scaffold] Fix leading and trailing Navigation Rail Widgets (flutter#3080) Roll Flutter from bd7bee0 to c35efda (24 revisions) (flutter#3085) [pigeon] Minor C++ output adjustments (flutter#3083) [pigeon] Updates writeScoped and addScoped to disallow symbol-less use. (flutter#3081) Roll Flutter from f33e8d3 to bd7bee0 (5 revisions) (flutter#3082) ...
* Add SwiftFunction annotation * Bump version to 3.2.4 * Remove unused imports * Improve methods map * Remove unnecessary print * Force cast match of SwiftFunction * Update packages/pigeon/lib/pigeon_lib.dart Co-authored-by: gaaclarke <[email protected]> * Improve documentation of function to parse method with SwiftFunction * Fix some dartdocs * gen * analyze * Improve SwiftFunction application * Add type annotation * format * Run format * Update macos Swift tests * Bump version to 7.0.0 * revert version change * Improve some code of SwiftGenerator * Bump version to 6.1.0 * Improve echo functions for Swift * Match order of parameters * Documents _SwiftFunctionComponents.fromMethod and _SwiftFunctionArgument * Improve doc comments * Fix tests * Fix SwiftFunction documentation Co-authored-by: gaaclarke <[email protected]> Co-authored-by: tarrinneal <[email protected]>
This PR adds a new annotation to Swift Generator to control the naming of a function like there is for ObjC (the annotation @ObjCSelector) as requested in flutter/flutter#105932
Fixes flutter/flutter#105932
Pre-launch Checklist
dart format
.)[shared_preferences]
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.md
to add a description of the change, following repository CHANGELOG style.///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.