Skip to content

[SourceKit/InterfaceGen] Also print the cross-import overlays of a module in its interface. #30521

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 3 commits into from
Mar 24, 2020

Conversation

nathawes
Copy link
Contributor

@nathawes nathawes commented Mar 20, 2020

When printing the generated interface of a module, also print the decls from any underscored cross-import overlays it is the direct, or indirect underlying module of. Declarations are grouped by overlay, with a MARK: comment introducing each overlay, and a regular comment above each decl listing the required bystander modules that must be imported for the decl to be
available.

In addition, in each overlay:

  • import declarations of the underlying modules are filtered out, since those modules are either other underscored cross-import overlays, or the target module the overlays are presented as being a part of.
  • import declarations of modules that are also imported in the target module are filtered out, also because the overlay is presented as a conditional part of the target module.

@brentdax does that handling of import decls in overlays make sense?

Also update cursor info to report the owning module of the symbol under the cursor as the underlying/primary module when the symbol comes from a cross-import overlay.

Resolves rdar://problem/59445385

…dule in its interface.

When printing the generated interface of a module, also print the decls from
any underscored cross-import overlays it is the direct, or indirect underlying
module of. Declarations are grouped by overlay, with a descriptive `MARK:`
comment introducing each overlay, and a regular comment above each decl listing
the required bystander modules that must be imported for the decl to be
available.

In addition in each overlay:
- import declarations of any underlying modules are filtered out, since they
  are either other underscored cross-import overlays, or the target module they
  are being presented as being part of.
- import declarations that are also in the target module are filtered out, since
  the overlay is being presented as a conditional part of the target module.

Resolves rdar://problem/59445385
@nathawes nathawes requested review from akyrtzi and beccadax March 20, 2020 01:31
@nathawes
Copy link
Contributor Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - b3f296d

@CodaFi
Copy link
Contributor

CodaFi commented Mar 20, 2020

@swift-ci test Linux

@CodaFi
Copy link
Contributor

CodaFi commented Mar 20, 2020

@swift-ci test Windows

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - b3f296d


import B

// Available when B is imported with A
Copy link
Contributor

Choose a reason for hiding this comment

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

How does this synthesized comment relate to a user documentation comment, could you add some doc-comments in the test cases?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The synthesized comment is printed before it at the moment. Added a test case showing the current behavior.

…erlays as coming from the underylying module.

Also refactor some of the interface generation cross-import support code to be
shared.
@nathawes nathawes force-pushed the cross-import-interface-gen branch from 7f6af09 to 36cf4ad Compare March 21, 2020 04:54
/// Prints a single decl using the \p Printer and \p Options provided.
///
/// \returns Whether the given decl was printed.
static bool printModuleInterfaceDecl(Decl *D,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This isn't new code - it's just pulled out of printSubmoduleInterface() below.

@nathawes
Copy link
Contributor Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 36cf4ad068d9ae0985681d2c603aa7766a374a4c

@nathawes nathawes force-pushed the cross-import-interface-gen branch from 36cf4ad to a355a56 Compare March 23, 2020 19:44
@nathawes
Copy link
Contributor Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 36cf4ad068d9ae0985681d2c603aa7766a374a4c

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 36cf4ad068d9ae0985681d2c603aa7766a374a4c

@nathawes
Copy link
Contributor Author

@swift-ci please test

@nathawes
Copy link
Contributor Author

@brentdax I'm going to go ahead and merge this so I can land a few subsequent PRs based on some the APIs added in this one, but it'd be great if you could take a look when you get the chance (I know you're probably busy build czar-ing). I'm not sure I've used the right terminology everywhere, and am probably missing some interesting test cases.

@nathawes nathawes merged commit 7811f53 into swiftlang:master Mar 24, 2020
@nathawes nathawes deleted the cross-import-interface-gen branch March 24, 2020 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants