In addition to Swift Concurrency, Swift 5.5 also introduces `get throws` properties, which would allow us to fix numerous warnings related to non-throwing `AbsolutePath.init` deprecation.
SKSupport now requires a link against Foundation, update the build
system to track that dependency.
Co-authored-by: Max Desiatov <m_desiatov@apple.com>
The dependency on `TSCUtility` was strictly for identifying the platform
of execution. This logic is relatively self-contained and effectively an
extension over an enumeration. Replicate this logic with updates for new
syntactic improvements. This allows us to partially reduce dependency on
swift-tools-support-core. The dependency on TSCBasic is more complicated
to remove due to the extensive use of `AbsolutePath`.
Co-authored-by: Alex Hoppen <alex@alexhoppen.de>
Building upon the infrastructure that requests the lexical structure of the document from SwiftSyntax, redo the folding ranges request using the tree directly. This corrects a number of inconsistencies in the tests mostly due to incorrect SourceLocations in the semantic ASTs and the line comment merging logic.
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.
Re-core the "lexical" token stream on top of SwiftSyntax and call into the parser to (re-)generate these "lexical tokens" when the document changes. Leave the semantic tokens alone since they take some non-zero amount of name lookup to fully resolve references to fully replicate.
A declaration request is similar to a definition request, except that it is expected to return (potentially) many results across the workspace for a given reference. For example, an inline function or macro may have many declarations in the workspace, but only one "good" or canonical definition. For now, this is only implemented by forwarding the request on to clangd since I'm unfamiliar with a SourceKit query for this.
For languages like Swift that lack such a sharp declaration/definition split, we could potentially use this request to provide navigable metadata on linked definitions. For example, the declaration for a type reference would include all extensions of that type in the workspace.
Rather than treating the filename as an opaque string and splitting on
`/`, use `AbsolutePath` to perform the `basename` operation on the path.
This ensures that we split the path properly on platforms which do not
use the POSIX path separator `/`.
Add a dependency on TSCBasic for LanguageServerProtocol. This dependency was added recently via an `import` and was updated in Package.swift but was missed in the CMake build.
Rather than using the `resolvingSymlinksInPath` on `URL` use
`resolvingSymlink` from tools-support-core as the semantics for the two
differ ever so slightly which matters for Windows (the former expands
symlinks on the terminal arc iterative where as the latter simply
expands the path).
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.
Migrate to `swift` member for the swift driver rather than trying to
create it by dropping the last character in the path to the swift
compiler which may be part of the file extension.
The root of the test project would be in POSIX spelling which would
cause mismatches between the formed paths and the value returned from
the LSP resulting in test failures on Windows.
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.