-
Notifications
You must be signed in to change notification settings - Fork 314
Additions to the LSP module for workspace/didChangeWatchedFiles
#376
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
Conversation
Sources/LanguageServerProtocol/SupportTypes/FileSystemWatcher.swift
Outdated
Show resolved
Hide resolved
|
||
import Foundation | ||
|
||
/// FIXME: Find a way to abstract this without deserializing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure of a better generalization here, we could do something like what we do for Notifications/Requests but to store it we'd need to type erase it/box it (e.g. an AnyRegistrationOptions)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There aren't that many of these - is there a reason not to just make encodeToLSPAny
a protocol requirement and implement it concretely for each concrete type that implements the protocol?
@swift-ci please test |
Sources/LanguageServerProtocol/SupportTypes/FileSystemWatcher.swift
Outdated
Show resolved
Hide resolved
Sources/LanguageServerProtocol/SupportTypes/ServerCapabilities.swift
Outdated
Show resolved
Hide resolved
Sources/LanguageServerProtocol/Requests/RegisterCapabilityRequest.swift
Outdated
Show resolved
Hide resolved
|
||
import Foundation | ||
|
||
/// FIXME: Find a way to abstract this without deserializing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There aren't that many of these - is there a reason not to just make encodeToLSPAny
a protocol requirement and implement it concretely for each concrete type that implements the protocol?
We can then use this functionality to allow a `BuildSystem` to watch files (e.g. via the client or even in-process file watching), which would allow us to do things like detect new files and provide accurate build settings for them.
c382985
to
d3ba9ef
Compare
We could but then we'd probably want to implement it for all of the transitive types embedded there, also note that at the moment these really would only ever be encoded, not decoded since only the server sends them over. |
This is fine for now as long as we don't have a use case, but we generally expect to be able to write both client and server using this code.
Is there something I'm missing? The ones added so far seem straightforward/shallow in terms of object graph. |
Tests/LanguageServerProtocolTests/LanguageServerProtocolTests.swift
Outdated
Show resolved
Hide resolved
Do we intend to keep LSPAny like it currently is? If so I wonder if it would be more useful to have a generalized encoder/decoder for it. Although that will be a bit more work it would save manually implementing all of these encoders/decoders. Also note that I didn't include all of the RegistrationOptions, there are more complex ones. |
Is there a good alternative? We're using it for places where the spec allows |
Right, if we had a proper |
|
After looking into the stdlib's JSONEncoder/JSONDecoder which is quite large and complicated, I agree that we should stick with |
Also regenerate Linux main
@swift-ci please test |
|
||
public func encodeToLSPAny() -> LSPAny { | ||
guard let wrapped = self else { return .null } | ||
return wrapped.encodeToLSPAny() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we actually use the null
encoding anywhere, or is this just for completeness? If possible I strongly prefer skipping nil values instead of encoding them as null
since that seems to play nicer with other tools and saves space.
Edit: to be clear, I'm fine with keeping this conformance of Optional: LSPAnyCodable
, particularly so that we can decode it correctly, I'm just wondering if it's used concretely in our code anywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Swapped over the place that used it
@@ -23,6 +35,7 @@ extension SourceKitDTests { | |||
|
|||
public func __allTests() -> [XCTestCaseEntry] { | |||
return [ | |||
testCase(CrashRecoveryTests.__allTests__CrashRecoveryTests), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops! Hope these are working on Linux...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, CI is failing but those errors link to
/home/buildnode/jenkins/workspace/swift-sourcekit-lsp-PR-Linux/tmp/TemporaryDirectory.YD3VQ4/pkg/Package.swift:3:5: error: type annotation missing in pattern
14:18:28 let pack
That seems like an unrelated issue that CI is picking up since it was present and enabled before in SwiftPMWorkspaceTests.testUnparsablePackage
or perhaps something related to the diagnostics changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm it might be related to the sourcekitd tests?
From the logs:
Test Suite 'Selected tests' started at 2021-03-16 13:18:18.663
Test Suite 'CrashRecoveryTests' started at 2021-03-16 13:18:18.666
Test Case 'CrashRecoveryTests.testSourcekitdCrashRecovery' started at 2021-03-16 13:18:18.666
But I don't see it ever report the status of that test...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's failing in CrashRecoveryTests.testSourcekitdCrashRecovery, which makes some sense since sourcekitd is in-process on Linux, so that test doesn't really make sense. We should just skip it on non-Darwin platforms. Feel free to either do that in this patch (some kind of try XCTSkipIf(...)
) or else remove the changes related to enabling these tests on Linux and let me or @ahoppen deal with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha, done
@swift-ci please test |
@swift-ci please test |
This broke the Windows bootstrap :-( |
Update the source file list for the new files. This repairs the bootstrap build on Windows.
build: update the CMakeLists.txt after #376
Is there any CI or pre-merge hooks for windows support? Or a script to run to update the CMake files or do you have to do it manually? |
There're nightly builds at https://dev.azure.com/compnerd/swift-build The CMake files need to be updated manually. |
We can then use this functionality to allow a
BuildSystem
to watchfiles (e.g. via the client or even in-process file watching),
which would allow us to do things like detect new files and provide
accurate build settings for them.