Commit Graph

544 Commits

Author SHA1 Message Date
Aleksey Kladov
2bfb65db93 Be consistent about token accesors 2020-04-09 18:48:13 +02:00
IceSentry
ebc61709c8 use .expr() to remove ref 2020-04-09 12:26:49 -04:00
IceSentry
ae416f3c6e clean up param hint checking 2020-04-09 10:35:07 -04:00
IceSentry
cba694c602 better &mut and & matching 2020-04-08 19:26:47 -04:00
IceSentry
de6db06322 ignore &mut and & when checking params 2020-04-08 19:07:21 -04:00
IceSentry
a2dc18f71a remove TODO 2020-04-08 18:11:24 -04:00
IceSentry
2a582b78a5 Add more heuristics for hiding obvious param hints
This will now hide "value", "pat", "rhs" and "other"
These words were selected from the std because they are used in common functions with only a single param and are obvious by their use.
I think it would be good to also hide "bytes" if the type is `[u8; n]` but I'm not sure how to get the param type signature

It will also hide the hint if the passed param starts or end with the param_name
2020-04-08 17:48:16 -04:00
bors[bot]
8ea7c9cb62
Merge #3826
3826: Flatten nested highlight ranges during DFS traversal r=matklad a=ltentrup

Implements the flattening of nested highlights from #3447.


There is a caveat: I needed to add `Clone` to `HighlightedRange` to split highlight ranges  ~and the nesting does not appear in the syntax highlighting test (it does appear in the accidental-quadratic test but there it is not checked against a ground-truth)~.

I have added a test case for the example mentioned in #3447.

Co-authored-by: Leander Tentrup <leander.tentrup@gmail.com>
2020-04-08 12:00:08 +00:00
Aleksey Kladov
4c29214bba Move computation of missing fields into hir 2020-04-07 18:34:17 +02:00
Aleksey Kladov
7819d99d6b Add functional update test 2020-04-07 18:25:47 +02:00
Aleksey Kladov
d8f6013404 Fix names of test modules 2020-04-07 18:23:18 +02:00
bors[bot]
33c364b545
Merge #3878
3878: A more precise panic macro r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-04-07 14:41:07 +00:00
Aleksey Kladov
3bde2b7423 A more precise panic macro 2020-04-07 16:40:39 +02:00
Aleksey Kladov
5540193fc8 Don't insert !() if there's already some 2020-04-07 16:37:33 +02:00
Aleksey Kladov
73ccf7f495 Reorder imports 2020-04-07 15:07:18 +02:00
Josh Mcguigan
8c378af721 missing match arms diagnostic 2020-04-07 05:12:08 -07:00
Aleksey Kladov
0215560434 Better naming for scope completion 2020-04-07 13:20:41 +02:00
Aleksey Kladov
a5ffe53c9d Better naming for path completion 2020-04-07 13:19:57 +02:00
Aleksey Kladov
baf9fcc38e
Merge pull request #3866 from lnicola/fewer-braces
Fix unnecessary braces warnings
2020-04-07 09:22:33 +02:00
Leander Tentrup
bf96d46fee Simplify HTML highlighter and add test case for highlight_injection logic 2020-04-06 23:00:09 +02:00
Aleksey Kladov
bf569f8b29 Check for eprintln on CI 2020-04-06 17:00:18 +02:00
Laurențiu Nicola
52fd2c8e48 Fix unnecessary braces warnings 2020-04-06 17:21:33 +03:00
Aleksey Kladov
ec3fb1cdb4
Merge pull request #3853 from matklad/cf
Make control token modifier less ambiguous
2020-04-06 11:53:56 +02:00
bors[bot]
4f904b2970
Merge #3829
3829: Adds to SSR match for semantically equivalent call and method call r=matklad a=mikhail-m1

#3186 
maybe I've missed some corner cases, but it works in general

Co-authored-by: Mikhail Modin <mikhailm1@gmail.com>
2020-04-06 08:15:48 +00:00
Aleksey Kladov
48bc0ca745 Make control token modifier less ambiguous
In textmate, keyword.control is used for all kinds of things; in fact,
the default scope mapping for keyword is keyword.control!

So let's add a less ambiguous controlFlow modifier

See Microsoft/vscode#94367
2020-04-06 09:57:50 +02:00
Aleksey Kladov
a5e8dfd024 Add parens for enums 2020-04-03 21:11:05 +02:00
Aleksey Kladov
b1cf95f691 Generalize call parenthesis insertion 2020-04-03 21:01:18 +02:00
Aleksey Kladov
adbcedde18 Remove the second code-path for completing names in patterns 2020-04-03 21:00:15 +02:00
Leander Tentrup
bb45aca909 Flatten nested highlight ranges during DFS traversal 2020-04-03 09:46:07 +02:00
Mikhail Modin
35a2cd08c1 Adds to SSR match for semantically equivalent call and method call 2020-04-02 20:18:44 +01:00
bors[bot]
a0cc66475a
Merge #3797
3797: Don't show chaining hints for record literals and unit structs r=matklad a=lnicola

Fixes #3796 

r? @Veetaha

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-04-01 12:18:34 +00:00
bors[bot]
aad0e63d74
Merge #3779
3779: Complete only missing fields in pats r=matklad a=SomeoneToIgnore

A follow-up for https://github.com/rust-analyzer/rust-analyzer/pull/3694

Same name vs string [issue](https://github.com/rust-analyzer/rust-analyzer/pull/3694#discussion_r396986819) persists here, now I'm able to obtain `ast::Name`, but I see no way to convert it into `hir::Name` or vice versa.

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-04-01 10:41:46 +00:00
Laurențiu Nicola
70960df437 Don't show chaining hints for record literals and unit structs 2020-04-01 13:14:41 +03:00
Kirill Bulatov
1335608dae Unite record completion logic into a single module 2020-04-01 13:03:56 +03:00
bors[bot]
e3a1f1c001
Merge #3765
3765: Adds sort for RecordLit comparison in SSR r=edwin0cheng a=mikhail-m1

an item from #3186 

Co-authored-by: Mikhail Modin <mikhailm1@gmail.com>
2020-04-01 10:01:16 +00:00
Kirill Bulatov
d35b943520 Split draft 2020-04-01 12:49:31 +03:00
Kirill Bulatov
bc71631e75 Complete only missing fields in pats 2020-04-01 12:49:31 +03:00
Mikhail Modin
47e8f3c93b Adds sort for RecordLit comparison in SSR 2020-04-01 09:39:33 +01:00
Aleksey Kladov
569f47e427 Better names for config structs 2020-03-31 16:05:25 +02:00
Kirill Bulatov
332799d914 Reload only the properties that do not affect vfs 2020-03-30 13:39:14 +03:00
Aleksey Kladov
311cbbdad5 Remove some unwraps 2020-03-28 12:27:54 +01:00
Aleksey Kladov
b764c38436 Start stdx
This crate will hold everything to small to be worth publishing
2020-03-28 11:01:25 +01:00
Edwin Cheng
d0b6ed4441 Add ProcMacroClient 2020-03-26 03:29:45 +08:00
Aleksey Kladov
2ccfb49bab Always expand macros during analysis 2020-03-25 13:53:15 +01:00
Matt Hooper
7b35da04bf Improvements based on code review feedback 2020-03-25 00:18:55 +01:00
Matt Hooper
9d298115a6 Fmt corrections 2020-03-24 23:22:41 +01:00
Matt Hooper
b70ce559b8 Added more unit tests 2020-03-24 23:22:41 +01:00
Matt Hooper
a197abbc7a Added new inlay hint kind and rules for method chaining 2020-03-24 23:18:42 +01:00
bors[bot]
9690f6bc43
Merge #3708
3708: Generalise syntax rewriting infrastructure to allow removal of nodes r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-24 16:15:08 +00:00
Aleksey Kladov
062f6e3bbe Generalise syntax rewriting infrastructure to allow removal of nodes 2020-03-24 17:14:33 +01:00
Aleksey Kladov
9bf2cd609c Align naming 2020-03-24 12:56:07 +01:00
bors[bot]
8617fe641d
Merge #3694
3694: Complete only missing fields r=matklad a=SomeoneToIgnore



Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-03-24 09:49:25 +00:00
Kirill Bulatov
f1cf1cc1ca Code review fixes
Co-Authored-By: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-24 11:33:47 +02:00
Kirill Bulatov
4e43df26b2 Consider references when applying postfix completions 2020-03-24 01:56:06 +02:00
Josh Mcguigan
df58ab8963 update itertools version to 0.9.0 2020-03-23 16:22:46 -07:00
Kirill Bulatov
00cbe81a5b Complete only missing fields 2020-03-24 00:36:06 +02:00
Edwin Cheng
6d5443ef94 Add test 2020-03-22 19:53:34 +08:00
Edwin Cheng
cba4dd1a8a Improve find_all_ref work inside macro 2020-03-22 19:53:28 +08:00
Steffen Lyngbaek
ec24c09006 Remove const
- Add test for @ matching
- Address comments
2020-03-19 14:17:34 -07:00
Steffen Lyngbaek
eb51abdc64 Fixes to more accurately give complete_scope completions
- Exclude const, static, functions form is_pat_binding_and_path
  (there might be more?)
- Add a check to filter out Record Fields
- Fix tests
2020-03-19 14:12:00 -07:00
Steffen Lyngbaek
6941a7faba - Exclude Local Scope for BindPats
- Exclude BindPats with @ or ref
- Remove outdated test and add one testing for ref
2020-03-19 14:12:00 -07:00
Steffen Lyngbaek
b6d6277362 Completition for type name? #3418
Iterate through TupleStructPat's until a MatchArm if
one exists. Store in a new is_pat_bind_and_path bool
and allow the `complete_scope` to find matches.

Added some tests to ensure it works in simple and nested cases.
2020-03-19 14:12:00 -07:00
Aleksey Kladov
de7662c852 Check that no file contains trailing ws
rustfmt allows trailing spaces in string literals unfortunately.
2020-03-17 11:42:54 +01:00
phynalle
cafacb74aa Fix typo 2020-03-17 19:15:30 +09:00
Florian Diebold
035db0fbb9 Add test, remove printlns 2020-03-16 18:38:19 +01:00
Florian Diebold
c32529ddd0 Get tests working 2020-03-16 18:38:19 +01:00
Florian Diebold
0f3a54dd4d wip 2020-03-16 18:38:19 +01:00
Florian Diebold
6305d094ac Attempt to implement ranking of rules when none matches perfectly (wip) 2020-03-16 18:38:19 +01:00
Florian Diebold
b973158aeb Make MBE expansion more resilient (WIP) 2020-03-16 18:38:19 +01:00
Veetaha
dd4ff92aa3
Remove dat fixme 2020-03-16 14:13:50 +02:00
bors[bot]
2eb1677b12
Merge #3603
3603: Fix crate display name dashes r=matklad a=SomeoneToIgnore

A follow-up of https://github.com/rust-analyzer/rust-analyzer/pull/3602#discussion_r392733525

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-03-16 10:33:13 +00:00
Kirill Bulatov
92fd430dab Use Display instead of a custom method 2020-03-16 12:03:43 +02:00
bors[bot]
a99cac671c
Merge #3540
3540: Swtches to rust SSR query check r=matklad a=mikhail-m1

related to #3186 

Co-authored-by: Mikhail Modin <mikhailm1@gmail.com>
2020-03-16 09:48:09 +00:00
Kirill Bulatov
059ed25a3e Fix crate display name dashes 2020-03-16 11:47:52 +02:00
bors[bot]
6bc226fa19
Merge #3602
3602: ra_ide: remove dead code, migrate from readonly String -> &str r=matklad a=Veetaha

https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/hover/near/190671355

Co-authored-by: veetaha <veetaha2@gmail.com>
2020-03-16 09:15:29 +00:00
veetaha
98c34b725f ra_ide: refactor readonly String -> &str 2020-03-16 02:35:59 +02:00
veetaha
4fd07a02a2 ra_ide: remove dead code in HoverResult 2020-03-16 01:30:50 +02:00
Mikhail Modin
b150965ed7 Swtches to rust SSR query check 2020-03-15 21:23:18 +00:00
bors[bot]
efa72c899d
Merge #3591
3591: Support local macro_rules r=matklad a=edwin0cheng

This PR implement local `macro_rules` in function body, by adding following things:

1. While lowering, add a `MacroDefId` in body's `ItemScope` as a textual legacy macro. 
2. Make `Expander::enter_expand` search with given `ItemScope`.
3. Make `Resolver::resolve_path_as_macro` search with `LocalItemScope`.

Fix #2181

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-03-15 12:15:09 +00:00
Florian Diebold
0a9ea782eb Fix completion of trait items
Trait items should be public by default.
2020-03-14 20:48:36 +01:00
Edwin Cheng
fe78a14bbb Support local macro_rules 2020-03-14 14:25:51 +08:00
Aleksey Kladov
a6638af4a6 Simplify tests 2020-03-13 18:00:23 +01:00
Aleksey Kladov
687bec117c Don't use generic DB where a concrete one will do 2020-03-13 17:58:49 +01:00
Florian Diebold
d6195fa21f Fix completion of HashMap::new
The `ty` function in code_model returned the type with placeholders for type
parameters. That's nice for printing, but not good for completion, because
placeholders won't unify with anything else: So the type we got for `HashMap`
was `HashMap<K, V, T>`, which doesn't unify with `HashMap<?, ?, RandomState>`,
so the `new` method wasn't shown.

Now we instead return `HashMap<{unknown}, {unknown}, {unknown}>`, which does
unify with the impl type. Maybe we should just expose this properly as variables
though, i.e. we'd return something like `exists<type, type, type> HashMap<?0,
?1, ?2>` (in Chalk notation). It'll make the API more complicated, but harder to
misuse. (And it would handle cases like `type TypeAlias<T> = HashMap<T, T>` more
correctly.)
2020-03-13 13:04:32 +01:00
Aleksey Kladov
680182d0a0 Restore cargo-fmt gating 2020-03-13 12:54:32 +01:00
bors[bot]
b0ed808266
Merge #3553
3553: Completions do not show for function with same name as mod r=matklad a=JoshMcguigan

fixes #3444 

I've added a test case in `crates/ra_ide/src/completion/complete_path.rs` which verifies the described behavior in #3444. Digging in, I found that [the module scope iterator](ba62d8bd1c/crates/ra_ide/src/completion/complete_path.rs (L22)) only provides the module `z`, and does not provide the function `z` (although if I name the function something else then it does show up here). 

I thought perhaps the name wasn't being properly resolved, but I added a test in `crates/ra_hir_def/src/nameres/tests.rs` which seems to suggest that it is? I've tried to figure out how to bridge the gap between these two tests (one passing, one failing) to see where the function `z` is being dropped, but to this point I haven't been able to track it down.

Any pointers on where I might look for this? 

Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
2020-03-13 09:18:47 +00:00
bors[bot]
56590097ed
Merge #3572
3572: Add test for completion of unresolved items r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-13 08:36:38 +00:00
Aleksey Kladov
9297f4d991 Add test for completion of unresolved items 2020-03-13 09:30:21 +01:00
CAD97
88c944f96b Remove some TextUnit->usize escapees 2020-03-12 22:33:27 -04:00
Josh Mcguigan
7208498d54 fix issue 3444 2020-03-12 17:16:28 -07:00
Aleksey Kladov
a6bb4cd0ec Fix completion tests 2020-03-12 22:03:30 +01:00
Aleksey Kladov
fd3ece2b73 Make naming more uniform 2020-03-12 17:38:48 +01:00
bors[bot]
d98a5fab46
Merge #3543
3543: Parameter inlay hint separate from variable type inlay? #2876 r=matklad a=slyngbaek

Add setting to allow enabling either type inlay hints or parameter
inlay hints or both. Group the the max inlay hint length option
into the object.

- Add a new type for the inlayHint options.
- Add tests to ensure the inlays don't happen on the server side

Co-authored-by: Steffen Lyngbaek <steffenlyngbaek@gmail.com>
2020-03-12 16:02:55 +00:00
Steffen Lyngbaek
58248e24cd Switch from Vec<InlayKind> to object with props
- Instead of a single object type, use several individual nested types
  to allow toggling from the settings GUI
- Remove unused struct definitions
- Install and test that the toggles work
2020-03-11 20:14:39 -07:00
Edwin Cheng
8c159b54e9 Add test on hover 2020-03-11 23:14:15 +08:00
Edwin Cheng
759bcea96d Implement dummy assert macro 2020-03-11 23:08:12 +08:00
Aleksey Kladov
85c30b1915 Continue multiline non-doc comment blocks 2020-03-11 12:58:16 +01:00
Aleksey Kladov
90fe534f03 Split on enter tests 2020-03-11 12:58:16 +01:00
Aleksey Kladov
52da9e90a6 Move on enter to a separate module 2020-03-11 12:58:16 +01:00
bors[bot]
c48dcf7411
Merge #3549
3549: Implement env! macro r=matklad a=edwin0cheng

This PR implements `env!` macro by adding following things:

1. Added `additional_outdirs` settings in vscode. (naming to be bikeshed)
2. Added `ExternSourceId` which is a wrapping for SourceRootId but only used in extern sources. It is because `OUT_DIR` is not belonged to any crate and we have to access it behind an `AstDatabase`.
3. This PR does not implement the `OUT_DIR` parsing from `cargo check`. I don't have general design about this,  @kiljacken could we reuse some cargo watch code for that ?

~~Block on [#3536]~~

PS: After this PR , we (kind of) completed the `include!(concat!(env!('OUT_DIR'),  "foo.rs")` macro call combo. [Exodia Obliterate!](https://www.youtube.com/watch?v=RfqNH3FoGi0)

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-03-11 10:51:07 +00:00