Skip to content

A couple of improvements for generated interfaces #1460

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 1 commit into from
Jun 12, 2024

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Jun 8, 2024

  • Rename methods to highlight that we’re talking about generated interfaces here, not .swiftinterface files
  • Don’t open the generated interface in documentManager. Opening documents in documentManager should only be done by the textDocument/didOpen notification from the LSP client. Otherwise we might indefinitely keep the document in the document manager
  • After getting the generated interface from sourcekitd, close the document in sourcekitd again. We don’t provide semantic functionality in the generated interface yet, so we can’t interact with the generated interface path. Before, we left it open in sourcekitd indefinitely.
  • A couple of code simplifications.

Fixes #878
rdar://116705653

- Rename methods to highlight that we’re talking about generated interfaces here, not `.swiftinterface` files
- Don’t open the generated interface in `documentManager`. Opening documents in `documentManager` should only be done by the `textDocument/didOpen` notification from the LSP client. Otherwise we might indefinitely keep the document in the document manager
- After getting the generated interface from sourcekitd, close the document in sourcekitd again. We don’t provide semantic functionality in the generated interface yet, so we can’t interact with the generated interface path. Before, we left it open in sourcekitd indefinitely.
- A couple of code simplifications.

Fixes swiftlang#878
rdar://116705653
@ahoppen ahoppen requested review from bnbarham and hamishknight June 8, 2024 14:56
@ahoppen ahoppen requested a review from benlangmuir as a code owner June 8, 2024 14:56
@ahoppen
Copy link
Member Author

ahoppen commented Jun 8, 2024

@swift-ci Please test

Comment on lines 31 to 32
// has interface already been generated
if let snapshot = try? self.documentManager.latestSnapshot(interfaceDocURI) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to make sure I understand, once the client has opened the interface, it gets populated in the documentManager?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, the client should send a textDocument/didOpen notification to SourceKit-LSP, which will then add it to the document manager like any other source file.

Copy link
Contributor

@bnbarham bnbarham left a comment

Choose a reason for hiding this comment

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

We don’t provide semantic functionality in the generated interface yet

IIRC sourcekitd does provide cursor-info for generated interface, is this just that we don't expose that from the LSP side yet?

@ahoppen
Copy link
Member Author

ahoppen commented Jun 12, 2024

IIRC sourcekitd does provide cursor-info for generated interface, is this just that we don't expose that from the LSP side yet?

Yes, we currently don’t provide any intelligent editor functionality in swift interfaces (#1155).

@ahoppen ahoppen merged commit 97ef5f4 into swiftlang:main Jun 12, 2024
3 checks passed
@ahoppen ahoppen deleted the generated-interface-improvements branch June 12, 2024 02:07
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.

Rename Swift Interface to Generated Interface
3 participants