Commit graph

352 commits

Author SHA1 Message Date
Aleksey Kladov
2bf81922f7 internal: more reasonable grammar for blocks
Consider these expples

        { 92 }
  async { 92 }
    'a: { 92 }
   #[a] { 92 }

Previously the tree for them were

  BLOCK_EXPR
    { ... }

  EFFECT_EXPR
    async
    BLOCK_EXPR
      { ... }

  EFFECT_EXPR
    'a:
    BLOCK_EXPR
      { ... }

  BLOCK_EXPR
    #[a]
    { ... }

As you see, it gets progressively worse :) The last two items are
especially odd. The last one even violates the balanced curleys
invariant we have (#10357) The new approach is to say that the stuff in
`{}` is stmt_list, and the block is stmt_list + optional modifiers

  BLOCK_EXPR
    STMT_LIST
      { ... }

  BLOCK_EXPR
    async
    STMT_LIST
      { ... }

  BLOCK_EXPR
    'a:
    STMT_LIST
      { ... }

  BLOCK_EXPR
    #[a]
    STMT_LIST
      { ... }
2021-09-26 19:16:09 +03:00
bors[bot]
c577e128fc
Merge #10248
10248: internal: remove dead code r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-09-15 18:23:46 +00:00
Aleksey Kladov
73b0f9dc04 internal: remove dead code 2021-09-15 21:22:06 +03:00
bors[bot]
911659a166
Merge #10048
10048: fix: correctly complete macro call if cursor at `!` r=Veykril a=unexge

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/9904

Co-authored-by: unexge <unexge@gmail.com>
2021-09-15 18:13:09 +00:00
bors[bot]
249ebdd076
Merge #10229
10229: fix: do not complete builtin attributes for qualified paths r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-09-13 22:31:39 +00:00
Lukas Wirth
845904f0bb fix: do not complete builtin attributes for qualified paths 2021-09-14 00:31:14 +02:00
Lukas Wirth
aa1b36dc6d Downmap the token in attribute inputs when expanding speculatively 2021-09-14 00:04:04 +02:00
Lukas Wirth
2b907652ee Speculatively expand attributes in completions 2021-09-13 19:30:23 +02:00
Aleksey Kladov
076c972e3b internal: prevent possible bugs when adding magical comments 2021-09-13 13:43:13 +03:00
Giles Cope
4ccd90af81
remove unused deps 2021-09-11 16:20:04 +01:00
Laurențiu Nicola
d27ed8c243 Avoid extra allocation in completion rendering 2021-09-06 17:55:07 +03:00
bors[bot]
cbc13ae6bd
Merge #10152
10152: feat: Add completion for raw identifiers r=matklad a=nabakin

![rust_analyzer_pr](https://user-images.githubusercontent.com/894305/132110362-c21b713d-acaf-4a6d-9749-ff812172cbce.gif)
Adds support for valid Rust completion of raw identifiers.

Previously, code completion of fields made via raw identifiers would not re-insert those raw identifiers, resulting in invalid Rust code. Now, code completion of fields made via raw identifiers do re-insert those raw identifiers, resulting in valid Rust code.

The same is true for all code completion instances for fields and compatible Rust identifiers.

Co-authored-by: Blake Wyatt <894305+nabakin@users.noreply.github.com>
2021-09-06 10:54:18 +00:00
bors[bot]
0bc8e2acb8
Merge #10154
10154: feat: Complete `#![recursion_limit = "N"]` instead of `#![recursion_limit = N]` r=lnicola a=hkmatsumoto

Currently ra emits `#![recursion_limit = 128]`, but this should rather be `#![recursion_limit = "128"]`

Co-authored-by: Hirochika Matsumoto <git@hkmatsumoto.com>
2021-09-06 10:38:41 +00:00
Jonas Schievink
8e736da456 Recover from statement macro expansion errors 2021-09-06 00:16:12 +02:00
Hirochika Matsumoto
1f238b3bb5 Complete #![recursion_limit = "N"] over #![recursion_limit = N] 2021-09-05 18:05:06 +09:00
Blake Wyatt
6c51ecad5b Add completion for raw identifiers 2021-09-04 19:28:59 -04:00
Lukas Wirth
40a2faee65 Enable flyimport for ident patterns 2021-09-01 16:13:53 +02:00
unexge
e0e7f0c170 Move "complete macro call if cursor at ! token" logic to MacroRender 2021-09-01 09:11:20 +03:00
Dezhi Wu
ba0947dded switch log crate to tracing 2021-08-30 15:11:42 +08:00
Lukas Wirth
ebb87fe157 Don't use fake text range in original node search as is in completions 2021-08-27 15:10:42 +02:00
Lukas Wirth
5012fa2dd4 Add completion tests for cursor after items 2021-08-27 14:21:17 +02:00
unexge
c0d2b44250 fix: correctly complete macro call if cursor at ! 2021-08-26 19:44:46 +03:00
Frank Steffahn
3a5a93595f Fix typos “a”→“an” 2021-08-22 14:31:37 +02:00
Lukas Wirth
833de22d0b fix: Do not show functional update completion when already qualified 2021-08-21 20:45:15 +02:00
bors[bot]
933a4dc3a6
Merge #9902
9902: minor: move functionality to a better place r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-08-14 17:43:52 +00:00
Aleksey Kladov
3c49a9f079 minor: move functionality to a better place 2021-08-14 20:43:28 +03:00
bors[bot]
1e0d20366f
Merge #9900
9900: internal: remove one more usage of old editing API. r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-08-14 17:17:51 +00:00
Aleksey Kladov
e300f58d2c internal: remove one more usage of old editing API. 2021-08-14 20:17:16 +03:00
Lukas Wirth
2e733b1a3e Simplify 2021-08-14 19:09:36 +02:00
Lukas Wirth
bf918046fa Only complete type annotations for patterns in function params 2021-08-14 18:18:32 +02:00
Lukas Wirth
73b7b34f89 Fill out expected type for functional update syntax completion 2021-08-11 18:12:44 +02:00
Lukas Wirth
f6d6fda85b Refine functional update completion some more 2021-08-10 17:03:38 +02:00
bors[bot]
f6ef043a88
Merge #9845
9845: fix: Do not drop `..Default::default()` completion when typing `..` r=Veykril a=Veykril

cc https://github.com/rust-analyzer/rust-analyzer/issues/9839
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-08-10 13:08:58 +00:00
Lukas Wirth
e729529410 Do not drop ..Default::default() completion when typing .. 2021-08-10 15:08:35 +02:00
Lukas Wirth
7e6eb67f0d Substitute generic types in inline_call 2021-08-10 14:39:56 +02:00
Aleksey Kladov
3e5b155716 fix: avoid pathological macro expansions
Today, rust-analyzer (and rustc, and bat, and IntelliJ) fail badly on
some kinds of maliciously constructed code, like a deep sequence of
nested parenthesis.

"Who writes 100k nested parenthesis" you'd ask?

Well, in a language with macros, a run-away macro expansion might do
that (see the added tests)! Such expansion can be broad, rather than
deep, so it bypasses recursion check at the macro-expansion layer, but
triggers deep recursion in parser.

In the ideal world, the parser would just handle deeply nested structs
gracefully. We'll get there some day, but at the moment, let's try to be
simple, and just avoid expanding macros with unbalanced parenthesis in
the first place.

closes #9358
2021-08-09 16:15:02 +03:00
Aleksey Kladov
0e437c809b fix: add ! to macro completions with existing arg 2021-08-08 15:53:31 +03:00
bors[bot]
546d718a7e
Merge #9808
9808: fix: Look for enum variants and trait assoc functions when looking for lang items r=matklad a=Veykril

Examples for lang enum variants are the `Option` variants.
Assoc trait functions aren't being seen since they aren't declared in the direct module scope.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-08-08 10:41:45 +00:00
Lukas Wirth
50d46863ef Look for enum variants and trait assoc functions when looking for lang items 2021-08-07 22:30:13 +02:00
Alexandre Fourcat
9beefef8f9
Add completion for struct literal in which all fields are visible.
Fix ide_completion tests.

Move 'complete_record_literal' call to the main completion function.

Fix a rendering bug when snippet not available.

Checks if an expression is expected before adding completion for struct literal.

Move 'completion struct literal with private field' test to 'expressions.rs' test file.

Update 'expect' tests with new check in 'complete record literal'.
2021-08-04 18:52:58 +02:00
bors[bot]
00c8cab20b
Merge #9765
9765: internal: Introduce TypeInfo r=Veykril a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-08-03 15:32:51 +00:00
Lukas Wirth
b96f1adf5c Give TypeInfo fields and methods more appropriate names 2021-08-03 17:28:51 +02:00
Lukas Wirth
25ff7171c4 Introduce TypeInfo 2021-08-03 16:41:53 +02:00
bors[bot]
4b0c97668c
Merge #9772
9772: feat: filter out duplicate macro completions r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-08-03 14:37:25 +00:00
Aleksey Kladov
2f9273633b feat: filter out duplicate macro completions
closes #9303
2021-08-03 17:36:06 +03:00
bors[bot]
da894358e1
Merge #9764
9764: fix: Don't use the module as the candidate node in fuzzy path flyimport r=Veykril a=Veykril

The problem was that the candidate node is whats being used for the scope, so using an inline module will yield the surrounding scope of the module instead of the scope of the module itself.
Also seems to fix the problem in this comment https://github.com/rust-analyzer/rust-analyzer/issues/9760#issuecomment-891125674, though I could not recreate that in a test for some reason.

Fixes #9760

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-08-02 18:43:02 +00:00
Lukas Wirth
e138676664 Don't use the module as the candidate node in fuzzy path flyimport 2021-08-02 19:56:32 +02:00
Aleksey Kladov
8b6ea1545f simplify 2021-08-02 14:27:11 +03:00
Aleksey Kladov
71cd67fe47 failing test 2021-08-02 14:27:11 +03:00
Lukas Wirth
1edbaa29f9 Wrap inner tail expressions in MissingOkOrSomeInTailExpr 2021-07-31 20:00:09 +02:00