Commit Graph

829 Commits

Author SHA1 Message Date
Aleksey Kladov
84cd28fddc Cut problematic dependency 2020-06-23 18:56:26 +02:00
Aleksey Kladov
fdf86aee18 Nicer API 2020-06-23 18:46:56 +02:00
Aleksey Kladov
21f751a0e5 Simplify 2020-06-23 18:37:26 +02:00
Aleksey Kladov
30748161f0 Simplify 2020-06-23 18:37:26 +02:00
Aleksey Kladov
dad1333b48 New VFS 2020-06-23 17:51:06 +02:00
bors[bot]
3e09dbba94
Merge #5002
5002: Fix underflow panic when doctests are at top of file r=Nashenas88 a=Nashenas88

While debugging a comment at the top of a test string, I discovered that the offset calculations could underflow and panic. This only seemed to occur in tests, I assume because it's running a debug mode. The wrapping is quickly fixed later on in release mode, which is why this seems to have gone unnoticed. The new checks ensure the value is always positive or zero.

Co-authored-by: Paul Daniel Faria <nashenas88@users.noreply.github.com>
2020-06-23 13:25:43 +00:00
bors[bot]
338b229b79
Merge #4999
4999: SSR: Allow matching of whole macro calls r=matklad a=davidlattimore

Matching within macro calls is to come later and matching of macro calls within macro calls later still.

Co-authored-by: David Lattimore <dml@google.com>
2020-06-23 10:02:59 +00:00
Paul Daniel Faria
0b971625c3 Fix underflow panic when doctests are at top of file 2020-06-22 22:29:08 -04:00
bors[bot]
98c3e4e887
Merge #5000
5000: Remove RelativePathBuf from fixture r=matklad a=matklad

The paths in fixture are not really relative (the default one is
`/main.rs`), so it doesn't make sense to use `RelativePathBuf` here.



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-22 22:15:22 +00:00
Aleksey Kladov
6a6098d4c3 Remove RelativePathBuf from fixture
The paths in fixture are not really relative (the default one is
`/main.rs`), so it doesn't make sense to use `RelativePathBuf` here.
2020-06-23 00:14:44 +02:00
David Lattimore
467af611fb SSR: Allow matching of whole macro calls
Matching within macro calls is to come later and matching of macro calls within macro calls later still.
2020-06-23 07:42:34 +10:00
bors[bot]
eabbeec14c
Merge #4988
4988: Don't offer to add missing fields of unknown types r=flodiebold a=lnicola



Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-06-22 15:47:22 +00:00
Laurențiu Nicola
acc2819c10 Don't offer to add missing fields of unknown types 2020-06-22 18:16:00 +03:00
bors[bot]
87615166af
Merge #4900
4900: Self variant enum res fix r=BGluth a=BGluth

Fixes #4789.

This is my first PR for this project, so it's probably worth giving it an extra close look.

A few things that I wasn't sure about:
- Is `resolve_path` really the best place to perform this check? It seemed like a natural place, but perhaps there's a better place?
- When handling the new variant `PathResolution::VariantDef`, I couldn't see an obvious variant of `TypeNs` to return in `in_type_ns` for Unions and Structs.

Co-authored-by: BGluth <gluthb@gmail.com>
2020-06-22 14:37:45 +00:00
bors[bot]
d8842e89e9
Merge #4899
4899: don't complete top level attrs inside nested attrs and add better labels r=matklad a=bnjjj

close #4890

Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-06-22 12:13:18 +00:00
bors[bot]
d144d69d2e
Merge #4921
4921: Allow SSR to match type references, items, paths and patterns r=davidlattimore a=davidlattimore

Part of #3186

Co-authored-by: David Lattimore <dml@google.com>
2020-06-22 11:50:34 +00:00
David Lattimore
662ab2ecc8 Allow SSR to match type references, items, paths and patterns
Part of #3186
2020-06-22 21:42:55 +10:00
Benjamin Coenen
5aad6c9fa6 don't complete top level attrs inside nested attrs and add better labels #4899
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-06-22 13:39:05 +02:00
bors[bot]
19701b39ac
Merge #4928
4928: Fix renaming mod in use tree r=matklad a=unexge

Fixes #4825

Co-authored-by: unexge <unexge@gmail.com>
2020-06-22 11:19:09 +00:00
BGluth
3a3b40a554 Created goto Self enum variant test 2020-06-21 13:27:16 -06:00
Benjamin Coenen
3df879f139 don't complete top level attrs inside nested attrs and add better labels #4899
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-06-21 19:14:08 +02:00
Leander Tentrup
df5b37cb61 Syntax highlighting for documentation comments on macro definitions 2020-06-20 00:02:42 +02:00
bors[bot]
90a5c4626a
Merge #4851
4851: Add quickfix to add a struct field r=TimoFreiberg a=TimoFreiberg

