Commit graph

5599 commits

Author SHA1 Message Date
Aleksey Kladov
0bf903411c Use match_ast 2020-03-18 20:51:47 +01:00
Aleksey Kladov
3f6dc20d3c Merge imports assist
Work towards #2220
2020-03-18 19:34:47 +01:00
Aleksey Kladov
4e50efcfc5 Strongly-typed generic methods for editing nodes 2020-03-18 19:34:47 +01:00
Aleksey Kladov
3c88ef76d6 Reduce visibility 2020-03-18 16:48:45 +01:00
veetaha
4d83961acb ra_hir_def: remove dat fixme 2020-03-18 02:35:49 +02:00
Emil Lauridsen
2dd887de47 Use dyn-ref instead of impl to impact compile times the least 2020-03-17 14:56:53 +01:00
Emil Lauridsen
5af81b8456 Slight readablity improvement 2020-03-17 14:56:14 +01:00
Emil Lauridsen
e154132c91 Remove outDirOverrides 2020-03-17 14:55:44 +01:00
Emil Lauridsen
f84deffd72 Support loading OUT_DIR for CLI runs 2020-03-17 14:47:05 +01:00
Emil Lauridsen
4fb79f2ca0 Support specifying OUT_DIR in json project 2020-03-17 14:47:05 +01:00
Emil Lauridsen
f5a2fcf8f5 Change existing OUT_DIR override config to make use of new infrastructure 2020-03-17 14:47:05 +01:00
Emil Lauridsen
33c6c7abc6 Support loading OUT_DIR from cargo check at launch 2020-03-17 14:47:05 +01: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
6c20d7e979 Small fixes 2020-03-16 18:46:08 +01:00
Florian Diebold
32dce75747 Some more refactoring 2020-03-16 18:38:19 +01:00
Florian Diebold
d6b622cdef Some cleanup 2020-03-16 18:38:19 +01:00
Florian Diebold
d655749aae Turn ExpandResult into struct 2020-03-16 18:38:19 +01:00
Florian Diebold
f3c6a2e3db Fix remaining test failure 2020-03-16 18:38:19 +01:00
Florian Diebold
0660dd10d2 Fix performance problem 2020-03-16 18:38:19 +01:00
Florian Diebold
e6ec4a329f Better fix for stuck parser? 2020-03-16 18:38:19 +01: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
Aleksey Kladov
9faea2364d Use dyn Trait for working with databse
It improves compile time in `--release` mode quite a bit, it doesn't
really slow things down and, conceptually, it seems closer to what we
want the physical architecture to look like (we don't want to
monomorphise EVERYTHING in a single leaf crate).
2020-03-16 17:42:30 +01:00
Veetaha
dd4ff92aa3
Remove dat fixme 2020-03-16 14:13:50 +02:00
bors[bot]
a007a123af
Merge #3573
3573: Check all crates of the workspace r=matklad a=matklad

Previously, if the root of the was was a real crate, only this crate
was checked.

Ideally, we might want some kind of config here (which might be just
overriding the whole command), but `--workspace` is def a nicer
default.

r? @kiljacken 

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-16 11:55:36 +00:00
bors[bot]
5bdc249b2c
Merge #3587
3587: Use WorkDoneProgress LSP API for initial load r=matklad a=slyngbaek

Addresses #3283

Rather than using custom UI for showing the loaded state. Rely
on the WorkDoneProgress API in 3.15.0
https://microsoft.github.io/language-server-protocol/specification#workDoneProgress.

No client-side work was necessary. The UI is not exactly what is
described in the issue but afaict that's how VS Code implements the LSP
API.

- The WorkDoneProgressEnd does not appear to display its message
  contents (controlled by vscode)

Co-authored-by: Steffen Lyngbaek <steffenlyngbaek@gmail.com>
2020-03-16 11:48:46 +00: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]
6616f336b2
Merge #3598
3598: ra_hir_expand: migrate to impl_intern_key!() r=matklad a=Veetaha



Co-authored-by: Veetaha <gerzoh1@gmail.com>
Co-authored-by: Veetaha <veetaha2@gmail.com>
2020-03-16 09:41:38 +00: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
Steffen Lyngbaek
b6dec2eb1f Fix tests part 2... 2020-03-15 23:32:28 -07:00
Steffen Lyngbaek
70ccda3941 Fix broken tests
- Handle case of no projects. The notification still needs to be posted
2020-03-15 21:44:27 -07:00
Steffen Lyngbaek
e3db4f3716 Rely on the safer workspace_loaded check 2020-03-15 20:48:39 -07: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
Veetaha
7eb5d89a85
ra_hir_expand: change the ordering of imports as per the formatter 2020-03-15 18:51:09 +02:00
Veetaha
cbd9f46bc7
ra_hir_expand: migrate to impl_intern_key!() 2020-03-15 18:25:55 +02: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
Steffen Lyngbaek
5a1e531176 Fix broken tests
- Properly wait for workspace loading to be done
2020-03-13 22:06:49 -07:00
Steffen Lyngbaek
f0b58fd1fa Use idiomatic way of defining floats 2020-03-13 16:27:39 -07:00
Steffen Lyngbaek
083035fd06 Use WorkDoneProgress LSP API for initial load
Addresses #3283

Rather than using custom UI for showing the loaded state. Rely
on the WorkDoneProgress API in 3.15.0
https://microsoft.github.io/language-server-protocol/specification#workDoneProgress.

No client-side work was necessary. The UI is not exactly what is
described in the issue but afaict that's how VS Code implements the LSP
API.

- The WorkDoneProgressEnd does not appear to display its message
  contents (controlled by vscode)
2020-03-13 16:03:02 -07:00
Aleksey Kladov
6eb05c4a14 Simplify 2020-03-13 18:02:04 +01: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
bors[bot]
4c85e53531
Merge #3561 #3577
3561: feat: add debug code lens r=matklad a=hdevalke

Refs #3539

3577: Protect against infinite macro expansion in def collector r=edwin0cheng a=flodiebold

Something I noticed while trying to make macro expansion more resilient against errors.

There was a test for this, but it wasn't actually working because the first recursive expansion failed. (The comma...)

Even with this limit, that test (when fixed) still takes some time to pass because of the exponential growth of the expansions, so I disabled it and added a different one without growth.

CC @edwin0cheng 

Co-authored-by: Hannes De Valkeneer <hannes@de-valkeneer.be>
Co-authored-by: hdevalke <2261239+hdevalke@users.noreply.github.com>
Co-authored-by: Florian Diebold <florian.diebold@freiheit.com>
2020-03-13 14:01:29 +00:00
Florian Diebold
89eb9e8002 Protect against infinite macro expansion in def collector
There was a test for this, but it wasn't actually working because the first
recursive expansion failed. (The comma...)

Even with this limit, that test (when fixed) still takes some time to pass
because of the exponential growth of the expansions, so I disabled it and added
a different one without growth.
2020-03-13 14:50:03 +01:00
Aleksey Kladov
bee5cdb359 Parse variadics correctly
closes #3571
2020-03-13 13:54:14 +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
Aleksey Kladov
1e19847af3 Move verbose tests out of line 2020-03-13 12:20:42 +01:00
Aleksey Kladov
f2dd023150 Check all crates of the workspace
Previously, if the root of the was was a real crate, only this crate
was checked.

Ideally, we might want some kind of config here (which might be just
overriding the whole command), but `--workspace` is def a nicer
default.
2020-03-13 10:59:20 +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
Hannes De Valkeneer
39c92b3872 fixup! feat: add debug code lens
autodetect vscode-lldb
2020-03-12 22:31:47 +01:00
Aleksey Kladov
a6bb4cd0ec Fix completion tests 2020-03-12 22:03:30 +01:00
Hannes De Valkeneer
e9d025b618 fixup! feat: add debug code lens
avoid repetition of `--no-run`
2020-03-12 21:28:26 +01:00
hdevalke
60b154ff92
Update crates/rust-analyzer/src/main_loop/handlers.rs
use `Vec::new` instead of `Vec::with_capacity(0)`

Co-Authored-By: Veetaha <veetaha2@gmail.com>
2020-03-12 20:56:34 +01:00
Aleksey Kladov
b3fa7312a7 Simpler deserialization 2020-03-12 18:01:36 +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
bors[bot]
944bd2cbc3
Merge #3559
3559: Implement builtin assert! macro r=matklad a=edwin0cheng

This PR add a dummy implementation for `assert!` macro, which mainly make `hover` and `goto-def` works on arguments inside it.

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-03-12 15:38:04 +00:00
bors[bot]
7bbdca6182
Merge #3564
3564: Better handling of a few kinds of cargo/clippy diagnostics r=matklad a=kiljacken

This was initially supposed to just be a fix for #3433, but I caught a few things that ended up being useful as well.

This PR primarily makes us handle multi-edit fix suggestions properly. Instead of just applying the first fix we apply all the parts of the fix in a single action.

Second up, this PR handles diagnostics with multiple primary spans, f.x. the unused import diagnostic from rustc:
![image](https://user-images.githubusercontent.com/209321/76531793-03269480-6476-11ea-9180-41c0ea705553.png)

The LSP doesn't handle this too well, as it only support a single complete range for each diagnostic, so we get duplicate messages in the problem panel of VSCode:
![image](https://user-images.githubusercontent.com/209321/76531901-29e4cb00-6476-11ea-9746-cd57f8974b85.png)

However, I feel like the improved visual aspect in-editor outweighs the duplication in the problem panel. I'm open to not including the second commit if anybody really doesn't like the idea of duplicate diagnostics in the problem pane.

Fixes #3433
Fixes #3257

Co-authored-by: Emil Lauridsen <mine809@gmail.com>
2020-03-12 14:46:42 +00:00
Aleksey Kladov
afd64ef4f7
Merge pull request #3562 from FireofGods/display_for_node
Add `std::fmt::Display` as a supertrait for `AstNode`
2020-03-12 15:40:53 +01:00
Emil Lauridsen
98e8ad5e60 Handle diagnostics with multiple primary spans 2020-03-12 15:24:20 +01:00
Emil Lauridsen
637c795b3c Correctly handle multi-line fixes from cargo/clippy 2020-03-12 15:01:53 +01: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
Hannes De Valkeneer
e903fd0d97 feat: add debug code lens
Refs #3539
2020-03-11 22:26:47 +01:00
Fireassember
31eec5e80c implementing Display for enums too. 2020-03-11 22:54:24 +02:00
Edwin Cheng
8f7703b006 Update comment
Co-Authored-By: bjorn3 <bjorn3@users.noreply.github.com>
2020-03-12 02:00:56 +08: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
4a745cc8cf Fix parsing of stement-ish binary expressions
closes #3512
2020-03-11 14:28:18 +01: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
bors[bot]
7b323b45a1
Merge #3555
3555: Introduce completion test utils r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-11 10:10:49 +00:00
Aleksey Kladov
dad8f1e064 Introduce completion test utils 2020-03-11 11:09:57 +01:00
Aleksey Kladov
9b0b59c5d2 Add a test for disabled argument snippets 2020-03-11 10:39:39 +01:00
bors[bot]
bf77850c81
Merge #3542
3542: Renames work on struct field shorthands r=matklad a=m-n

When renaming either a local or a struct field, struct field shorthands are now renamed correctly.

Happy to refactor this if it doesn't fit the design of the code. Thanks for adding the suggestion of where to start on the issue.

I wasn't sure if I should also look at the behavior of renaming when placing the cursor at the field shorthand; the following describes the behavior with this patch:

```rust
#[test]
fn test_rename_field_shorthand_for_unspecified() {
    // when renaming a shorthand, should we have a way to specify
    // between renaming the field and the local?
    //
    // If not is this the correct default?
    test_rename(
        r#"
struct Foo {
    i: i32,
}
 impl Foo {
    fn new(i: i32) -> Self {
        Self { i<|> }
    }
}
"#,
        "j",
        r#"
struct Foo {
    i: i32,
}
 impl Foo {
    fn new(j: i32) -> Self {
        Self { i: j }
    }
}
"#,
    );
}
```
Resolves #3431

Co-authored-by: Matt Niemeir <matt.niemeir@gmail.com>
2020-03-11 09:22:09 +00:00
Matt Niemeir
13ccbb2919 find_usages limited to actual usages again 2020-03-10 22:27:38 -05:00
Edwin Cheng
6ea7c31915 Add extern source 2020-03-11 11:04:02 +08:00
Steffen Lyngbaek
974ed7155a Deduplicate some Inlay definitions
- Remove match conversion for InlayKind since we're using remote
2020-03-10 18:59:49 -07:00
Steffen Lyngbaek
cfb48df149 Address Issues from Github
- Updated naming of config
- Define struct in ra_ide and use remote derive in rust-analyzer/config
- Make inlayConfig type more flexible to support more future types
- Remove constructor only used in tests
2020-03-10 14:36:01 -07:00
Steffen Lyngbaek
e98aff109a Parameter inlay hint separate from variable type inlay? #2876
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
2020-03-10 14:33:45 -07:00
Florian Diebold
adc7b8ea2d Fix completion with a partially unknown type
To test whether the receiver type matches for the impl, we unify the given self
type (in this case `HashSet<{unknown}>`) with the self type of the
impl (`HashSet<?0>`), but if the given self type contains Unknowns, they won't
be unified with the variables in those places. So we got a receiver type that
was different from the expected one, and concluded the impl doesn't match.

The fix is slightly hacky; if after the unification, our variables are still
there, we make them fall back to Unknown. This does make some sense though,
since we don't want to 'leak' the variables.

Fixes #3547.
2020-03-10 21:02:13 +01:00
Aleksey Kladov
14094e4477 Move FeatureFlags 2020-03-10 18:56:15 +01:00
Aleksey Kladov
bf582e77d6 Pull completion options up to the rust-analyzer 2020-03-10 18:47:09 +01:00
Aleksey Kladov
2347c03dcd Introduce CompletionOptions 2020-03-10 18:40:22 +01:00
Edwin Cheng
5a292309c5 Add and fix tests 2020-03-11 01:06:01 +08:00
Edwin Cheng
e00a1e0b79 Setup Env in world 2020-03-11 01:06:01 +08:00
Edwin Cheng
22f064cca7 Add resolve_extern_path in DB 2020-03-11 01:06:01 +08:00
Edwin Cheng
8153a0b3ef Add ExternSourceId and env functions 2020-03-11 01:06:01 +08:00
Edwin Cheng
c1db5d26a0 Add additional_outdirs in config 2020-03-11 01:06:01 +08:00
bors[bot]
6b9d66bbee
Merge #3536
3536: Add get and set for `Env` r=matklad a=edwin0cheng

This PR add three things :

1. Add `get` and `set` in `Env`.
2. Implement fixture meta for `with_single_file`. 
3. Add `env` meta in fixture.

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-03-10 16:46:21 +00:00
Aleksey Kladov
34bc0f4f55
Merge pull request #3506 from slyngbaek/3183
Next steps in assoc item completion #3183
2020-03-10 17:45:57 +01:00
Edwin Cheng
95ba7da1ab Check only one fixture 2020-03-11 00:45:03 +08:00
Edwin Cheng
773f3afd36 Add fixture meta for single file fixture 2020-03-11 00:45:03 +08:00
Aleksey Kladov
59a3ec5f33 ⬆️ fst 2020-03-10 15:03:32 +01:00
Matt Niemeir
ce8121bd65 Renaming a local renames struct field shorthand 2020-03-09 22:14:17 -05:00
Matt Niemeir
a9b6aec8a7 Struct field rename renames field in constructor field shorthand 2020-03-09 22:14:17 -05:00
Steffen Lyngbaek
f67e6a850e Switch to explicit offsets for impl_def
Blacklists are prone to more errors
2020-03-09 13:02:09 -07:00
bors[bot]
530ff9f57f
Merge #3533
3533: Updates insta to 0.15.0 and bumps console to 0.10.0 r=matklad a=kjeremy



Co-authored-by: kjeremy <kjeremy@gmail.com>
2020-03-09 14:38:20 +00:00
kjeremy
d1e9f0af04 Updates insta to 0.15.0 and bumps console to 0.10.0 2020-03-09 10:28:30 -04:00
kjeremy
c981c8b0d0 Fix SelectionRange return type 2020-03-09 10:17:16 -04:00
Aleksey Kladov
34b0409298 Print crate name in profil 2020-03-09 11:55:43 +01:00
bors[bot]
a6133206d1
Merge #3527
3527: Simplify r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-09 10:19:26 +00:00
Aleksey Kladov
100cbc57ce Simplify 2020-03-09 11:19:03 +01:00
Aleksey Kladov
d0d5aa935b Simplify 2020-03-09 11:17:39 +01:00
Aleksey Kladov
254ef1860b Minimize API 2020-03-09 11:16:06 +01:00
Aleksey Kladov
0320ebdd10 Use Index for CrateGraph 2020-03-09 11:11:59 +01:00
bors[bot]
0dbd8ff59b
Merge #3526
3526: Silence "file out of workspace" errors r=matklad a=matklad

We really should fix this limitation of the VFS, but it's some way off
at the moment, so let's just silence the user-visible error for now.

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-09 09:59:02 +00:00
Aleksey Kladov
43bc03faf0 Silence "file out of workspace" errors
We really should fix this limitation of the VFS, but it's some way off
at the moment, so let's just silence the user-visible error for now.
2020-03-09 10:54:14 +01:00
bors[bot]
57c27f9139
Merge #3519
3519: Show mod path on hover r=matklad a=SomeoneToIgnore

Closes #1064

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-03-09 09:33:46 +00:00
Kirill Bulatov
e1aa96f2c5 Less abstract CrateData api 2020-03-09 11:26:46 +02:00
bors[bot]
beb4f49541
Merge #3513
3513: Completion in macros r=matklad a=flodiebold

I experimented a bit with completion in macros. It's kind of working, but there are a lot of rough edges.

 - I'm trying to expand the macro call with the inserted fake token. This requires some hacky additions on the HIR level to be able to do "hypothetical" expansions. There should probably be a nicer API for this, if we want to do it this way. I'm not sure whether it's worth it, because we still can't do a lot if the original macro call didn't expand in nearly the same way. E.g. if we have something like `println!("", x<|>)` the expansions will look the same and everything is fine; but in that case we could maybe have achieved the same result in a simpler way. If we have something like `m!(<|>)` where `m!()` doesn't even expand or expands to something very different, we don't really know what to do anyway.
 - Relatedly, there are a lot of cases where this doesn't work because either the original call or the hypothetical call doesn't expand. E.g. if we have `m!(x.<|>)` the original token tree doesn't parse as an expression; if we have `m!(match x { <|> })` the hypothetical token tree doesn't parse. It would be nice if we could have better error recovery in these cases.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2020-03-09 08:56:58 +00:00
bors[bot]
30062da628
Merge #3516
3516: Handle visibility in more cases in completion r=matklad a=flodiebold

This means we don't show private items when completing paths or method calls.

We might want to show private items if we can edit their definition and provide a "make public" assist, but I feel like we'd need better sorting of completion items for that, so they can be not shown or sorted to the bottom by default. Until then, they're usually more of a distraction to me.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2020-03-09 08:50:19 +00:00
bors[bot]
0363c9495a
Merge #3518
3518: Add parse_to_token_tree r=matklad a=edwin0cheng

This PR introduce a function for parsing `&str` to `tt::TokenTree`:

```rust
// Convert a string to a `TokenTree`
pub fn parse_to_token_tree(text: &str) -> Option<(tt::Subtree, TokenMap)> {
````

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-03-09 08:43:07 +00:00
bors[bot]
7ac99aad28
Merge #3524
3524: Ignore client-specific notifications r=matklad a=matklad

closes #3523



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-09 08:27:31 +00:00
Aleksey Kladov
8aeab8d7b0 Ignore client-specific notifications
closes #3523
2020-03-09 09:26:41 +01:00
Steffen Lyngbaek
9138d39947 Clean up completion matching.
- Add test to ensure nested completions don't happen
2020-03-08 17:50:41 -07:00
Kirill Bulatov
605dc98451 Omit unit struct hints 2020-03-08 23:21:08 +02:00
Kirill Bulatov
5cffef56e2 Consider crate declaration names 2020-03-08 23:00:50 +02:00
Edwin Cheng
e7206467d5 Add parse_to_token_tree 2020-03-09 00:13:04 +08:00
Florian Diebold
05e1c7b197 Handle visibility for assoc item path completion as well 2020-03-08 15:15:46 +01:00
Steffen Lyngbaek
7c439355ce Don't allow nested completions 2020-03-08 03:24:34 -07:00
Florian Diebold
afdf08e964 Move hypothetical expansion to hir_expand 2020-03-08 11:10:48 +01:00
Florian Diebold
d9c77c5453 Handle visibility for path completion (not in all cases yet) 2020-03-08 10:51:40 +01:00
Florian Diebold
734e68da4c Handle visibility in method call completion 2020-03-07 23:03:56 +01:00
Kirill Bulatov
32f5276465 Show mod path in hover tooltip 2020-03-07 23:20:18 +02:00
Florian Diebold
f617455d10 Remove TODOs 2020-03-07 19:58:18 +01:00
Florian Diebold
941a574409 Fix CompletionContext module field (by removing it)
Two uses only needed the crate; one was wrong and should use the module from the
scope instead.
2020-03-07 17:53:22 +01:00
Florian Diebold
020c00e44d Add some sanity checks 2020-03-07 17:47:49 +01:00
Florian Diebold
cbca4effce Fix record pattern completion 2020-03-07 16:53:16 +01:00
Florian Diebold
b719e211cf Fix record literal completion 2020-03-07 16:48:39 +01:00
Florian Diebold
6bea6199b3 Fix range for postfix snippets 2020-03-07 16:44:51 +01:00
Florian Diebold
8cc4210278 Add more tests 2020-03-07 15:48:06 +01:00
Florian Diebold
24e98121d8 Try to complete within macros 2020-03-07 15:48:06 +01:00