Commit Graph

27032 Commits

Author SHA1 Message Date
Lukas Wirth
91046e9e45 fix: Fix completions analysis not caching all nodes in Semantics 2023-12-22 13:01:48 +01:00
Lukas Wirth
9d24764624 internal: Cleanup Expander a bit 2023-12-22 13:01:13 +01:00
bors
d2dacc0393 Auto merge of #16182 - Veykril:world-symbols-focus-range, r=Veykril
internal: Update world symbols request definiton, prefer focus range for macros

Prior to this, the symbol search would always jump to the defining macro call, not it jumps to the name in the macro call input if possible. This is a large improvement for assoc items in an attribute impl or trait.
2023-12-22 10:54:01 +00:00
bors
23a1280106 Auto merge of #16137 - unexge:complete-macros-in-macro-use, r=Veykril
Complete exported macros in `#[macro_use($0)]`

Closes https://github.com/rust-lang/rust-analyzer/issues/15657.

Originally added a test case for incomplete input:
```rust
#[test]
fn completes_incomplete_syntax() {
    check(
        r#"
//- /dep.rs crate:dep
#[macro_export]
macro_rules! foo {
    () => {};
}

//- /main.rs crate:main deps:dep
#[macro_use($0
extern crate dep;
"#,
        expect![[r#"
                ma foo
            "#]],
    )
}
```

but couldn't make it pass and removed it 😅 Our current recovering logic doesn't work for token trees and for this code:
```rust
#[macro_use(
extern crate lazy_static;

fn main() {}
```

we ended up with this syntax tree:
```
SOURCE_FILE@0..53
  ATTR@0..52
    POUND@0..1 "#"
    L_BRACK@1..2 "["
    META@2..52
      PATH@2..11
        PATH_SEGMENT@2..11
          NAME_REF@2..11
            IDENT@2..11 "macro_use"
      TOKEN_TREE@11..52
        L_PAREN@11..12 "("
        WHITESPACE@12..13 "\n"
        EXTERN_KW@13..19 "extern"
        WHITESPACE@19..20 " "
        CRATE_KW@20..25 "crate"
        WHITESPACE@25..26 " "
        IDENT@26..37 "lazy_static"
        SEMICOLON@37..38 ";"
        WHITESPACE@38..40 "\n\n"
        FN_KW@40..42 "fn"
        WHITESPACE@42..43 " "
        IDENT@43..47 "main"
        TOKEN_TREE@47..49
          L_PAREN@47..48 "("
          R_PAREN@48..49 ")"
        WHITESPACE@49..50 " "
        TOKEN_TREE@50..52
          L_CURLY@50..51 "{"
          R_CURLY@51..52 "}"
  WHITESPACE@52..53 "\n"
```

Maybe we can try to parse the token tree in `crates/ide-completion/src/context/analysis.rs` but I'm not sure what's the best way forward.
2023-12-22 10:42:38 +00:00
Lukas Wirth
2a5b60b186 internal: Update world symbols request definiton, prefer focus range for macros 2023-12-22 11:42:08 +01:00
bors
20e09c6968 Auto merge of #16088 - Veykril:proc-macro-srv-2, r=Veykril
feat: Implement a rust-analyzer span backed proc-macro server mode

This implements the basic span APIs. Basically anything that doesn't require talking back to the client for information access.

This also commits our syntax fixup marker to use an `ErasedAstFileId` of `!0-1` aka `0xffff_fffe`, instead of using a dummy FileId as a marker, as we need that for the `SourceFile` API to be implementable. The reason as to why the server needs to know about this at all is to prevent it from creating invalid fixup spans which could make r-a panic.
2023-12-22 09:49:05 +00:00
Lukas Wirth
5761b50ed8 More general server config message for proc-macro-api 2023-12-22 10:35:10 +01:00
Lukas Wirth
9e8e124269 Special case fixup spans in server::Span impl, they are immutable 2023-12-22 10:13:00 +01:00
Lukas Wirth
2e52aa1615 Clean up 2023-12-21 17:24:00 +01:00
Lukas Wirth
ca957f4f82 Fix proc-macro-test-impl building without any proc-macros 2023-12-21 17:24:00 +01:00
Lukas Wirth
9197b541c2 Fix dead code warnings 2023-12-21 17:23:56 +01:00
Lukas Wirth
96051bc0d8 Fix workspace layout 2023-12-21 17:23:36 +01:00
Lukas Wirth
874df3bffa Add eager-expand comment 2023-12-21 17:23:36 +01:00
Lukas Wirth
c89fd01739 Move proc-macro-test into proc-macro-srv 2023-12-21 17:23:33 +01:00
Lukas Wirth
f427f56812 Implement other non-db reliant server::Span functions 2023-12-21 17:23:04 +01:00
Lukas Wirth
428a34a9b4 Implement server::Span::Join 2023-12-21 17:23:04 +01:00
Lukas Wirth
6be83b8204 Fix IDE layer not resolving assoc type paths in path qualifiers 2023-12-21 17:23:03 +01:00
Lukas Wirth
a892237ed4 Add rust-analyzer-span server feature equivalent to the ID server 2023-12-21 17:22:59 +01:00
bors
3ce35931db Auto merge of #16178 - Veykril:builtin-fn-callsite, r=Veykril
fix: Fix span marking for builtin fn macros
2023-12-21 15:22:23 +00:00
Lukas Wirth
5bdb479131 fix: Fix span marking for builtin fn macros 2023-12-21 16:20:27 +01:00
bors
9ee71b43ca Auto merge of #16175 - Veykril:dummy-spans, r=Veykril
fix: Correctly set and mark the proc-macro spans

This slows down analysis by 2-3s on self for me unfortunately (~2.5% slowdown)

Noisy diff due to two simple refactoring in the first 2 commits. Relevant changes are [7d762d1](7d762d18ed) and [1e1113c](1e1113cf5f) which introduce def site spans and correct marking for proc-macros respectively.
2023-12-21 10:00:13 +00:00
Lukas Wirth
1e1113cf5f Correctly set and mark the proc-macro spans 2023-12-21 10:51:54 +01:00
Lukas Wirth
7d762d18ed Record macro def site spans 2023-12-21 09:54:47 +01:00
Lukas Wirth
51a9e7831a Rename some things and turn macro to macro def into a query 2023-12-21 09:18:25 +01:00
Lukas Wirth
071fe4e4e9 Move Intern and Lookup traits to hir-expand 2023-12-20 21:24:20 +01:00
bors
337e2abb67 Auto merge of #16167 - Veykril:dummy-spans, r=Veykril
fix: Fully remove dummy spans

Fixes https://github.com/rust-lang/rust-analyzer/issues/16008

Some of these spans are certainly wrong, but since we discard invisible delimiters currently it doesn't really matter.
2023-12-20 13:33:36 +00:00
bors
65ed198819 Auto merge of #16066 - Young-Flash:auto_remove_brace, r=lnicola
fix: auto remove unnecessary braces after remove unused imports

before
![before](https://github.com/rust-lang/rust-analyzer/assets/71162630/8d44f955-f84f-4a92-b13f-5a2dee2ded36)

after
![after](https://github.com/rust-lang/rust-analyzer/assets/71162630/1eab23c8-39bd-4711-97c1-d483ce400a18)
2023-12-20 13:22:00 +00:00
Lukas Wirth
f211a40f1f Remove SyntaxContext trait 2023-12-20 14:02:40 +01:00
Lukas Wirth
7b804552a5 Remove Delimiter::DUMMY_INVISIBLE 2023-12-20 14:00:14 +01:00
Lukas Wirth
2c6ce480e3 Remove Delimier::dummy_invisible 2023-12-20 13:06:46 +01:00
Lukas Wirth
4ec81230db Remove usages of Span::DUMMY 2023-12-20 12:53:46 +01:00
Young-Flash
4cd939ad08 chore: add test case for nested use tree 2023-12-20 19:44:57 +08:00
Young-Flash
bc2dee7429 feat: auto remove unnecessary braces after remove unused imports 2023-12-20 19:44:53 +08:00
bors
7bdf48ce37 Auto merge of #16165 - Veykril:meta-vars, r=Veykril
fix: Update metavariable expression implementation

Fixes https://github.com/rust-lang/rust-analyzer/issues/16154
This duplicates behavior of that before and after PR https://github.com/rust-lang/rust/pull/117050 based on the toolchain version. There are some 1.76 nightlies that are still broken (any before that PR basically) but fetching and storing the commit makes little sense to me (opposed to the toolchain version).
2023-12-20 10:30:58 +00:00
Lukas Wirth
f48ecb6e09 Try to support pre and post-change metavars 2023-12-19 20:45:12 +01:00
Lukas Wirth
8753ca5360 fix: Update metavariable expression implementation 2023-12-19 11:55:00 +01:00
bors
831d0e01b3 Auto merge of #16162 - sanjaiyan-dev:sanjaiyan-async-concurrent, r=lnicola
minor: Optimizing Performance with `Promise.all` 🏎

Hello,

This pull request introduces a modest performance improvement by executing asynchronous tasks using `Promise.all`, thereby enhancing the efficient utilization of hardware resources.

Thank you for considering this enhancement.

Ref-: https://github.com/rust-lang/rust/pull/119108
2023-12-19 09:31:34 +00:00
bors
37b00196ad Auto merge of #16164 - lnicola:bump-test-electron, r=lnicola
minor: Bump `@vscode/test-electron`

Fixes this failure in #16162:

![image](https://github.com/rust-lang/rust-analyzer/assets/308347/d52e9b51-ce35-4145-bb43-20af82cc4e26)
2023-12-19 09:19:59 +00:00
Laurențiu Nicola
f178a8becd Bump test-electron 2023-12-19 10:32:56 +02:00
bors
7204ee1262 Auto merge of #16163 - Veykril:goto-impl-fix, r=Veykril
fix: Deduplicate annotations

Fixes https://github.com/rust-lang/rust-analyzer/issues/16157
2023-12-19 07:50:23 +00:00
Lukas Wirth
002e611d09 fix: Deduplicate annotations 2023-12-19 08:49:00 +01:00
Sanjaiyan Parthipan
f587b54340
perf: Run async task in concurrent 2023-12-19 13:16:55 +05:30
bors
dbd0b035e6 Auto merge of #16155 - Waqar144:work/fix-16142, r=lnicola
fix: Dont assume ascii in remove_markdown

Fixes #16142
2023-12-19 07:22:46 +00:00
bors
1c4c2200eb Auto merge of #16160 - Waqar144:work/use-reserve, r=Veykril
minor: Use reserve when removing markdown from text

After markdown syntax removal the length of the text is roughly the same so we can reserve memory beforehand
2023-12-19 07:11:20 +00:00
bors
484525f8d7 Auto merge of #16158 - saiintbrisson:fix/mbe/desugar-comment-to-raw-string, r=Veykril
fix(mbe): desugar doc correctly for mbe

Fixes #16110.

The way rust desugars doc comments when expanding macros is rendering it as raw strings delimited with hashes. Rust-analyzer wasn't aware of this, so the desugared doc comments wouldn't match correctly when on the LHS of macro declarations.

This PR fixes this by porting the code used by rustc:
59096cdad0/compiler/rustc_ast/src/tokenstream.rs (L662-L671)
2023-12-19 07:00:35 +00:00
bors
f1d09c9c7c Auto merge of #16159 - Waqar144:work/simplify, r=Veykril
minor: use a single push_str instead of 2 push
2023-12-19 06:49:22 +00:00
Waqar Ahmed
13177e314d minor: Use reserve when removing markdown from text
After markdown syntax removal the length of the text is roughly the
same so we can reserve memory beforehand
2023-12-19 11:22:02 +05:00
Waqar Ahmed
9f4d26901b minor: use a single push_str instead of 2 push 2023-12-19 11:17:09 +05:00
Luiz Carvalho
6f58e98f2c
fix(mbe): update test 2023-12-19 01:03:00 -03:00
Luiz Carvalho
117a28a065
fix(mbe): desugar doc correctly for mbe
Fixes #16110.

The way rust desugars doc comments when expanding macros
is rendering it as raw strings delimited with hashes.
Rust-analyzer wasn't aware of this, so the desugared doc
comments wouldn't match correctly when on the LHS of macro
declarations.

This PR fixes this by porting the code used by rustc: 4cfdbd328b/compiler/rustc_ast/src/tokenstream.rs (L6837)
2023-12-19 00:55:56 -03:00