-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[pigeon] add support for multiple swift outputs #12720
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -84,6 +84,7 @@ class InternalSwiftOptions extends InternalOptions { | |||||||||||||||||||||||||||
| const InternalSwiftOptions({ | ||||||||||||||||||||||||||||
| this.copyrightHeader, | ||||||||||||||||||||||||||||
| required this.swiftOut, | ||||||||||||||||||||||||||||
| this.swiftOuts, | ||||||||||||||||||||||||||||
| this.fileSpecificClassNameComponent, | ||||||||||||||||||||||||||||
| this.errorClassName, | ||||||||||||||||||||||||||||
| this.includeErrorClass = true, | ||||||||||||||||||||||||||||
|
|
@@ -92,22 +93,38 @@ class InternalSwiftOptions extends InternalOptions { | |||||||||||||||||||||||||||
| /// Creates InternalSwiftOptions from SwiftOptions. | ||||||||||||||||||||||||||||
| InternalSwiftOptions.fromSwiftOptions( | ||||||||||||||||||||||||||||
| SwiftOptions options, { | ||||||||||||||||||||||||||||
| required this.swiftOut, | ||||||||||||||||||||||||||||
| Iterable<String>? swiftOuts, | ||||||||||||||||||||||||||||
| String? swiftOut, | ||||||||||||||||||||||||||||
| Iterable<String>? copyrightHeader, | ||||||||||||||||||||||||||||
| }) : copyrightHeader = options.copyrightHeader ?? copyrightHeader, | ||||||||||||||||||||||||||||
| fileSpecificClassNameComponent = | ||||||||||||||||||||||||||||
| options.fileSpecificClassNameComponent ?? | ||||||||||||||||||||||||||||
| swiftOut.split('/').lastOrNull?.split('.').firstOrNull ?? | ||||||||||||||||||||||||||||
| (swiftOuts?.firstOrNull ?? swiftOut ?? '') | ||||||||||||||||||||||||||||
| .split('/') | ||||||||||||||||||||||||||||
| .lastOrNull | ||||||||||||||||||||||||||||
| ?.split('.') | ||||||||||||||||||||||||||||
| .firstOrNull ?? | ||||||||||||||||||||||||||||
| '', | ||||||||||||||||||||||||||||
|
Comment on lines
+102
to
107
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When running on Windows, file paths typically use backslashes (
Suggested change
|
||||||||||||||||||||||||||||
| errorClassName = options.errorClassName, | ||||||||||||||||||||||||||||
| includeErrorClass = options.includeErrorClass; | ||||||||||||||||||||||||||||
| includeErrorClass = options.includeErrorClass, | ||||||||||||||||||||||||||||
| swiftOut = swiftOut ?? swiftOuts?.firstOrNull ?? '', | ||||||||||||||||||||||||||||
| swiftOuts = swiftOuts ?? (swiftOut != null ? <String>[swiftOut] : const <String>[]); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| /// A copyright header that will get prepended to generated code. | ||||||||||||||||||||||||||||
| final Iterable<String>? copyrightHeader; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| /// Path to the swift file that will be generated. | ||||||||||||||||||||||||||||
| /// | ||||||||||||||||||||||||||||
| /// If multiple output paths were specified, this contains the first path. | ||||||||||||||||||||||||||||
| final String swiftOut; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| /// Paths to all swift files that will be generated. | ||||||||||||||||||||||||||||
| final Iterable<String>? swiftOuts; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| /// Returns all output paths for Swift. | ||||||||||||||||||||||||||||
| Iterable<String> get allSwiftOuts => | ||||||||||||||||||||||||||||
| swiftOuts ?? (swiftOut.isNotEmpty ? <String>[swiftOut] : const <String>[]); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| /// A String to augment class names to avoid cross file collisions. | ||||||||||||||||||||||||||||
| final String? fileSpecificClassNameComponent; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
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.
Using
path.posix.joinforces POSIX-style forward slashes as path separators. Since this code is performing local file system operations (File(...)), it is better to use platform-agnosticpath.jointo ensure correct path resolution on Windows and other platforms.