Skip to content

[ContributorDoc] Checklist for adding new LSP/BSP messages#2626

Merged
rintaro merged 1 commit into
swiftlang:mainfrom
rintaro:add-message-doc
Apr 29, 2026
Merged

[ContributorDoc] Checklist for adding new LSP/BSP messages#2626
rintaro merged 1 commit into
swiftlang:mainfrom
rintaro:add-message-doc

Conversation

@rintaro
Copy link
Copy Markdown
Member

@rintaro rintaro commented Apr 28, 2026

Because I keep forgetting these.

@rintaro
Copy link
Copy Markdown
Member Author

rintaro commented Apr 28, 2026

@swift-ci Please test


- [ ] Add the request Swift file under `Sources/LanguageServerProtocol/Requests/`
- [ ] `Sources/LanguageServerProtocol/CMakeLists.txt` — add the file in alphabetical order
- [ ] `Sources/LanguageServerProtocol/Messages.swift` — add to `builtinRequests`
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This tend to be missed because our test cases don't go through this. We should fix that...

Comment thread Contributor Documentation/Adding LSP and BSP Messages.md Outdated
Comment thread Contributor Documentation/Adding LSP and BSP Messages.md Outdated
- [ ] `Sources/SourceKitLSP/MessageHandlingDependencyTracker.swift` — add a case to `init(_ request:)` to declare the dependency type (`.freestanding`, `.documentRequest(uri)`, etc.) *(client → server only)*
- [ ] `Sources/SourceKitLSP/SourceKitLSPServer.swift`:
- [ ] *(client → server)* Add a case to the main request dispatch switch and implement the handler
- [ ] *(server → client)* Call `client.send(request)` from the appropriate place
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I’m not sure if we need this. I mean, if you want to use it, you have to send the request, otherwise there’s just no point.

- [ ] `Contributor Documentation/LSP Extensions.md` — document the request
- [ ] Add tests

## LSP Notification
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we unify this with the LSP Requests section? Most of it is duplicated.

- [ ] `Sources/SourceKitLSP/SourceKitLSPServer.swift`:
- [ ] *(client → server)* Add a case to the main request dispatch switch and implement the handler
- [ ] *(server → client)* Call `client.send(request)` from the appropriate place
- [ ] If experimental: advertise via `serverCapabilities()` and guard with a capability check *(client → server)*; check the client capability before sending *(server → client)*
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We need to advertise the request from both SourceKitLSPServer.serverCapabilities and SwiftLangaugeService.initialize.

- [ ] If experimental: advertise via `serverCapabilities()` and guard with a capability check *(client → server)*; check the client capability before sending *(server → client)*
- [ ] `Sources/SourceKitLSP/CapabilityRegistry.swift` — if gated on an experimental **client** capability, add a helper property *(client → server only)*
- [ ] `Contributor Documentation/LSP Extensions.md` — document the request
- [ ] Add tests
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don’t think we should explicitly need to mention this. Tests should be added to every change, no matter what.

- [ ] `Sources/BuildServerIntegration/BuildServerMessageDependencyTracker.swift` — add a case to the dependency tracking switch
- [ ] `Sources/BuildServerIntegration/BuiltInBuildServer.swift` — add the handler method to the `BuiltInBuildServer` protocol
- [ ] `Sources/BuildServerIntegration/BuiltInBuildServerAdapter.swift` — add a case to the request dispatch switch
- [ ] Implement the handler in all `BuiltInBuildServer` conformers:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don’t think we need to explicitly spell this out. Adding the requirement to BuiltInBuildServer will prompt theses.

@rintaro rintaro force-pushed the add-message-doc branch 2 times, most recently from 53769e4 to a2da4b9 Compare April 28, 2026 15:23
Copy link
Copy Markdown
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

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

Some more nitpicks, otherwise looks good.

Comment thread Contributor Documentation/Adding LSP and BSP Messages.md
- [ ] If handled by a language service: also advertise in each `LanguageService.initialize` conforming method
- [ ] If experimental *(server → client)*: check the client capability before sending
- [ ] `Sources/SourceKitLSP/CapabilityRegistry.swift` — if gated on an experimental **client** capability, add a helper property
- [ ] `Contributor Documentation/LSP Extensions.md` — document if it is a SourceKit-LSP extension
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
- [ ] `Contributor Documentation/LSP Extensions.md` — document if it is a SourceKit-LSP extension
- [ ] `Contributor Documentation/LSP Extensions.md` — document if it is an LSP extension

- [ ] `Sources/BuildServerIntegration/BuildServerMessageDependencyTracker.swift` — add a case to the dependency tracking switch *(request only)*
- [ ] `Sources/BuildServerIntegration/BuiltInBuildServer.swift` — add the handler method to the `BuiltInBuildServer` protocol *(request only)*
- [ ] `Sources/BuildServerIntegration/BuiltInBuildServerAdapter.swift` — add a case to the request dispatch switch *(request only)*
- [ ] *(SourceKit-LSP → build server, notification only)* Send via `buildServerManager.send(notification)` from the appropriate place; if built-in servers also need to react, add a case to `BuiltInBuildServerAdapter.handle(notification:)`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Similar to my comment in LSP: I don’t think we need to document that you need to send the request if you want to send it.

- [ ] `Sources/BuildServerIntegration/BuiltInBuildServerAdapter.swift` — add a case to the request dispatch switch *(request only)*
- [ ] *(SourceKit-LSP → build server, notification only)* Send via `buildServerManager.send(notification)` from the appropriate place; if built-in servers also need to react, add a case to `BuiltInBuildServerAdapter.handle(notification:)`
- [ ] *(build server → SourceKit-LSP, notification only)* `Sources/BuildServerIntegration/BuildServerManager.swift` — add a case to `handle(notification:)` and implement the handler
- [ ] `Contributor Documentation/BSP Extensions.md` — document if it is a SourceKit-LSP extension
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
- [ ] `Contributor Documentation/BSP Extensions.md` — document if it is a SourceKit-LSP extension
- [ ] `Contributor Documentation/BSP Extensions.md` — document if it is a BSP extension

@rintaro
Copy link
Copy Markdown
Member Author

rintaro commented Apr 28, 2026

@swift-ci Please test

@rintaro
Copy link
Copy Markdown
Member Author

rintaro commented Apr 28, 2026

@swift-ci Please test Windows

@rintaro rintaro merged commit 5901c30 into swiftlang:main Apr 29, 2026
3 checks passed
@nkcsgexi
Copy link
Copy Markdown

Thank you for adding this doc, Rintaro!

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.

3 participants