Commit Graph

2546 Commits

Author SHA1 Message Date
Johannes Altmanninger
d24b0ba330 Fix off-by-one error converting to LSP UTF8 offsets with multi-byte char
On this file,

```rust
fn main() {
    let 된장 = 1;
}
```

when using `"positionEncodings":["utf-16"]` I get an "unused variable" diagnostic on the variable
name (codepoint offset range `8..10`). So far so good.

When using `positionEncodings":["utf-8"]`, I expect to get the equivalent range in bytes (LSP:
"Character offsets count UTF-8 code units (e.g bytes)."), which is `8..14`, because both
characters are 3 bytes in UTF-8.  However I actually get `10..14`.

Looks like this is because we accidentally treat a 1-based index as an offset value: when
converting from our internal char-indices to LSP byte offsets, we look at one character to many.
This causes wrong results if the extra character is a multi-byte one, such as when computing
the start coordinate of 된장.

Fix that by actually passing an offset. While at it, fix the variable name of the line number,
which is not an offset (yet).

Originally reported at https://github.com/kakoune-lsp/kakoune-lsp/issues/740
2024-04-03 14:46:51 +02:00
bors
3691380c35 Auto merge of #16920 - Veykril:clippy-lints, r=Veykril
internal: Fix new nightly clippy lints
2024-04-01 16:00:18 +00:00
Lukas Wirth
2ae3e57c26 Fix new clippy lints 2024-04-01 17:55:56 +02:00
Lukas Wirth
ff279f1e91 Fix allFeatures config docs 2024-04-01 14:16:36 +02:00
bors
a6ddf5fb80 Auto merge of #16961 - Wilfred:fix_crate_ids, r=Veykril
Fix crate IDs when multiple workspaces are loaded

Previously, we assumed that the crate numbers in a `rust-project.json` always matched the `CrateId` values in the crate graph. This isn't true when there are multiple workspaces, because the crate graphs are merged and the `CrateId` values in the merged graph are different.

This broke flycheck (see first commit), because we were unable to find the workspace when a file changed, so we every single flycheck, producing duplicate compilation errors.

Instead, use the crate root module path to look up the relevant flycheck. This makes `ProjectWorkspace::Json` consistenet with `ProjectWorkspace::Cargo`.

Also, define a separate JSON crate number type, to prevent bugs like this happening again.
2024-04-01 10:43:06 +00:00
bors
2678660880 Auto merge of #16924 - poliorcetics:ab/push-kxwqvtypvlsq, r=Veykril
feat: Add `rust-analyzer.cargo.allTargets` to configure passing `--all-targets` to cargo invocations

Closes #16859

## Unresolved question:

Should this be a setting for build scripts only ? All the other `--all-targets` I found where already covered by `checkOnSave.allTargets`
2024-04-01 10:30:15 +00:00
bors
a8b7acf22f Auto merge of #16971 - HKalbasi:test-explorer, r=HKalbasi
Resolve tests per file instead of per crate in test explorer

Fix part of #16827
2024-03-29 02:06:22 +00:00
hkalbasi
beec6914c8 Resolve tests per file instead of per crate in test explorer 2024-03-29 05:34:43 +03:30
Wilfred Hughes
5e370b1cb8 Use crate root to choose relevant workspace for flycheck 2024-03-27 10:33:20 -07:00
Alexis (Poliorcetics) Bourget
8f9a58c73d
fix: check for client support of relative glob patterns before using them 2024-03-27 03:21:34 +01:00
Alexis (Poliorcetics) Bourget
174af88e76
feat: Add rust-analyzer.cargo.allTargets to configure passing --all-targets to cargo invocations 2024-03-27 01:57:41 +01:00
bors
0583aaa555 Auto merge of #16805 - dfireBird:lifetime_lowering, r=Veykril
feat: Implement resolving and lowering of Lifetimes (no inference yet)
2024-03-26 07:58:43 +00:00
bors
e52bb8cddb Auto merge of #16906 - Young-Flash:limit_struct_hover_display, r=Veykril
feat: limit struct hover display nums

follow up https://github.com/rust-lang/rust-analyzer/pull/15847, https://github.com/rust-lang/rust-analyzer/pull/15938
2024-03-25 22:13:59 +00:00
Young-Flash
d81148a009 expose config for hover struct field display 2024-03-25 19:55:19 +08:00
Laurențiu Nicola
84d38c7e94 Move xtask flags around outide the generated section 2024-03-23 11:35:32 +02:00
Lukas Wirth
8e324e98a1 Rename ProcMacroKind::FuncLike to Bang 2024-03-22 11:20:56 +01:00
Lukas Wirth
fe28e470cd Use relative glob patterns in DidChangeWatchedFilesRegistrationOptions 2024-03-21 21:27:34 +01:00
Lukas Wirth
23613a9de7 fix: Some file watching related vfs fixes 2024-03-21 21:22:19 +01:00
Lukas Wirth
cd8eb0fe6d internal: Remove span trait 2024-03-21 20:08:30 +01:00
bors
6fce1d71df Auto merge of #16892 - Veykril:crate-graph-non-eager, r=Veykril
internal: Don't eagerly try to read crate root file contents before VFS

