Commit Graph

1886 Commits

Author SHA1 Message Date
Aleksey Kladov
9923383d53 add graph fixture 2019-02-11 13:47:17 +03:00
Aleksey Kladov
dced2f4ed4 Handle SourceRoots automatically in fixtures 2019-02-11 12:53:10 +03:00
Ville Penttinen
710975ecd8 Fix typo in Cargo.toml authors
Fixes typo introduced in #782
2019-02-11 10:20:04 +02:00
Ville Penttinen
ab3d231b1d Update authors field in Cargo.tomls to "rust-analyzer developers"
This closes #777
2019-02-11 08:55:35 +02:00
bors[bot]
ffd407afff Merge #778
778: Glob imports r=matklad a=flodiebold

This implements glob imports, completing #231 :)

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2019-02-10 20:15:41 +00:00
bors[bot]
b952c270ee Merge #762
762: "Dumb" auto import assist r=matklad a=eulerdisk

This adds a new assist to "add xxx::yyy to the current file" when the cursor is on a PATH. It manages correctly nested imports,`self` keyword and creates new nested imports if necessary. [See the tests]
It doesn't use name resolution so in that sense is 'dumb', but I have plans to do that. That in the future will be useful to auto import trait names in autocompletion for example.

It can easily be extended to provide multiple actions to select in which scope to import. That's another thing I plan to do.

@matklad I copied some indentation code from `ide_light`, I don't know at the moment if/how you want to refactor that code. This assist was meant to be in `ide_light`.

Co-authored-by: Andrea Pretto <eulerdisk@gmail.com>
2019-02-10 19:00:36 +00:00
Florian Diebold
2f24e740db Implement glob imports within the same crate
Fixes #231.
2019-02-10 16:48:29 +01:00
Florian Diebold
2e1d739a80 Import glob imports from other crates
This is the easy part since we don't have to consider the fixpoint algorithm.
2019-02-10 16:20:01 +01:00
Florian Diebold
c1e295682e Implement glob imports from enums 2019-02-10 16:20:01 +01:00
Florian Diebold
35cfb418ba Add some tests 2019-02-10 16:20:01 +01:00
Florian Diebold
2e9194a621 Spell cases explicitly in Ty::walk{_mut} 2019-02-10 12:35:30 +01:00
Florian Diebold
b18863f987 Clean up a bit 2019-02-10 11:48:59 +01:00
Florian Diebold
6f81a372db Add a smoke test for ra_batch 2019-02-10 11:44:53 +01:00
Florian Diebold
6964a88e8c Add an ra_cli command that analyses all crates in the current workspace
... and prints various stats about how many expressions have a type etc.
2019-02-10 10:56:58 +01:00
Florian Diebold
43e52ac9e2 Implement BatchDatabase construction 2019-02-10 10:56:58 +01:00
Florian Diebold
15224dfcd5 Add new crate 2019-02-10 10:56:58 +01:00
bors[bot]
166c720425 Merge #770
770: Fix introduce var duplicating newlines r=matklad a=vipentti

This fixes #713.

If the block before the statement we want to use introduce var on, had empty
lines these empty lines would also be added between the let-statement and
the current line where the new variable is used.

This fixes that by trimming excess newlines from the start of the indent chunk
and simply adding a single newline (when the chunk had newlines) between the
let-statement and the current statement. If there were no newlines this
matches the previous behaviour.

Co-authored-by: Ville Penttinen <villem.penttinen@gmail.com>
2019-02-10 08:16:08 +00:00
Florian Diebold
c098a3fda5 Add comment and mark 2019-02-09 22:03:01 +01:00
Florian Diebold
a28d4befaf Fix another crash, and try harder to prevent stack overflows 2019-02-09 21:53:55 +01:00
Florian Diebold
c0c3b37255 Fix another crash found when analyzing rustc 2019-02-09 21:37:30 +01:00
Florian Diebold
f1afc93353 Fix handling of literal patterns
Wrap them in a LiteralPat node so they can be distinguished from literal
expressions.
2019-02-09 21:37:30 +01:00
Florian Diebold
7ebde241c0 Fix two crashes found by running inference on all of rustc 2019-02-09 21:37:09 +01:00
Bernardo
c3c2e166b0 update notify with fix for hight cpu usage 2019-02-09 17:18:26 +01:00
Ville Penttinen
7b9aefc29d Fix introduce var duplicating newlines
This fixes #713.

If the block before the statement we want to use introduce var on, had empty
lines these empty lines would also be added between the let-statement and
the current line where the new variable is used.

This fixes that by trimming excess newlines from the start of the indent chunk
and simply adding a single newline (when the chunk had newlines) between the
let-statement and the current statement. If there were no newlines this
matches the previous behaviour.
2019-02-09 13:52:01 +02:00
Andrea Pretto
1a4faaffd7 auto_import: use ra_fmt 2019-02-09 11:47:23 +01:00
Andrea Pretto
ee9b0c89e6 auto_import: struct variants for ImportAction 2019-02-09 11:30:09 +01:00
Andrea Pretto
1866fb2dda auto_import: remove PathSegmentsMatch 2019-02-09 11:30:09 +01:00
Andrea Pretto
6d8832359e auto_import: Removed Empty in favor of Partial(0)
auto_import: Removed unecessary lifetimes
2019-02-09 11:30:09 +01:00
Andrea Pretto
5580cf239d auto_import assist 2019-02-09 11:29:59 +01:00
Florian Diebold
e91a46eb0c Clean up a bit 2019-02-09 11:15:25 +01:00
Florian Diebold
50fd860471 Remove Vfs from project model 2019-02-09 11:15:25 +01:00
Florian Diebold
12c70871cc Remove SmolStr from project model 2019-02-09 11:15:25 +01:00
Florian Diebold
ddbf43b630 Move crate graph generation to ra_project_model 2019-02-09 11:15:25 +01:00
Florian Diebold
fcd615e4b7 Extract project model to separate crate 2019-02-09 11:15:25 +01:00
bors[bot]
34398a8756 Merge #766
766: Formatting code into ra_fmt r=matklad a=eulerdisk

As discussed https://github.com/rust-analyzer/rust-analyzer/pull/762#discussion_r254905885

I did only move the code without other improvements.

Co-authored-by: Andrea Pretto <eulerdisk@gmail.com>
2019-02-09 09:56:54 +00:00
robojumper
4fdeb54bb5 Improve sorting delegate 2019-02-09 01:57:08 +01:00
robojumper
a70589712a Remove unused import 2019-02-09 00:54:07 +01:00
robojumper
3be98f2ac9 Add tests for action target ranges 2019-02-09 00:34:26 +01:00
robojumper
a3622eb629 Add some assist ranges 2019-02-08 22:43:13 +01:00
Andrea Pretto
02dd0cfd8c Refactor formatting code out of ra_ida_api_light into ra_fmt. 2019-02-08 18:58:27 +01:00
Aleksey Kladov
12e3b4c70b reformat the world 2019-02-08 14:49:43 +03:00
Aleksey Kladov
884f04670a diagnostics is now a function 2019-02-08 14:34:30 +03:00
Aleksey Kladov
8328e196dd move diagnostics to a separate file 2019-02-08 14:34:30 +03:00
Aleksey Kladov
e4a6343e47 move index_resolve to symbol index 2019-02-08 14:34:30 +03:00
Aleksey Kladov
5173c6295b move find_references to references 2019-02-08 14:34:30 +03:00
Aleksey Kladov
f5bb704568 avoid 'ignored' in test output 2019-02-08 14:34:30 +03:00
Aleksey Kladov
4d0e58afef rename rename to references 2019-02-08 14:34:30 +03:00
Aleksey Kladov
bddd124298 move crate for 2019-02-08 14:34:30 +03:00
Aleksey Kladov
842e8001b2 move changes to a separate file 2019-02-08 14:34:30 +03:00
Ville Penttinen
be7c5eecc4 Remove unnecessary dbg! calls 2019-02-07 20:42:00 +02:00
Ville Penttinen
6cbf83c946 Add new assist to remove dbg!() calls
This fixes #758.

Currently we try to maintain the cursor position relative to the statement under
cursor, if the cursor is inside the dbg! macro call.

Meaning:

let foo = dbg!(some.complex<|>().expression());

Should turn into:

let foo = some.complex<|>().expression();

With the cursor staying in place.
2019-02-07 20:34:33 +02:00
kjeremy
6753051a45 Some clippy cleanups 2019-02-06 15:50:26 -05:00
kjeremy
bcbee10b89 assists: compute edit 2019-02-06 11:15:18 -05:00
Aleksey Kladov
0c5fd8f7cb move assists to a separate crate 2019-02-06 17:00:00 +03:00
Jeremy Kolb
d107926f86 Remove stray dbg! 2019-02-06 07:22:16 -05:00
kjeremy
852b083794 Fill deprecation for LSP 2019-02-05 17:05:46 -05:00
Jeremy Kolb
e696342afa Rename assits to assists 2019-02-05 08:13:16 -05:00
bors[bot]
4183825475 Merge #740
740: Update dependencies r=kjeremy a=kjeremy



Co-authored-by: kjeremy <kjeremy@gmail.com>
Co-authored-by: Jeremy Kolb <kjeremy@gmail.com>
2019-02-05 12:16:25 +00:00
Jeremy Kolb
c73cc0ab8f Remove unused imports 2019-02-05 07:15:15 -05:00
bors[bot]
4d4c46aff8 Merge #742
742: Extern crate r=matklad a=flodiebold

This implements `extern crate` declarations by lowering them to (absolute) imports, and adds support for absolute paths. It also extracts the extern prelude from the per-module item map, and handles the special case of extern crates in the crate root adding to the extern prelude.

This means we finally resolve `Arc`, so it fixes #523 😄 

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2019-02-05 07:53:08 +00:00
bors[bot]
94d5d0d7e8 Merge #743
743: Move comment r=matklad a=kjeremy

As pointed out in https://github.com/rust-analyzer/rust-analyzer/pull/738/files#r253651450

Co-authored-by: kjeremy <kjeremy@gmail.com>
2019-02-05 07:36:51 +00:00
bors[bot]
d914ac0069 Merge #744
744: mbe: Ensure repetition separator matches r=matklad a=jrmuizel



Co-authored-by: Jeff Muizelaar <jrmuizel@gmail.com>
2019-02-05 07:28:31 +00:00
Jeff Muizelaar
a4b473226b mbe: Ensure repetition separator matches 2019-02-04 20:19:23 -05:00
Florian Diebold
de4c5e381f Fix ReachedFixedPoint value for unresolved external prelude items 2019-02-04 23:26:25 +01:00
kjeremy
7f92fd858a Move comment 2019-02-04 16:34:02 -05:00
Florian Diebold
699ce06ac3 Complete extern prelude (again) 2019-02-04 22:09:56 +01:00
Florian Diebold
ccef48b6c3 Make it possible to have multiple crate in a mock analysis fixture 2019-02-04 21:49:34 +01:00
Florian Diebold
0c2fedc2cb Add alloc to std deps 2019-02-04 21:49:34 +01:00
Florian Diebold
1056b480d6 Make extern crates in the root module add to the extern prelude
To accomplish this, separate the extern prelude from the per-module item maps.
2019-02-04 21:49:34 +01:00
Florian Diebold
d69023fc72 Lower extern crates to imports
This is probably not completely correct, but it kind of works.
2019-02-04 21:49:34 +01:00
Florian Diebold
397d84ee29 Add test for extern crate renames 2019-02-04 21:49:34 +01:00
Florian Diebold
e163c908ac Add AST for extern crate
Also change it to parse the crate name as a NAME_REF, not a NAME.
2019-02-04 21:49:34 +01:00
bors[bot]
77a824c6a0 Merge #741
741: Test more Self inference r=flodiebold a=kjeremy

These cases didn't look covered.

Co-authored-by: kjeremy <kjeremy@gmail.com>
2019-02-04 20:28:09 +00:00
kjeremy
5227102c12 Test more Self inference 2019-02-04 14:44:06 -05:00
kjeremy
8ec4b84013 Bump insta and proptest to latest 2019-02-04 14:11:51 -05:00
kjeremy
20e9aa2364 Future proof by explicitly matching against None 2019-02-04 12:49:29 -05:00
kjeremy
0f7a714c63 Add comment 2019-02-04 10:26:43 -05:00
Jeremy Kolb
6ac4cca6c1 Implement lens for impls and support resolving lenses. 2019-02-04 08:45:33 -05:00
Jeff Muizelaar
0000f00787 mbe: Add support matching for matching idents 2019-02-03 19:43:37 -05:00
Jeff Muizelaar
1997797adc Factor out rules parsing 2019-02-03 19:43:35 -05:00
Aleksey Kladov
dbf9820e35 make HirDatabase object-safe 2019-02-03 22:15:31 +03:00
bors[bot]
395965351d Merge #733
733: fill match arms r=matklad a=gfreezy

fixed #626 

Co-authored-by: gfreezy <gfreezy@gmail.com>
2019-02-03 18:11:06 +00:00
gfreezy
bfaefed3f6 fill match arm 2019-02-04 00:27:36 +08:00
Laurențiu Nicola
cbc2ac5d09
Add core to STD_DEPS
See #731.
2019-02-03 17:35:42 +02:00
Jeff Muizelaar
dbc3074556 Make sure we match the entire pattern 2019-02-03 10:07:57 -05:00
bors[bot]
f370393bba Merge #728
728: add postfix completion for `dbg!()` with `.dbg` r=matklad a=hdhoang

closes #716 

Co-authored-by: Hoàng Đức Hiếu <code@hdhoang.space>
2019-02-03 13:26:37 +00:00
Hoàng Đức Hiếu
9dd7ccf609 fold complete_postfix tests into one 2019-02-03 20:12:57 +07:00
bors[bot]
02bacf70fa Merge #727
727: Fix macro_rules separator parsing. r=matklad a=jrmuizel

macro_rules rules are separated by ';' including an optional ';' at the end

Co-authored-by: Jeff Muizelaar <jrmuizel@gmail.com>
2019-02-03 07:32:59 +00:00
Jeff Muizelaar
0bb8456e7d Fill out test a little more
This factors out an assert_expansion function to make things
more managable.
2019-02-02 22:39:45 -05:00
Jeff Muizelaar
31d143ba18 Fix macro_rules separator parsing.
macro_rules rules are separated by ';' including an optional ';' at the
end
2019-02-02 22:39:13 -05:00
DJMcNab
7417c0775b Fix number of extern_inner_attributes 2019-02-02 16:18:12 +00:00
Hoàng Đức Hiếu
1c5a63e3db add postfix completion for dbg!() with .dbg 2019-02-02 22:10:18 +07:00
Florian Diebold
d8ef8acb47 Use aliases in import resolution 2019-02-02 00:23:59 +01:00
Florian Diebold
5a7fce4e4c Pass aliases to ImportData 2019-02-02 00:23:53 +01:00
Florian Diebold
aa5f6a1ee8 Add test for use as 2019-02-02 00:23:53 +01:00
Florian Diebold
c5852f422f Some cleanup and additional tests 2019-02-01 23:24:26 +01:00
Florian Diebold
d571d26955 Make the Resolution variants tuple variants 2019-02-01 22:54:30 +01:00
Florian Diebold
d3df80dfe4 Cleanup 2019-02-01 22:54:21 +01:00
Florian Diebold
afce8e4426 Use the new Resolver API for goto def 2019-02-01 22:45:43 +01:00
Florian Diebold
33ff7b56ff Use the new Resolver API in completion 2019-02-01 22:45:25 +01:00
Florian Diebold
6b076f1931 Use new Resolver API in type inference 2019-02-01 22:45:23 +01:00
Florian Diebold
758bc72873 Implement methods to build a resolver 2019-02-01 22:17:48 +01:00
Florian Diebold
5208c2aa93 Sketching the resolver API 2019-02-01 22:14:34 +01:00
csmoe
4dffdcf14a split HirDatabase api 2019-02-01 22:05:24 +08:00
csmoe
12433a7887 split hirdatabase 2019-02-01 21:36:51 +08:00
Aleksey Kladov
de85f1e947 remove hard-coded support for ctry macro
It was used mainly to prevent HirFileId infra from bitroting, but the
`vec![]` macro can serve that just as well!
2019-02-01 10:52:36 +03:00
kjeremy
f0fdc9d5c0 Go To Implementation for Trait 2019-01-31 18:34:52 -05:00
Aleksey Kladov
4c0ab7db85 explain the magic 2019-01-31 22:23:30 +02:00
Aleksey Kladov
b4b522fb39 cleanup the api 2019-01-31 22:23:30 +02:00
Aleksey Kladov
a16f6bb27d cleanup 2019-01-31 22:23:30 +02:00
Aleksey Kladov
2d1f0b105d move test 2019-01-31 22:23:30 +02:00
Aleksey Kladov
40feacdeb9 split macros across crates 2019-01-31 22:23:30 +02:00
Aleksey Kladov
ad80a0c551 preserve token spacing 2019-01-31 22:23:30 +02:00
Aleksey Kladov
5934738854 first test sort-of passes 2019-01-31 22:23:30 +02:00
Aleksey Kladov
be03aa5ee7 extract tt cursor 2019-01-31 22:23:30 +02:00
Aleksey Kladov
8d5a8f085c binders boilerplate 2019-01-31 22:23:30 +02:00
Aleksey Kladov
2def5b4e6f more expand boilerplate 2019-01-31 22:23:30 +02:00
Aleksey Kladov
d2a1e07150 more expand boilerplate 2019-01-31 22:23:30 +02:00
Aleksey Kladov
09a8d75351 expand boilerplate 2019-01-31 22:23:30 +02:00
Aleksey Kladov
2d88207853 reshuffle 2019-01-31 22:23:30 +02:00
Aleksey Kladov
ce3636798b move macros to a separate crate 2019-01-31 22:23:30 +02:00
Aleksey Kladov
9a043a163c parses simple macro 2019-01-31 22:23:30 +02:00
Aleksey Kladov
0d9210e9bc handle multibyte tokens 2019-01-31 22:23:30 +02:00
Aleksey Kladov
f3489e8111 add eat methods 2019-01-31 22:23:30 +02:00
Aleksey Kladov
e28a5e048a parsing scaffold 2019-01-31 22:23:30 +02:00
Aleksey Kladov
2980508ad2 debug impls 2019-01-31 22:23:30 +02:00
Aleksey Kladov
82cf0185c3 add repeats to ast 2019-01-31 22:23:30 +02:00
Aleksey Kladov
3bd4560d6e convert punts and literals 2019-01-31 22:23:30 +02:00
Aleksey Kladov
c09c6fc97c start tt convertions boilerplate 2019-01-31 22:23:30 +02:00
Aleksey Kladov
a4342a7fee add conversion boilerplate 2019-01-31 22:23:30 +02:00
Aleksey Kladov
ca327f35ad add macro by example ide 2019-01-31 22:23:30 +02:00
Aleksey Kladov
6846ac2a16 shorten name :-) 2019-01-31 22:23:30 +02:00
Aleksey Kladov
b8f56f89c6 start token tree module 2019-01-31 22:23:30 +02:00
bors[bot]
1bf47d43db Merge #715
715: Use "▶" for test code lens r=matklad a=kjeremy

I find that this makes code lenses stand out more otherwise they can be easy to miss.

Co-authored-by: Jeremy Kolb <kjeremy@gmail.com>
2019-01-31 13:04:03 +00:00
Jeremy Kolb
76c0d0b94d format 2019-01-31 07:44:26 -05:00
bors[bot]
97ade89993 Merge #692
692: [WIP] Correctly parse attributes  r=matklad a=DJMcNab

Reference - https://doc.rust-lang.org/reference/attributes.html
This fixes/investigates inner attributes for:

- [x] `impl` blocks
- [x] `extern` blocks
- [x] `fn`s (fixes #689)
- [x] `mod`s (already supported)
- [x] 'block expressions' (the long text just describes all 'blocks' used as statements)

This also investigates/fixes outer attributes for:

- [ ] 'most statements' (see also: #685, https://doc.rust-lang.org/reference/expressions.html#expression-attributes)
- [x] Enum variants, Struct and Union fields (Fixed in #507)
- [ ] 'Match expression arms' (@matklad can you provide a test case which explains what this means?)
- [ ] 'Generic lifetime or type parameters'
- [ ] 'Elements of array expressions, tuple expressions, call expressions, tuple-style struct and enum variant expressions'
- [ ] 'The tail expression of block expressions'

Co-authored-by: DJMcNab <36049421+djmcnab@users.noreply.github.com>
2019-01-31 07:06:31 +00:00
bors[bot]
777c79ce6b Merge #712
712:  Fix #667 and improvements to introduce_variable r=matklad a=eulerdisk

Fix #667 (but not re-indenting currently), plus many other improvements.
@matklad I'm not sure how to handle re-indenting here.

Co-authored-by: Andrea Pretto <eulerdisk@gmail.com>
2019-01-31 07:00:11 +00:00
Jeremy Kolb
57899d66fa Use "▶" for test code lens
I find that this makes code lenses stand out more.
2019-01-30 22:09:27 -05:00
Andrea Pretto
a5fe4a08fb Some improvements to introduce_variable. 2019-01-30 23:01:01 +01:00
bors[bot]
28fdb8d03c Merge #701
701: Minor type inference tweaks r=flodiebold a=marcusklaas

Pass down expectation for reference expressions and type the guard in match expressions.

I wasn't able to add a test for the former addition because the type variable previously introduced would always resolve to the right type in the things I tried!

Co-authored-by: Marcus Klaas de Vries <mail@marcusklaas.nl>
2019-01-30 20:51:47 +00:00
Florian Diebold
1acff307fe Move expr_scopes query to its module 2019-01-30 21:39:34 +01:00
Andrea Pretto
7a1494ced5 Fix #667 2019-01-30 21:31:29 +01:00
Florian Diebold
65864d85f9 Rename FnScopes -> ExprScopes
The reason for this is that it describes scopes for any body expression, not
just that of a function. It did not actually refer to functions at all anymore.
2019-01-30 21:23:50 +01:00
Marcus Klaas de Vries
13cb4a1b37 Add test for passing on ref expectations 2019-01-30 21:14:26 +01:00
Aleksey Kladov
ef7eb8c257 Use Crate instead of CrateId 2019-01-30 22:37:20 +03:00
Aleksey Kladov
95aa7e46fc move item_map_query 2019-01-30 22:36:22 +03:00
bors[bot]
b704ce803b Merge #702
702: Go to Implementation r=matklad a=kjeremy

First half of #620

Co-authored-by: Jeremy Kolb <kjeremy@gmail.com>
Co-authored-by: kjeremy <kjeremy@gmail.com>
2019-01-30 19:19:31 +00:00
kjeremy
04eb15856b Resolve crate 2019-01-30 13:18:21 -05:00
Jeremy Kolb
b88ba007cc Pass Documentation up to LSP and add "rust" to our codeblocks there 2019-01-29 21:39:09 -05:00
Jeremy Kolb
3c17643b30 Go to Implementation for structs and enums 2019-01-29 19:13:02 -05:00