Commit Graph

48 Commits

Author SHA1 Message Date
Max Desiatov
f5a30d9351 Fix uses of deprecated non-throwing AbsolutePath.init (#709)
These warnings appeared after an update to TSC deprecated this initializer.
2023-02-09 14:04:57 +00:00
Ruslan Latypov
c94c48415d fix scripts extension comparison to include dot 2022-10-24 14:41:58 +01:00
Ruslan Latypov
8ba893118c SKCore: allow non python build servers 2022-10-21 17:43:48 +01:00
Boris Buegling
43c072dc84 Adopt to path API changes
We are moving to a better model for TSC's path APIs in apple/swift-tools-support-core#353. The previous API is still available (but deprecated) as much as possible, but since SourceKit-LSP was using `resolveSymlinks` (which is now throwing) quite a bit, there are some changes necessary.
2022-10-18 15:28:54 -07:00
Saleem Abdulrasool
7d1bcee1b0 explicitly import TSCBasic types
Explicitly import interfaces from TSCBasic which now allows us to
identify all the swift-tools-support-core interfaces which are in
use in SourceKit-LSP.
2022-09-10 12:53:30 -07:00
Saleem Abdulrasool
79105208d5 SKCore,SKTestSupport: adjust test server handling
The test system depended on the shebang to locate the python
interpreter.  However, this is not a portable system.  Instead, prefer
to explicitly search for the interpreter prior to the execution.  This
enables supporting execution of the script support on all platforms. A
secondary change of the printed string is required for Windows. Python
will replace `\n` with `\r\n` resulting in `\r\n` being emitted as
`\r\r\n` on Windows breaking the expectations on the receiver.  Adjust
this by explicitly writing out a binary string to the raw underlying
buffer to avoid the translation.
2022-09-06 09:19:37 -07:00
David Goldman
472a06c88a Support index store path remappings (#562)
This allows sourcekit-lsp to make use of the path remappings recently added to
the index store and IndexStoreDB to remap remote paths into local paths
when loading index data locally.

These remappings can be provided via the `-index-prefix-map` command line flag to sourcekit-lsp or via the `BuildSystem` integration point.
2022-06-09 10:45:52 -04:00
Alex Hoppen
d02d3914c5 Query build system of workspaces to determine best workspace to open a file in
This sets the stage for multi-workspace support. Everything should be handled internally, we are just missing the API to actually open multiple workspaces at this point.
2022-05-04 14:48:31 +02:00
Ben Langmuir
3927e639be Revert "Support opening multiple workspaces in a single sourcekit-lsp instance" 2022-05-03 13:47:19 -07:00
Alex Hoppen
f91564a75f Query build system of workspaces to determine best workspace to open a file in
This sets the stage for multi-workspace support. Everything should be handled internally, we are just missing the API to actually open multiple workspaces at this point.
2022-05-02 09:31:07 +02:00
Alex Hoppen
9a5b1e81ef Reload Swift Package when new file creation is indicated by DidChangeWatchedFileNotification
Implement rudementary support for `DidChangeWatchedFileNotification` for SwiftPM projects: When a file is added, reload the Swift package to compute build settings for it.

This enables proper semantic functionality added to the project after the LSP server was started.

Resolves SR-15633
2022-01-19 11:20:10 +01:00
Kyle
6d1b09ad5b Remove available check below macOS 10.15.4
Since the Package.swift declare the minimal target for macOS is 10.15.4,
we can remove the uncessary available check code
2021-12-05 17:07:34 +08:00
Saleem Abdulrasool
6a275d134c Fix the Pipe handling on Windows to be correct
This actually addresses the real issue that was ignored earlier about
pipes on Windows.  The FileHandle cannot provide a non-owning file
descriptor (the returned file descriptor would need to be explicitly
`_close`'d by the receiver).  Foundation now vends a `_handle` accessor
to the OS primitive handle.  Use this to create the dispatch loop for
messaging.  We now create the JSONRPCConnection from handles on Windows
which actually should help enable running some of the tests on Windows
as well.
2020-11-02 09:55:58 -08:00
Ben Langmuir
5449a2acb7 [jsonrpc] Workaround file descriptor lifetime issue
We should solve this in the JSONRPCConnection itself, but in the
meantime workaround by keeping pipes alive until the connection has
closed.
2020-06-09 13:20:15 -07:00
David Goldman
cf19900d84 Swap BuildSystem to remove build settings method (#183)
Remove `settings(for:)` from the BuildSystem API in favor of the change callback

- With the `settings(for:)` method removed, we instead block on a
  callback from the `BuildSystemManager` which itself handles
  the primary build system callback in conjunction with the fallback
  system

- We queue up notifications / requests that reference documents
  until we receive the callback.

- Remove language from FileBuildSettings as it is no longer needed,
  Swift-specific working dir fixes are now in SwiftCompileCommand

- registerForChangeNotifications should inform its delegate
  asynchronously instead of immediately
2020-06-01 13:20:15 -04:00
Ben Langmuir
a679d4553d [buildsystem] Standardize call between register and settings query NFC
In preparation for injecting doing more during registration, pass
through the same parameters (add language) so that we can call settings
as necessary.
2020-02-05 21:53:52 -08:00
Ben Langmuir
47d92d89f9 Remove unused toolchain lookup function NFC
We want to be able to lookup the toolchain by file eventually, but it's
currently dead code.
2020-02-05 21:53:52 -08:00
Ben Langmuir
cffced1844 Thread Language through FileBuildSettings NFC
Will make it easier to work with cached settings.
2020-02-05 21:53:52 -08:00
Alex Hoppen
f167126c8d Fix typo: JSONRPCConnection should be spelled with two 'n' 2019-11-29 10:20:02 -08:00
Ben Langmuir
ab4a25d581 [BSP] Use URI instead of URL
Similar to LSP, BSP also uses URI. We were handling this correctly
everywhere except one test that was using a string with no scheme.
2019-11-20 09:41:48 -08:00
Alex Hoppen
558d7fc664 Change backing storage of DocumentURI to URL
URL can in fact store URIs, it just doesn't have a very nice API to
interact with them. As long as we only operate on absoluteString, we
should be fine though. So instead of implementing the logic for
detecting file URLs ourselves, we can just use a URL as storage for
DocumentURI.
2019-11-20 09:41:48 -08:00
Alex Hoppen
5c839f8640 Add support for non-URL URIs
According to the LSP specification, arbitrary URIs can be used as
document identifiers. Instead of internally assuming that all URIs are
URLs, use a DocumentURI enum to represent URIs. These can either be file
URLs or other URIs whose value as treated as an opaque string.
2019-11-20 09:41:48 -08:00
Ben Langmuir
775e198f77 Rename LSPSupport -> LSPLogging to reflect reduced scope
Ideally we can someday migrate this to something more standard such as
swift-log, and make it explicit how to control logging for the JSONRPC
module.
2019-11-19 11:08:31 -08:00
Alex Hoppen
05ecd26d08 Reorganize the repository into a set of bare LSP modules and SourceKit modules
We will be able to split the LSP modules off later. These LSP modules
will provide the ability to write custom LSP servers and clients in
Swift. The sourcekit-lsp repository will build on top of this new
package to provide an LSP implementation that creates a language server
for Swift and C-based-languages.
2019-11-14 10:35:06 -08:00
Alex Hoppen
1fde01efc0 Move LanguageServer to SKCore 2019-11-12 16:58:25 -08:00
Ben Langmuir
2c043e9250 Merge pull request #179 from rmaz/indexdbpath
Set index db path from build server response
2019-10-30 16:10:29 -07:00
Richard Howell
1d7858e023 call delegate on build targets change 2019-10-21 10:39:22 -07:00
Richard Howell
8e0fc462a0 set index db path from server data 2019-10-21 10:38:05 -07:00
Richard Howell
93b9838841 shutdown build server connection on deinit 2019-10-17 09:33:00 -07:00
Richard Howell
26d3fca5dd use LSPResult instead of optionals 2019-10-04 15:14:04 -07:00
Richard Howell
0f6f260701 add interface for fetching output paths 2019-10-04 14:51:26 -07:00
Richard Howell
315070d6f7 add inteface to fetch build target sources 2019-10-04 14:50:46 -07:00
Richard Howell
e3fce37388 use LSPResult instead of optional 2019-10-01 14:33:06 -07:00
Richard Howell
81c50db7e1 add the workspace/buildTargets request 2019-09-25 14:16:30 -07:00
Richard Howell
4804c7c138 add register and unregister requests and handle updates 2019-09-13 15:07:08 -07:00
Richard Howell
f2b5f2c167 add settings request and tests 2019-09-10 10:40:14 -07:00
David Goldman
e5caf44fda Add a BuildSystemDelegate which supports notifications for build settings changes
Introduce a `BuildSystemDelegate` to handle notifications from the build system

* `SourceKitServer` is the main delegate to process these notifications
* Currently limited to changes in `FileBuildSettings`
* Delegate informs the `BuildSystem` of files to watch via `registerChangeWatching(for: URL)` and `unregisterChangeWatching(for: URL)`
* In the future we could have more integration for handling changes in dependencies

Handling changes in `FileBuildSettings`

* `SourceKitServer` sends notifications to the internal LSPs informing them of any opened documents that have changes in their compiler flags
    * For clangd, we send a notification to update the compilation database
    * For SourceKit/sourcekitd we must close and reopen the file to force a new AST with the new compiler flags
2019-09-06 17:44:36 -04:00
Ben Langmuir
6bb0924de4 Update one more Basic -> TSCBasic from recent commit 2019-09-03 08:38:38 -07:00
Richard Howell
83d0e75fec nicer case matching for response data 2019-08-29 16:12:09 -07:00
Richard Howell
8e8bf8abf2 don't block shutting down build server 2019-08-29 16:05:20 -07:00
Richard Howell
301fa20327 add log message for shutdown errors 2019-08-29 10:20:27 -07:00
Richard Howell
cbd33eed6a add support for index store path via metadata 2019-08-29 10:20:27 -07:00
Richard Howell
7b842235be add build server lifecycle notifications 2019-08-29 10:04:18 -07:00
Richard Howell
58a42b08b3 use Language instead of String 2019-08-28 19:43:10 -07:00
Richard Howell
bfb0eb7cf9 don't forget to actually initialize the server 2019-08-28 15:43:49 -07:00
Richard Howell
fd6cdfb603 use Codable, start server as part of init, no log on missing config 2019-08-28 15:35:57 -07:00
Richard Howell
89f62f8229 add copyright headers 2019-08-28 15:15:59 -07:00
Richard Howell
366f7d930d Add initial BuildServerBuildSystem based on BSP 2019-08-27 15:47:40 -07:00