Commit Graph

213 Commits

Author SHA1 Message Date
Alex Hoppen
ca470335e6 Merge pull request #1008 from ahoppen/ahoppen/skd-array-dictionary-from-literal
Support creation of SKDRequest(Dictionary|Array) from literals
2024-01-09 13:26:00 -08:00
Alex Hoppen
3991fae867 Define methods on SourceKitD to create arrays and dictionaries instead of using skd postfix syntax 2024-01-08 18:06:31 -08:00
Marcin Krzyzanowski
79ca4c0ac6 Remove redundant typealias 2024-01-08 23:51:09 +01:00
Marcin Krzyzanowski
2c616f7838 Refactor SemanticTokenTypes, SemanticTokenModifiers 2023-12-26 22:55:12 +01:00
Alex Hoppen
f901cc9250 Support creation of SKDRequest(Dictionary|Array) from literals
IMO this makes it a lot clearer which keys are present in the request dictionaries because we are no longer mutating them on the fly.
2023-12-22 22:29:11 -08:00
Alex Hoppen
f32e7dd51c Merge pull request #999 from ahoppen/ahoppen/folding-range-improvements
Improve code folding
2023-12-15 07:43:49 -08:00
Alex Hoppen
be0dd73135 Support folding of function parameter clauses
Fixes #898
rdar://116877123
2023-12-14 09:03:10 -08:00
Alex Hoppen
fbb77c6ce4 Don’t report empty folding ranges 2023-12-13 16:38:08 -08:00
Alex Hoppen
2bae1f0d75 Improve folding of calls that span multiple lines 2023-12-13 16:34:07 -08:00
Alex Hoppen
796138be5e Support folding of switch cases 2023-12-13 16:14:04 -08:00
Alex Hoppen
cc4cfac73b Support folding of collection literals 2023-12-13 16:10:14 -08:00
Alex Hoppen
fc3c51989f Consider trivia symetrically when folding braced blocks 2023-12-13 16:05:38 -08:00
Alex Hoppen
c8b2f76adc Move FoldingRange to its own file
No code change here.
2023-12-13 16:00:35 -08:00
Alex Hoppen
997ef38916 Support rename across Swift files
rdar://118995700
2023-12-12 17:34:34 -08:00
Alex Hoppen
34a36b44e6 Refactor rename to support index-based discovery of rename locations 2023-12-12 17:34:34 -08:00
Alex Hoppen
6b5842f0a2 Send source text for find-syntactic-rename-ranges 2023-12-09 08:35:14 -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
8857a08940 Parse information from related identiers that is needed to perform local rename 2023-12-09 08:34:41 -08:00
Alex Hoppen
8acc5bd999 Factor related identifiers request into a separate file
This allows use to re-use related identifiers when implementing rename
2023-12-09 08:34:40 -08:00
Alex Hoppen
2d01d5d146 Merge pull request #983 from ahoppen/ahoppen/parameter-highlighting
Add semantic highlighting for function parameter labels
2023-12-06 14:25:24 -08:00
Alex Hoppen
742455833b Add semantic highlighting for function parameter labels 2023-12-06 10:02:39 -08:00
Alex Hoppen
ed410e6503 Merge pull request #977 from ahoppen/ahoppen/jump-to-override
Show overriden functions when performing jump-to-definition on a dynamic call
2023-12-05 16:18:46 -08:00
Alex Hoppen
f293741dca Merge pull request #981 from ahoppen/ahoppen/never-error-for-diagnostics-request
Never return error for diagnostics request
2023-12-05 10:03:45 -08:00
Alex Hoppen
84fdea9e05 Filter overrides in DefinitionRequest by receiver types 2023-11-29 09:03:36 -08:00
Alex Hoppen
1ffa825b3f Remove extractIndexedOccurences
`extractIndexedOccurences` mostly dealt with how to create a fallback value and we didn’t support fallback values in 3/4 cases. Remove it, simplifying the callers of `extractIndexedOccurances` along the way.
2023-11-29 09:02:19 -08:00
Alex Hoppen
4052465905 Show overriden functions when performing jump-to-definition on a dynamic call
Fixes #809
rdar://114864256
2023-11-29 09:02:02 -08:00
Alex Hoppen
4c8aea29c3 Never return error for diagnostics request
VS Code does not request diagnostics again for a document if the diagnostics request failed. Since sourcekit-lsp usually recovers from failures (e.g. after sourcekitd crashes), this is undesirable. Instead of returning an error, return empty results.
2023-11-27 19:39:22 -08:00
Alex Hoppen
b85f3afc10 Report MARK comments in the document symbols request
Fixes #963
rdar://117811210
2023-11-27 15:55:50 -08:00
Alex Hoppen
9595498dae Don’t include local variables in document symbols
Fixes #962
rdar://117810784
2023-11-27 15:38:36 -08:00
Alex Hoppen
e6cf72317d Merge pull request #975 from ahoppen/ahoppen/normalize-identifier-start
Support cursor info-based requests when cursor is placed at the end of an identifier
2023-11-27 15:36:19 -08:00
Alex Hoppen
f5e26e4b95 Support cursor info-based requests when cursor is placed at the end of an identifier
VS Code considers the position after an identifier as part of an identifier. Ie. if you have `let foo| = 1`, then it considers the cursor to be positioned at the identifier. This scenario is hit, when selecting an identifier by double-clicking it and then eg. performing jump-to-definition. In that case VS Code will send the position after the identifier.
`sourcekitd`, on the other hand, does not consider the position after the identifier as part of the identifier.
To bridge the gap here, normalize any positions inside, or directly after, an identifier to the identifier's start.

