Skip to content
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

[swift2objc] Filtering Support #1730

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

nikeokoronkwo
Copy link

This Pull Request is to add filtering support to the swiftgen tool.

  • Add filtering support to swiftgen Config
  • Implementing filtering support into transform logic
  • Create and test unit tests for such filtering logic

More information can be found here: #1394

Copy link
Contributor

@liamappelbe liamappelbe left a comment

Choose a reason for hiding this comment

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

Looks like you've also got a merge conflict to resolve.

///
/// APIs can be filtered by name
///
/// TODO: Add `excludeAll` option to exclude all or include all declarations
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think that's necessary. People can just set filter = (_) => false.

/// APIs can be filtered by name
///
/// TODO: Add `excludeAll` option to exclude all or include all declarations
final bool Function(Declaration declaration)? filter;
Copy link
Contributor

@liamappelbe liamappelbe Nov 18, 2024

Choose a reason for hiding this comment

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

The name and documentation don't really make it clear whether this function should return true or false to include the given declaration. Maybe rename it include or shouldInclude. Also, make it non-null and then set a default in the constructor.

@@ -43,6 +43,16 @@ ReferredType _parseVariableType(
) {
final subHeadings = propertySymbolJson['names']['subHeading'];

// if subheadings have text that contain sets of parentheses and arrows
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like closure stuff. Remove it from this PR.

outputFile: Uri.file(actualOutputFile),
tempDir: Directory(thisDir).uri,
preamble: '// Test preamble text',
filter: (declaration) => false,
Copy link
Contributor

Choose a reason for hiding this comment

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

This test would be a bit better if you filtered some specific declarations. Try adding a few more classes, methods, globals, top level functions etc, and filter some of them but not all of them.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, also, can you add a method that is included by the filter, but refers to a class that is not included? What should happen in that case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants