Commit graph

735 commits

Author SHA1 Message Date
Matthew Jasper
1895888aec Handle more cases in highlight_name_by_syntax 2020-05-24 15:12:17 +01:00
Matthew Jasper
e2d36cb692 Highlight true and false as literals 2020-05-24 15:12:17 +01:00
Aleksey Kladov
d1ff0145a9 Fix tests 2020-05-24 15:47:05 +02:00
Aleksey Kladov
130318b823
Merge pull request #4548 from bnjjj/fix_4464
add support of feature flag for runnables
2020-05-24 15:34:35 +02:00
Aleksey Kladov
f26b7928e0
Merge pull request #4495 from vsrs/fixture_meta
Test fixtures parsing improvements
2020-05-24 15:32:52 +02:00
Aleksey Kladov
ce7144a93d
Merge pull request #4474 from georgewfraser/color_attrs
Color attribute functions
2020-05-24 15:32:31 +02:00
Benjamin Coenen
27ed376bc4 add support of feature flag for runnables #4464
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-24 13:34:34 +02:00
Benjamin Coenen
48d7c61e26 add support of feature flag for runnables #4464
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-23 20:59:18 +02:00
bors[bot]
88c292b1c2
Merge #4559
4559: Module name on hover shows another newline after it r=matklad a=Arthamys

This changes the display of hover information to add a newline between the module path of the item and the signature of the item, as suggested in #3813 

**Before**

