Commit Graph

15 Commits

Author SHA1 Message Date
Alex Hoppen
41b810b80c Cancel preparation tasks for editor functionality if the preparation task hasn't been started yet and the document is no longer active
When the user opens documents from three targets A, B, and C in quick succession, then we don’t want to schedule preparation of wait until A *and* B are finished preparing before preparing C.

Instead, we want to
- Finish for preparation of A to finish if it has already started by the time the file in C is opened. This is done so we always make progress during preparation and don’t get into a scenario where preparation is always cancelled if a user switches between two targets more quickly than it takes to prepare those targets.
- Not prepare B because it is no longer relevant and we haven’t started any progress here. Essentially, we pretend that the hop to B never happened.
2024-05-21 18:12:24 -07:00
Alex Hoppen
7e7df04b48 Make the SourceKitLSP module build in Swift 6 mode
Swift 6 mode didn’t find any notable data races. But it’s good to know Swift 6 will prevent future ones.
2024-05-13 21:28:42 -07:00
Alex Hoppen
08f1595b5b Never return nil for position conversions
Instead of returning `nil` to indicate that the position conversion failed, log a fault and perform a best-effort recovery.

I think this allows us to perform better recovery and also makes code calling these position conversions a lot simpler because it doesn’t need to make decisions about what to do if position conversions fail.
2024-04-11 13:59:17 -07:00
Alex Hoppen
d62c4ce9fa Unify logging of errors during position conversions
Instead of logging errors in position translation ad-hoc at the caller’s side (and ofter forgetting to do so), log these errors in `LineTable`. To be able to debug where the position conversion error is coming from, also log the file name and line number of the caller.

rdar://125545620
2024-04-05 06:56:59 -07:00
Alex Hoppen
31b7fb7dbe [Diagnose] Allow passing --position to sourcekit-lsp run-sourcekitd-request
When doing the final manual reduction steps of a sourcekitd request, this eliminates laborious adjustment of key.offset in the request while lines that don’t contain the offset are being modified.
2024-02-29 20:57:45 -08:00
Alex Hoppen
6b2b70207b Rename references to function parameters inside function bodies
rdar://122031097
2024-02-23 16:32:20 -08:00
Alex Hoppen
79cc4f9ae8 Support formatting of entire documents
Depend on the swift-format library to discover and write the swift-format configuration file. Invoke swift-format from the toolchain to actually format a document. This makes sure that the formatting of SourceKit-LSP and the swift-format executable in the toolchain never get out of sync.

Fixes #576
rdar://96159694
2024-01-23 22:31:52 -08:00
Alex Hoppen
777f1dc463 Add support for rename within the current file
rdar://117822427
2023-12-09 08:35:13 -08:00
Alex Hoppen
d0fc00ce98 Format using swift-format
Add `.swift-format` to the repo and format the repo with `swift-format`.

This commit does not add any automation to enforce formatting of sourcekit-lsp in CI. The goal of this commit is to get the majority of source changes out of the way so that the diff of actually enforcing formatting will have fewer changes or conflicts.
2023-10-10 13:44:47 -07:00
Bruno Rocha
9eb2fe4453 Clean implementation 2019-10-04 12:34:09 -03:00
Bruno Rocha
a84eaaa478 Apply review comments (LSPAnyCodable/Cleaning) 2019-10-03 11:37:24 -03:00
Rintaro Ishizaki
8f90fa450a [SKSupport.LineTable] More efficient LineTable
Use `index(_:offsetBy:limitedBy:)` to get index from the views.
2018-11-22 01:18:23 +09:00
Rintaro Ishizaki
c97a244874 [SKSupport.LineTable] Fix UTF16 offset calculation
Rework LineTable. Now that line table is just a collection of `Substring`.
Derive UTF16/UTF8 offset from corresponding view of the content String.
Added several methods to translate between line/UTF(8|16)column and
UTF8 offset.

Resolves: https://bugs.swift.org/browse/SR-9311
2018-11-21 21:56:06 +09:00
Adam Nemecek
97fd1e8cb3 trimmed whitespace 2018-11-15 14:12:34 -08:00
Ben Langmuir
aabf57a252 Import SourceKit-LSP sources 2018-11-13 15:50:48 -08:00