Related to #4563 
I created a quickfix for record literals first because the NoSuchField diagnostic was already there.
To offer that quickfix for FieldExprs with unknown fields I'd need to add a new diagnostic (or create a `NoSuchField` diagnostic for those cases)

I think it'd make sense to make this a snippet completion (to select the generated type), but this would require changing the `Analysis` API and I'd like some feedback before I touch that.

Co-authored-by: Timo Freiberg <timo.freiberg@gmail.com>
2020-06-19 15:08:52 +00:00
bors[bot]
4575c38810
Merge #4839
4839: `Go to Type Definition` hover action. r=matklad a=vsrs

![hover_actions_goto](https://user-images.githubusercontent.com/62505555/83335671-0122e380-a2b7-11ea-9922-fbdcfb11a7f3.gif)

This implementation supports things like `dyn Trait<SomeType>`, `-> impl Trait`, etc.

Co-authored-by: vsrs <vit@conrlab.com>
2020-06-19 13:34:24 +00:00
Benjamin Coenen
3f26c5758d don't complete top level attrs inside nested attrs and add better labels #4890
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-06-18 21:31:49 +02:00
bors[bot]
f7f627d342
Merge #4903
4903: Add highlighting support for doc comments r=matklad a=Nashenas88

The language server protocol includes a semantic modifier for documentation. This change exports that modifier for doc comments so users can choose to highlight them differently compared to regular comments.

Example:
<img width="375" alt="Screen Shot 2020-06-16 at 10 34 14 AM" src="https://user-images.githubusercontent.com/1673130/84788271-f6599580-afbc-11ea-96e5-7a0215da620b.png">

CC @woody77 

Co-authored-by: Paul Daniel Faria <Nashenas88@users.noreply.github.com>
2020-06-18 13:23:14 +00:00
Paul Daniel Faria
66fc084a86 Remove logic to mark all doctest code as 2020-06-18 09:14:02 -04:00
bors[bot]
13adfedf82
Merge #4821
4821: display Doctest code lens before comment r=matklad a=bnjjj

close #4785

Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-06-18 10:34:21 +00:00
Benjamin Coenen
2732fdb595 display Doctest code lens before comment #4785
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-06-18 11:31:15 +02:00
vsrs
022fbefffa Apply suggestions from code review 2020-06-18 10:15:43 +03:00
vsrs
4b07c1e775 Add Type::walk method 2020-06-18 10:15:43 +03:00
vsrs
7ec0064409 Remove AdtOrTrait 2020-06-18 10:15:43 +03:00
vsrs
d4e75312ba Add associated type test. 2020-06-18 10:15:43 +03:00
vsrs
283ec13fc0 Fix type "items" order. 2020-06-18 10:15:43 +03:00
vsrs
c50157f330 Add Go to Type Definition hover action. 2020-06-18 10:15:43 +03:00
Aleksey Kladov
d1d0b5a88c Remove special casing for library symbols
We might as well handle them internally, via queries.

I am not sure, but it looks like the current LibraryData setup might
even predate salsa? It's not really needed and creates a bunch of
complexity.
2020-06-18 08:29:34 +02:00
unexge
ce29d172a5 Fix renaming mod in use tree 2020-06-17 20:16:04 +03:00
Paul Daniel Faria
a951108173 Ensure all existing doctest code highlights have documentation modifier 2020-06-17 09:33:21 -04:00
Leander Tentrup
2145e2d878 Syntax highlighting for escape sequences in strings 2020-06-17 15:27:13 +02:00
Paul Daniel Faria
aae26bc5b8 Add highlighting support for doc comments 2020-06-17 08:29:13 -04:00
bors[bot]
931f317399
Merge #4913 #4915 #4916
4913: Remove debugging code for incremental sync r=matklad a=lnicola



4915: Inspect markdown code fences to determine whether to apply syntax highlighting r=matklad a=ltentrup

Fixes #4904 

4916: Warnings as hint or info r=matklad a=GabbeV

Fixes #4229 

This PR is my second attempt at providing a solution to the above issue. My last PR(#4721) had to be rolled back(#4862) due to it overriding behavior many users expected. This PR solves a broader problem while trying to minimize surprises for the users. 

### Problem description
The underlying problem this PR tries to solve is the mismatch between [Rustc lint levels](https://doc.rust-lang.org/rustc/lints/levels.html) and [LSP diagnostic severity](https://microsoft.github.io/language-server-protocol/specification#diagnostic). Rustc currently doesn't have a lint level less severe than warning forcing the user to disable warnings if they think they get to noisy. LSP however provides two severitys below warning, information and hint. This allows editors like VSCode to provide more fine grained control over how prominently to show different diagnostics.

Info severity shows a blue squiggly underline in code and can be filtered separately from errors and warnings in the problems panel.
![image](https://user-images.githubusercontent.com/13839236/84830640-0bb8d900-b02a-11ea-9e2f-0561b0e8f1ef.png)
![image](https://user-images.githubusercontent.com/13839236/84826931-ffca1880-b023-11ea-8080-5e5b91a6ac0d.png)

Hint severity doesn't show up in the problems panel at all and only show three dots under the affected code or just faded text if the diagnostic also has the unnecessary tag.
![image](https://user-images.githubusercontent.com/13839236/84827165-55062a00-b024-11ea-8bd6-bdbf1217c4c5.png)

### Solution
The solution provided by this PR allows the user to configure lists of of warnings to report as info severity and hint severity respectively. I purposefully only convert warnings and not errors as i believe it's a good idea to have the editor show the same severity as the compiler as much as possible.
![image](https://user-images.githubusercontent.com/13839236/84829609-50437500-b028-11ea-80a8-1bbd05680ba7.png)

### Open questions
#### Discoverability
How do we teach this to new and existing users? Should a section be added to the user manual? If so  where and what should it say?

#### Defaults
Other languages such as TypeScript report unused code as hint by default. Should rust-analyzer similarly report some problems as hint/info by default?

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
Co-authored-by: Leander Tentrup <leander.tentrup@gmail.com>
Co-authored-by: Gabriel Valfridsson <gabriel.valfridsson@gmail.com>
2020-06-17 11:01:37 +00:00
David Lattimore
ac9166a7af Remove :expr from placeholders
Reasoning discussed at #3186
2020-06-17 18:28:24 +10:00
Leander Tentrup
8ff91cf6b6 Inspect markdown code fences to determine whether to apply syntax highlighting 2020-06-16 23:03:59 +02:00
Aleksey Kladov
3c72fc0573 Anchor file-system operations to the file, and not to the source root.
Anchoring to the SourceRoot wont' work if the path is absolute:

  #[path = "/tmp/foo.rs"]
  mod foo;

Anchoring to a file will.

However, we *should* anchor, instead of just producing an abs path.

I can imagine a situation where, for example, rust-analyzer processes
crates from different machines (or, for example, from in-memory git
branch), where the same absolute path in different crates might refer
to different files in the end!
2020-06-16 18:45:58 +02:00
Benjamin Coenen
9aad07dbea don't complete top level attrs inside nested attrs and add better labels #4890
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-06-15 23:11:08 +02:00
Leander Tentrup
c4b3db0c2f Syntactic highlighting of NAME_REF for injections
This commit adds a function that tries to determine the syntax highlighting class of NAME_REFs based on the usage.
It is used for highlighting injections (such as highlighting of doctests) as the semantic logic will most of the time result in unresolved references.
It also adds a color to unresolved references in HTML encoding.
2020-06-15 22:13:53 +02:00
bors[bot]
5b013e5665
Merge #4877
4877: Fix syntax highlighting of recursive macros r=matklad a=ltentrup

Add syntax highlighting for the BANG (`!`) token if the parent is `MACRO_CALL`.

Before:
<img width="514" alt="before" src="https://user-images.githubusercontent.com/201808/84595030-11f65c00-ae56-11ea-9bb2-b1abe2236990.png">

After:
<img width="516" alt="recursive-macro" src="https://user-images.githubusercontent.com/201808/84594981-d196de00-ae55-11ea-8636-f877d5d795ff.png">


Fixes #4694.

Co-authored-by: Leander Tentrup <leander.tentrup@gmail.com>
2020-06-15 13:44:46 +00:00
Leander Tentrup
06f89e5f3a Fix syntax highlighting of recursive macros
Add syntax highlighting for the BANG (`!`) token if the parent is `MACRO_CALL`.
2020-06-15 15:03:13 +02:00
Aleksey Kladov
52a220cece Deprecate hir::Path::from_ast 2020-06-15 10:55:48 +02:00
Benjamin Coenen
36d9105d0e display Doctest code lens before comment #4785
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-06-14 21:50:24 +02:00