Fixes https://github.com/rust-lang/rust-analyzer/issues/8623
2024-03-19 15:36:26 +00:00
Lukas Wirth
7b91d01360 internal: Don't eagerly try to read crate root file contents before VFS 2024-03-19 16:12:56 +01:00
bors
4e54b4bd6c Auto merge of #16889 - Veykril:utf8-path, r=Veykril
internal: Enforce utf8 paths

Cargo already requires this, and I highly doubt r-a works with non-utf8 paths generally either. This just makes dealing with paths a lot easier.
2024-03-19 14:57:18 +00:00
Lukas Wirth
399dbc074b internal: Enforce utf8 paths 2024-03-19 15:39:00 +01:00
Lukas Wirth
232125be12 minor: Do progress reporting for crate-graph construction 2024-03-19 10:06:51 +01:00
hkalbasi
92300e8f86 Use --workspace and --no-fail-fast in test explorer 2024-03-19 01:46:41 +03:30
dfireBird
8d08b337fa
include lifetime in the filter for data layout in analysis-stats
clippy fixes
2024-03-18 17:18:08 +05:30
bors
7c2bb75bc8 Auto merge of #16860 - Veykril:macarons, r=Veykril
feat: Syntax highlighting improvements

Specifically
- Adds a new `constant` modifier, attached to keyword `const` (except for `*const ()` and `&raw const ()`), `const` items and `const` functions
- Adds (or rather reveals) `associated` modifier for associated items
- Fixes usage of the standard `static` modifier, now it acts like `associated` except being omitted for methods.
- Splits `SymbolKind::Function` into `Function` and `Method`. We already split other things like that (notable self param from params), so the split makes sense in general as a lot special cases around it anyways.
2024-03-18 09:14:08 +00:00
Lukas Wirth
4a93368590 Use a hash to find the correct inlay hint when resolving 2024-03-18 09:51:51 +01:00
Lukas Wirth
3115fd8b41 Simplify inlay hints needs_resolve 2024-03-18 09:50:27 +01:00
Matthias Krüger
2a8edaa14d remove redundant clone()s 2024-03-17 14:06:21 +01:00
Lukas Wirth
640c8b722e Move custom async modifier to standard one 2024-03-17 11:10:29 +01:00
Lukas Wirth
23fff55f0c Split SymbolKind::Function into Function and Method 2024-03-17 11:07:22 +01:00
Lukas Wirth
c8f6655327 Don't emit modifiers depending on the symbol kind in lsp conversion layer 2024-03-17 10:40:32 +01:00
Lukas Wirth
66adc1cc94 Emit Const modifier in syntax highlighting for const-like things 2024-03-17 10:35:33 +01:00
hkalbasi
dcfc9ccace Distinguish integration tests from crates in test explorer 2024-03-15 17:16:28 +03:30
hkalbasi
eeff20d172 Show compilation progress in test explorer 2024-03-15 16:28:59 +03:30
Lukas Wirth
c50c4f8bbb internal: Use assoc items as anchors for spans 2024-03-15 09:28:39 +01:00
Lukas Wirth
9ba4493918 internal: Improve rooted upmapping 2024-03-12 13:46:58 +01:00
bors
8f8bcfc131 Auto merge of #16335 - lnicola:salsa-lz4-file-text, r=Veykril
internal: Compress file text using LZ4

I haven't tested properly, but this roughly looks like:

```
1246 MB
    59mb   4899 FileTextQuery

1008 MB
    20mb   4899 CompressedFileTextQuery
   555kb   1790 FileTextQuery
```

We might want to test on something more interesting, like `bevy`.
2024-03-11 13:43:33 +00:00
bors
2f872156fe Auto merge of #16808 - ShoyuVanilla:proc-macro-sem-token, r=Veykril
feat: Add proc macro semantic token type

Closes  #11529
2024-03-11 13:20:29 +00:00
Shoyu Vanilla
fc11216ad5 feat: Add proc macro semantic token type 2024-03-11 22:14:59 +09:00
bors
2320e12541 Auto merge of #16771 - Veykril:self-param-split, r=Veykril
internal: Don't desugar self param into a pattern

Small experiment to see if this simplifies things
2024-03-11 12:45:46 +00:00
Lukas Wirth
0dbaccd484 Track vscode version for conditional bug server sided bugfixes 2024-03-11 10:31:06 +01:00
Kirill Bulatov
57a0ad4343 Stop eagerly resolving inlay hint text edits for VSCode
After https://github.com/microsoft/vscode/issues/193124 was fixed,
this change is not needed anymore.
2024-03-11 10:22:02 +01:00
Lukas Wirth
458f4a2960 internal: Treat the self param as different from patterns when lowering 2024-03-11 09:46:28 +01:00
bors
574e23ec50 Auto merge of #16794 - HKalbasi:test-explorer, r=lnicola
Some minor changes in the test explorer lsp extension

followup #16662

cc `@nemethf` `@ShuiRuTian`
2024-03-09 10:01:41 +00:00
r0cky
79508d909a remove unused struct Snap in lsif 2024-03-09 09:09:27 +08:00
hkalbasi
dc99ad912a Some minor changes in the test explorer lsp extension 2024-03-09 01:21:27 +03:30
Laurențiu Nicola
a12ccd5923 Fix test 2024-03-08 20:39:47 +02:00
Laurențiu Nicola
0f43b55e83 Stop using an Arc when setting the file text 2024-03-08 20:30:12 +02:00