Skip to content

Don’t block the generation of a build system by build graph generation #1632

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
Sep 7, 2024

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Aug 17, 2024

We currently load the entire package before generating a SwiftPMBuildSystem. That means that the initialize request to SourceKit-LSP is blocked until the package has been loaded, preventing us from offering any sort of functionality, including syntactic functionality like formatting.

Decouple build system creation and build graph generation (aka. package loading for SwiftPM). We can operate with fallback build settings until the build graph has been loaded and reopen the document once the proper build settings are available.

rdar://126644596

@ahoppen
Copy link
Member Author

ahoppen commented Aug 17, 2024

@swift-ci Please test


/// Check that the entries in `uriToWorkspace` are still up-to-date after workspaces might have changed.
///
/// For any entries that are not up-to-date, close the document in the old workspace and open it in the new document.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// For any entries that are not up-to-date, close the document in the old workspace and open it in the new document.
/// For any entries that are not up-to-date, close the document in the old workspace and open it in the new workspace.

package func generateBuildGraph(allowFileSystemWrites: Bool) async throws {
try await self.reloadPackage(forceResolvedVersions: !isForIndexBuild || !allowFileSystemWrites)
package func generateBuildGraph() async throws {
try await self.reloadPackage(forceResolvedVersions: !isForIndexBuild)
Copy link
Contributor

Choose a reason for hiding this comment

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

forceResolvedVersions is now always !isForIndexBuild, is it worth keeping it as a parameter?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice catch, I didn’t notice we can remove it even one level further. 👍🏽

@ahoppen ahoppen force-pushed the lazy-workspace-loading branch 2 times, most recently from c8454f5 to 0151a0f Compare August 19, 2024 22:35
@ahoppen
Copy link
Member Author

ahoppen commented Aug 19, 2024

@swift-ci Please test

@ahoppen ahoppen enabled auto-merge August 19, 2024 22:36
@ahoppen ahoppen disabled auto-merge August 22, 2024 01:08
We currently load the entire package before generating a `SwiftPMBuildSystem`. That means that the initialize request to SourceKit-LSP is blocked until the package has been loaded, preventing us from offering any sort of functionality, including syntactic functionality like formatting.

Decouple build system creation and build graph generation (aka. package loading for SwiftPM). We can operate with fallback build settings until the build graph has been loaded and reopen the document once the proper build settings are available.

rdar://126644596
@ahoppen ahoppen force-pushed the lazy-workspace-loading branch from 0151a0f to 6e0281f Compare September 7, 2024 05:52
@ahoppen
Copy link
Member Author

ahoppen commented Sep 7, 2024

@swift-ci Please test

@ahoppen ahoppen enabled auto-merge September 7, 2024 05:52
@ahoppen
Copy link
Member Author

ahoppen commented Sep 7, 2024

@swift-ci Please test Windows

@ahoppen ahoppen merged commit 33e955a into swiftlang:main Sep 7, 2024
3 checks passed
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.

2 participants