Fixes #820
rdar://115557453
2023-11-23 20:22:05 -08:00
Alex Hoppen
2aedb85a1f Don't cancel cursor info and related identifiers requests on subsequent requests
SourceKit-LSP supports explicit cancellation and thus we don’t need to do the implicit cancellation of cursor info and related identifiers on subsequent requests.
2023-11-21 17:45:10 -08:00
joehsieh
a095810af8 Implement an initializer of CodeAction with the FixIt from swift-syntax
Finetune the code

Finetune the code

Finetune the code

Update the code per comments

Use location marker instead of hard coded indexes

Update the test to align the code convention

Rename a variable

Correct unit tests

Format the code

Update Package.swift
2023-11-08 18:09:38 +09:00
Alex Hoppen
3ba15e1997 Merge pull request #955 from ahoppen/ahoppen/format
Format sources with swift-format
2023-10-31 21:48:03 -07:00
Alex Hoppen
ac3eb32e65 Format sources with swift-format 2023-10-31 19:30:31 -07:00
Alex Hoppen
d4f304ebcc Uppercase first letter of diagnostics
sourcekitd returns diagnostics with the first letter lowercase. Xcode, for example, shows the messages with the first letter uppercases. I think that looks nicer and we should also uppercase the first letter in sourcekit-lsp.
2023-10-31 19:28:04 -07:00
Alex Hoppen
9a87691853 Merge pull request #945 from ahoppen/ahoppen/language-server-protocol-dependency-free
Make the `LanguageServerProtocol` module dependency-free
2023-10-31 16:02:50 -07:00
Alex Hoppen
9919d038ee Merge pull request #947 from ahoppen/ahoppen/skip-semantic-tokens-tests
Skip semantic tokens tests if sourcekitd doesn't support the semantic tokens request
2023-10-31 15:09:27 -07:00
Alex Hoppen
aa70fc0e8d Make the LanguageServerProtocol module dependency-free
Shuffle a few types around so that the `LanguageServerProtocol` has no more dependencies.

Fixes #938
rdar://117565087
2023-10-31 13:22:38 -07:00
Alex Hoppen
1a23153fd5 When sourcekitd crashes, log the file contents with which it crashed and the request
This should make it a lot easier to reproduce sourcekitd crashes.
2023-10-31 08:30:54 -07:00
Alex Hoppen
ecc550eb53 Skip semantic tokens tests if sourcekitd doesn't support the semantic tokens request
When running sourcekit-lsp’s tests using Xcode 15, they fail because the sourcekitd in Xcode 15 does not contain the semantic tokens request. The intended workaround/fix is to dowload a recent Swift development snapshot from swift.org and set it as `SOURCEKIT_TOOLCHAIN_PATH` when running tests. But that’s not a great experience for new contributors. Instead, if sourcekitd doesn’t support the semantic tokens request, simply skip the test.

This also changes the implementation of the semantic tokens LSP request slightly: When the sourcekitd request to get semantic tokens fails, we now fail the entire LSP request, instead of returning the tokens from the synax tree. I think that’s reasonable because the editor did ask for semantic tokens, not syntactic tokens.

Fixes #940
rdar://117590581
2023-10-31 08:26:55 -07:00
Alex Hoppen
c37b4b8a8c Always require a prefix for orLog calls
Otherwise it’s very easy to end up with log messages like `requestCancelled` for which it’s not clear where they are coming from.
2023-10-30 16:55:50 -07:00
Alex Hoppen
9f7ff0891a Merge pull request #944 from ahoppen/ahoppen/declname
Rename `qualifiedDeclName` to `declName` in document symbols
2023-10-30 14:25:42 -07:00
Alex Hoppen
f4a07df3c5 Merge pull request #943 from ahoppen/ahoppen/latest-snapshot-throw
Make `DocumentManager.latestSnapshot` throw if no snapshot exists for the URI
2023-10-30 13:56:01 -07:00
Alex Hoppen
8d71b317a4 Merge pull request #946 from ahoppen/ahoppen/remove-connection-sendsync
Remove `Connection.sendSync`
2023-10-27 14:04:00 -07:00
Alex Hoppen
96e0e48b0d Make DocumentManager.latestSnapshot throw if no snapshot exists for the URI
This simplifies most calls that would log an error + return an empty response if no document was found.
2023-10-27 12:59:44 -07:00
Alex Hoppen
baa450a602 Remove Connection.sendSync
All callers should call the async version `Connection.send`.
2023-10-27 10:42:00 -07:00
Alex Hoppen
02606d22fa Rename qualifiedDeclName to declName in document symbols
`qualifiedDeclName` wasn’t the correct term here.
2023-10-27 10:11:38 -07:00
Alex Hoppen
5bdd6f253b Refactor SwiftLanguageServer to be able to call the async version of SourceKitD.send
Resolves #869
rdar://116703689
2023-10-26 21:38:25 -07:00
Alex Hoppen
c667741b7e Change most SourceKitD.sendSync calls to call the async alternative 2023-10-26 21:38:25 -07:00