![before_3813](https://user-images.githubusercontent.com/11710698/82609224-5d517d80-9bbc-11ea-9a08-0a1558409c6b.png)

**After**

![after_3813](https://user-images.githubusercontent.com/11710698/82609208-562a6f80-9bbc-11ea-8cb6-4430269c5800.png)

Co-authored-by: Galilée 'Bill' Enguehard <galilee.enguehard@gmail.com>
2020-05-23 11:09:24 +00:00
Galilée 'Bill' Enguehard
d688215f25 Update tests to accept new hover formatting 2020-05-22 20:11:24 +02:00
Galilée 'Bill' Enguehard
910ac5a213 Fix formatting error when no modpath is present 2020-05-22 20:10:37 +02:00
Galilée 'Bill' Enguehard
5043c9ce9c Modify hover info to show module path separated by a line 2020-05-22 19:04:39 +02:00
Aleksey Kladov
2c04aad2d2 KISS SourceChange
The idea behind requiring the label is a noble one, but we are not
really using it consistently anyway, and it should be easy to retrofit
later, should we need it.
2020-05-22 18:04:26 +02:00
Benjamin Coenen
43339058e3 add support of feature flag for runnables #4464
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-22 09:23:31 +02:00
Galilée 'Bill' Enguehard
7fece3bdd2 Merge branch 'master' of github.com:rust-analyzer/rust-analyzer into modname_spacing 2020-05-21 23:27:38 +02:00
Galilée 'Bill' Enguehard
db926218b2 Add extra newline after module path in hover info
Closes issue #3813
2020-05-21 23:26:09 +02:00
Aleksey Kladov
5b5ebec440 Formalize JoinLines protocol extension 2020-05-21 20:05:33 +02:00
Aleksey Kladov
ef0da3bbec Cleanup 2020-05-21 16:11:37 +02:00
Aleksey Kladov
5f57491c98 Cleanup TextEdit 2020-05-21 15:56:18 +02:00
Aleksey Kladov
ff28c79ebd Remove dead code for handling cursor positions 2020-05-21 15:08:03 +02:00
Aleksey Kladov
4b495da368 Transition OnEnter to WorkspaceSnippetEdit
This also changes our handiling of snippet edits on the client side.
`editor.insertSnippet` unfortunately forces indentation, which we
really don't want to have to deal with. So, let's just implement our
manual hacky way of dealing with a simple subset of snippets we
actually use in rust-analyzer
2020-05-21 15:08:03 +02:00
Benjamin Coenen
a7c8aa7c60 add support of feature flag for runnables #4464
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-21 10:53:29 +02:00
Benjamin Coenen
c6143742bd add support of feature flag for runnables #4464
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-21 10:48:42 +02:00
Aleksey Kladov
4fdb1eac08 Remove unused cursor positions 2020-05-21 10:37:11 +02:00
Aleksey Kladov
04a8daaa33 Remove unused cursor positions 2020-05-21 00:46:08 +02:00
vain0x
e18f00882d Add call postfix completion
To make it easier to wrap an expression with Ok/Some/Rc::new etc.
2020-05-20 22:05:37 +09:00
Aleksey Kladov
ecac5d7de2 Switch to new magic marks 2020-05-20 13:02:53 +02:00
Aleksey Kladov
5258c817f7 Remove cross-crate marks
They create quite a bit of friction. Really, we should just move the
tests to the same crate, rather than paper over existing split.
2020-05-20 13:00:50 +02:00
Aleksey Kladov
c847c079fd Add AssistConfig 2020-05-19 20:28:27 +02:00
George Fraser
47ce5ea581 Color attribute functions 2020-05-18 22:55:46 -07:00
Coenen Benjamin
01688f8d4f
Fix doctests in an Impl block 2020-05-17 12:10:35 +02:00
Benjamin Coenen
947f95193a fix doctest inside impl block #4449
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-17 11:16:31 +02:00
Benjamin Coenen
03735be317 fix doctest inside impl block #4449
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-17 00:43:42 +02:00
bors[bot]
ebaa05a447
Merge #4472
4472: Fix path resolution for module and function with same name r=hasali19 a=hasali19

This fixes #3970 and also fixes completion for the same issue.

Co-authored-by: Hasan Ali <git@hasali.co.uk>
2020-05-16 19:49:01 +00:00
vsrs
2c00bd8c6a Propogate fixture meta to AnalysisHost
Except crate name.
2020-05-16 15:23:43 +03:00
vsrs
2dde9b1994 Use FixtureMeta in MockAnalysis 2020-05-16 13:17:21 +03:00
vsrs
256fb7556e Remove temporary FixtureEntry parsed_meta field. 2020-05-16 12:25:26 +03:00
zbsz
d7d8bfc472 Add 'self to parameter' renaming. 2020-05-15 19:05:59 -07:00
Hasan Ali
001a86dc03 Fix completion and hover for module and function of same name 2020-05-16 01:09:04 +01:00
Aleksey Kladov
90c62bcee9 Prioritize locals with correct types 2020-05-14 15:15:52 +02:00
Pavan Kumar Sunkara
9f0a7eb97b Make some stuff public so that they can be reused by other tools 2020-05-14 11:14:46 +02:00
Benjamin Coenen
df33022408 add more specific match postfix for Result and Option
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-12 11:48:58 +02:00
bors[bot]
2c9878a2fc
Merge #4423
4423: add tests module snippet r=bnjjj a=bnjjj

Request from a friend coming from intellij Rust

Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-11 18:15:31 +00:00
bors[bot]
0063ad970d
Merge #4358
4358: add if let and while let postfix for Option and Result #4348 r=matklad a=bnjjj

close #4348 

I also added `while let` for iterator or stream it could be useful 

![iflet](https://user-images.githubusercontent.com/5719034/81278000-676c6b80-9055-11ea-87ad-6b8476dd983f.gif)


Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-11 18:08:26 +00:00
Benjamin Coenen
72e3d2260b add tests module snippet
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-11 19:59:58 +02:00
bors[bot]
848aa56df5
Merge #4397
4397: Textmate cooperation r=matklad a=georgewfraser

This PR tweaks the fallback TextMate scopes to make them more consistent with the existing grammar and other languages, and edits the builtin TextMate grammar to align with semantic coloring. Before is on the left, after is on the right:

<img width="855" alt="Screen Shot 2020-05-10 at 1 45 51 PM" src="https://user-images.githubusercontent.com/1369240/81512320-a8be7e80-92d4-11ea-8940-2c03f6769015.png">

**Use keyword.other for regular keywords instead of keyword**. This is a really peculiar quirk of TextMate conventions, but virtually *all* TextMate grammars use `keyword.other` (colored blue in VSCode Dark+) for regular keywords and `keyword.control` (colored purple in VSCode Dark+) for control keywords. The TextMate scope `keyword` is colored like control keywords, not regular keywords. It may seem strange that the `keyword` scope is not the right fallback for the `keyword` semantic token, but TextMate has a long and weird history. Note how keywords change from purple back to blue (what they were before semantic coloring was added):

**(1) Use punctuation.section.embedded for format specifiers**. This aligns with how Typescript colors formatting directives:

<img width="238" alt="Screen Shot 2020-05-09 at 10 54 01 AM" src="https://user-images.githubusercontent.com/1369240/81481258-93b5f280-91e3-11ea-99c2-c6d258c5bcad.png">

**(2) Consistently use `entity.name.type.*` scopes for type names**. Avoid using `entity.name.*` which gets colored like a keyword.

**(3) Use Property instead of Member for fields**. Property and Member are very similar, but if you look at the TextMate fallback scopes, it's clear that Member is intended for function-like-things (methods?) and Property is intended for variable-like-things.

**(4) Color `for` as a regular keyword when it's part of `impl Trait for Struct`**. 

**(5) Use `variable.other.constant` for constants instead of `entity.name.constant`**. In the latest VSCode insiders, variable.other.constant has a subtly different color that differentiates constants from ordinary variables. It looks close to the green of types but it's not the same---it's a new color recently added to take advantage of semantic coloring.

I also made some minor changes that make the TextMate scopes better match the semantic scopes. The effect of this for the user is you observe less of a change when semantic coloring "activates". You can see the changes I made relative to the built-in TextMate grammar here:

a91d15c80c..97428b6d52 (diff-6966c729b862f79f79bf7258eb3e0885)


Co-authored-by: George Fraser <george@fivetran.com>
2020-05-11 17:33:38 +00:00
Benjamin Coenen
4e54b1ca46 add tests module snippet
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-11 18:11:23 +02:00
bors[bot]
05399250d4
Merge #4421
4421: Find references to a function outside module r=flodiebold a=montekki

Fixes #4188 

Yet again, it looks like although the code in 
da1f316b02/crates/ra_ide_db/src/search.rs (L128-L132)

may be wrong, it is not hit since the `vis` is `None` at this point. The fix is similar to the #4237 case: just add another special case to `Definition::visibility()`.

Co-authored-by: Fedor Sakharov <fedor.sakharov@gmail.com>
2020-05-11 12:21:08 +00:00
Fedor Sakharov
762ec9581a
Find references to a function outside module 2020-05-11 12:25:18 +03:00
George Fraser
63b75a40c8 Color for as a regular keyword when it's part of impl _ for _ 2020-05-10 13:11:14 -07:00
George Fraser
3f1c73633e Color in as a control keyword 2020-05-10 13:07:28 -07:00
bors[bot]
74e72e9afa
Merge #4394 #4414
4394: Simplify r=matklad a=Veetaha



4414: Highlighting improvements r=matklad a=matthewjasper

- `static mut`s are highlighted as `mutable`.
- The name of the macro declared by `macro_rules!` is now highlighted.

Co-authored-by: veetaha <veetaha2@gmail.com>
Co-authored-by: Matthew Jasper <mjjasper1@gmail.com>
2020-05-10 17:47:27 +00:00
Aleksey Kladov
1586bab0b9 Simplify proto conversion
Trait based infra in conv.rs is significantly more complicated than
what we actually need here.
2020-05-10 19:01:26 +02:00
Matthew Jasper
22b75c4cea Highlight the name in macro declarations 2020-05-10 16:25:51 +01:00
Matthew Jasper
11c0a5bb60 Highlight mutable statics as mutable 2020-05-10 16:25:51 +01:00
Benjamin Coenen
92b2230fef add if let and while let postfix for Option and Result
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-10 12:45:35 +02:00
Benjamin Coenen
e80903a965 Merge branch 'master' of github.com:rust-analyzer/rust-analyzer into feat_4348 2020-05-10 12:31:55 +02:00
Edwin Cheng
a3375c1a88 Remove dbg 2020-05-10 18:03:44 +08:00
Edwin Cheng
9405116d51 Hot fix panic for function_signature 2020-05-10 16:27:31 +08:00
bors[bot]
fd84c31ff7
Merge #4346
4346: Fix rename of enum variant visible from module r=matklad a=montekki

Probably fixes #4237 

It looks like the ref is found correctly in this case but it's visibility is not correctly determined. I took a stab at fixing that by adding an implementation of `HasVisibility` for `EnumVariant` so it works more or less the same way it does for struct fields.

In other words, the `search_range` here does not contain the ref since it's not considered visible:

efd8e34c39/crates/ra_ide_db/src/search.rs (L209-L214)


Before that I tried to populate `ItemScope` with visible enum variants but that ended up with breaking tests all over the place and also it looked illogical in the end: `ItemScope` is not populated with, say, public struct fields and the same should be true for `enum` variants.

I've added two more or less identical tests: one for the case with a struct field rename and one for enum variant rename; the test for struct should probably be removed and the names should be changed.


Co-authored-by: Fedor Sakharov <fedor.sakharov@gmail.com>
2020-05-07 16:29:01 +00:00
Aleksey Kladov
28fcff125a Nicer API 2020-05-07 17:29:23 +02:00
Aleksey Kladov
c6b81bc013 Rename AssitLabel -> Assist 2020-05-07 17:18:28 +02:00
Aleksey Kladov
43cedecf68 Fix panic in FunctionSignature 2020-05-07 14:29:01 +02:00
Benjamin Coenen
6203e9c4fa add if let and while let postfix for Option and Result #4348
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-07 11:23:38 +02:00
bors[bot]
1a0988b899
Merge #4316 #4351
4316: do not truncate display for hover r=matklad a=bnjjj

close #4311 

4351: Fix Windows server path r=matklad a=lnicola

CC @Coder-256.

Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
2020-05-06 16:54:31 +00:00
Fedor Sakharov
bd9f1f7eb7
Fix rename of enum variant visible from module 2020-05-06 17:35:22 +03:00
Aleksey Kladov
4d50709a96 Minor 2020-05-06 16:10:35 +02:00
Aleksey Kladov
0970c3454b Rename 2020-05-06 16:10:35 +02:00
Aleksey Kladov
fdd4df97ba Use SourceChange for assists 2020-05-06 15:43:47 +02:00
Benjamin Coenen
1ec953f117 do not truncate display for hover
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-06 11:33:43 +02:00
Aleksey Kladov
3850b1c086 Lift SourceChange to the ra_ide_db 2020-05-06 11:32:34 +02:00
Aleksey Kladov
beb35c3ecb Fix capitalization 2020-05-06 11:19:43 +02:00
Benjamin Coenen
550c629498 do not truncate display for hover
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-06 11:08:50 +02:00
Benjamin Coenen
c4d128e454 Merge branch 'master' of github.com:rust-analyzer/rust-analyzer into fix_4311 2020-05-06 09:57:00 +02:00
Aleksey Kladov
ca9e0f5fe9 Fixup tests 2020-05-05 23:48:26 +02:00
Aleksey Kladov
27c7ef6d65 Use more natural signature for Edit::apply 2020-05-05 23:23:29 +02:00
Aleksey Kladov
4a6fa8f0df Rename AtomTextEdit -> Indel 2020-05-05 23:15:49 +02:00
Aleksey Kladov
3908fad1fe Normalize naming of diagnostics 2020-05-05 21:35:30 +02:00
Aleksey Kladov
df00da15c4 Fix compilation 2020-05-05 20:45:44 +02:00
bors[bot]
f0411ff9e0
Merge #4320
4320: add doctest support r=matklad a=bnjjj

close #4317

preview:

<img width="253" alt="Capture d’écran 2020-05-05 à 17 39 58" src="https://user-images.githubusercontent.com/5719034/81086040-45110b80-8ef8-11ea-9c05-79c6fe400fc3.png">


Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-05 16:22:31 +00:00
Edwin Cheng
92665358cd Rename ImplItem to AssocItem 2020-05-05 23:56:10 +08:00
Benjamin Coenen
fe52f8f028 add doctest support #4317
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-05 17:44:27 +02:00
Benjamin Coenen
0bf02f5cca do not truncate display for hover #4311
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-05 14:29:25 +02:00
Aleksey Kladov
b211c5814e Remove false positive attr compleitons 2020-05-04 16:48:50 +02:00
Aleksey Kladov
8f4478390e Qualify ast types 2020-05-04 15:33:08 +02:00
Aleksey Kladov
e9643ab74c Cleanup imports 2020-05-04 15:33:08 +02:00
Aleksey Kladov
71f6d58e31 Remove unnecessary condition
No tests fail, and quick manual testing shows that there are no
false-positives. In general, each completion contributor should be
independent from the others.
2020-05-04 15:32:23 +02:00
bors[bot]
b1a5dc8c8b
Merge #4269 #4293
4269: add support of use alias semantic in definition r=matklad a=bnjjj

close #4202 

4293: no doctests for flycheck r=matklad a=matklad



bors r+
🤖

Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-05-04 10:34:06 +00:00
Aleksey Kladov
710e430dbb Fix focus range for TypeParam
closes #4274
2020-05-04 12:25:32 +02:00
Aleksey Kladov
13bce1a164 Add test marks 2020-05-04 12:10:26 +02:00
Kirill Bulatov
30817de3af Code review fixes
Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-05-04 11:04:02 +03:00
Kirill Bulatov
66882f1a24 Move snake case method to heck 2020-05-03 21:35:21 +03:00
Kirill Bulatov
ba8ffab644 Omit name hints for enum names similar to parameter names 2020-05-03 15:55:08 +03:00
Kirill Bulatov
8eb820f460 Omit name hints for method names similar to parameter names 2020-05-03 15:55:08 +03:00
Kirill Bulatov
2fd054f276 Fix derive argument parsing 2020-05-02 23:47:51 +03:00
Benjamin Coenen
99c2ca8494 add support of use alias semantic in definition #4202
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-02 21:42:27 +02:00
Kirill Bulatov
9f0ed7ed92 Separate macros completion from other 2020-05-02 22:33:23 +03:00
Kirill Bulatov
fee74851b0 Propose custom derives in completion 2020-05-02 22:24:27 +03:00
Kirill Bulatov
767bff89ed Complete standard derives 2020-05-02 21:41:02 +03:00
Benjamin Coenen
4613497a77 Merge branch 'master' of github.com:rust-analyzer/rust-analyzer into fix_4202 2020-05-02 20:27:02 +02:00