Commit graph

304 commits

Author SHA1 Message Date
Florian Diebold
affaf7700a Represent unknown types as {unknown} instead of [unknown]
Since the latter could actually be a real type...
2019-03-03 03:00:17 +01:00
bors[bot]
00b09bcd8c Merge #908
908: Enable markup for hover on expressions which resolve using type_of r=matklad a=vipentti

This adds highlighting when hovering over items which are resolved using
`type_of`.

This adds basic highlighting, discussed in #904.

Co-authored-by: Ville Penttinen <villem.penttinen@gmail.com>
2019-03-02 14:21:44 +00:00
Aleksey Kladov
8fc08d36e3 remove second way to get the body 2019-03-02 16:59:18 +03:00
Aleksey Kladov
03b2ab8e1f rename syntax_mapping as well 2019-03-02 16:56:09 +03:00
Aleksey Kladov
80bb7d86ec align lower module query names 2019-03-02 16:49:06 +03:00
Aleksey Kladov
f4c5383103 dont store body inside source map 2019-03-02 16:18:40 +03:00
Aleksey Kladov
eaf1df26e9 rename syntax-mapping -> source-map 2019-03-02 15:40:40 +03:00
kjeremy
d0efa77e0e Update hover message since we do support globs 2019-02-28 14:48:21 -05:00
Ville Penttinen
da26820ebd Enable markup for hover on expressions which resolve using type_of
This adds highlighting when hovering over items which are resolved using
`type_of`.
2019-02-28 09:33:06 +02:00
Ville Penttinen
c879f43186 Enable hover support for NamedFieldDefs
Additionally add type ascription for const and statics as well.
2019-02-27 17:52:37 +02:00
Ville Penttinen
bb4521be1c Allow goto-definition to work for named fields in struct initializer
Now goto definition should work when done on a named field in a struct
initializer.
2019-02-27 17:51:59 +02:00
Ville Penttinen
e3525527e3 Add support for hovering over the name of an item 2019-02-27 09:49:22 +02:00
Ville Penttinen
79114c67b1 Replace visit_fn with crate::completion::function_label 2019-02-26 21:30:46 +02:00
Ville Penttinen
6f5fd6c9de Add new type HoverResult to contain the results of hovering
This makes testing hovers easier as well as allows us to do more things with the
results if needed.
2019-02-26 19:30:17 +02:00
Ville Penttinen
3ec2584148 Add support for showing fn signature when hovering 2019-02-26 18:55:08 +02:00
Aleksey Kladov
78f10fcdc4 rename type to type_alias in the AST as well 2019-02-25 13:49:32 +03:00
Aleksey Kladov
330ce2e26b complete patterns 2019-02-24 23:50:02 +03:00
Florian Diebold
bd8ed644e4 Rename Type => TypeAlias 2019-02-24 21:36:49 +01:00
Aleksey Kladov
d5f6a5f5e2 move testing functions 2019-02-24 21:54:13 +03:00
Aleksey Kladov
98510ec5d3 move the rest of presentation to presentation 2019-02-24 21:46:04 +03:00
Aleksey Kladov
b7a7872910 move more code to presentation 2019-02-24 21:34:38 +03:00
Aleksey Kladov
a650a93bf5 move res completion to presentation 2019-02-24 21:21:31 +03:00
Aleksey Kladov
2369af8c82 simplify 2019-02-24 20:59:12 +03:00
Aleksey Kladov
5887c0e574 move enum-variants to presentation 2019-02-24 20:56:53 +03:00
Aleksey Kladov
9af525dbd6 simplify 2019-02-24 20:49:55 +03:00
Aleksey Kladov
3c7c5a7354 move presentaion completion to presentation 2019-02-24 19:37:22 +03:00
Aleksey Kladov
b04cadc02c move function rendering to presentation 2019-02-24 19:34:27 +03:00
Aleksey Kladov
d0a261468e introduce completion presentation
This module should remove completion rendering boilerplate from the
"brains" of completion engine.
2019-02-24 18:51:38 +03:00
Aleksey Kladov
6285fcc39b complete fields in struct literals 2019-02-24 17:39:08 +03:00
Aleksey Kladov
65a2be4953 complete struct literals 2019-02-24 17:01:56 +03:00
Aleksey Kladov
ef442b8682 Assign IDs to assists 2019-02-24 14:00:00 +03:00
Ville Penttinen
40e6cb196b Remove unnecessary to_nav_target 2019-02-23 14:08:57 +02:00
Ville Penttinen
c565ec2d6e Add name_range field to FileSymbol
This contains the syntax range of the name itself, allowing NavigationTarget to
properly set the focus_range. This should make it so that when using symbol
based navigation, we should always focus on the name, instead of the full range.
2019-02-23 13:05:45 +02:00
Ville Penttinen
7046b16275 Fix NavigationTarget debug_render container_name output 2019-02-23 12:53:53 +02:00
Ville Penttinen
2a3abe2ce3 Fix goto def not working when cursor was over the name of a def
We now allow goto_definition to return the named NavigationTarget if the cursor
is on the name of a definition.
2019-02-23 11:02:42 +02:00
bors[bot]
3d8a0982a1 Merge #866
866: Implement basic support for Associated Methods r=flodiebold a=vipentti

This is my attempt at learning to understand how the type inference works by adding basic support for associated methods. Currently it does not resolve associated types or constants. 

The basic idea is that `Resolver::resolve_path` returns a new `PathResult` type, which has two variants, `FullyResolved` and `PartiallyResolved`, fully resolved matches the previous behavior, where as `PartiallyResolved` contains the `PerNs<Resolution` in addition to a `segment_index` which contains the index of the segment which we failed to resolve. This index can then be used to continue inference in `infer_path_expr` using the `Type` we managed to resolve.

This changes some of the previous apis, so looking for feedback and suggestions.

This should enable fixing #832

Co-authored-by: Ville Penttinen <villem.penttinen@gmail.com>
2019-02-22 19:58:22 +00:00
Ville Penttinen
247d1c17b3 Change resolve_path to return the fully resolved path or PerNs::none
This also adds new pub(crate) resolve_path_segments which returns the
PathResult, which may or may not be fully resolved. PathResult is also now
pub(crate) since it is an implementation detail.
2019-02-22 10:15:23 +02:00
bors[bot]
bb665a7062 Merge #864
864: Fix handling of generics in tuple variants and refactor a bit r=matklad a=flodiebold

(The problem was that we created separate substitutions for the return value, so we lost the connection between the type arguments in the constructor call and the type arguments of the result.)

Also make them display a tiny bit nicer.

Fixes #860.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
Co-authored-by: Florian Diebold <florian.diebold@freiheit.com>
2019-02-21 20:47:50 +00:00
Aleksey Kladov
f7f99af0a6 kill utils module 2019-02-21 15:57:40 +03:00
Ville Penttinen
816971ebc9 Implement basic support for Associated Methods and Constants
This is done in `infer_path_expr`. When `Resolver::resolve_path` returns
`PartiallyResolved`, we use the returned `Resolution` together with the given
`segment_index` to check if we can find something matching the segment at
segment_index in the impls for that particular type.
2019-02-21 12:25:55 +02:00
Florian Diebold
72712b8a42 Fix handling of generics in tuple variants and refactor a bit
Also make them display a tiny bit nicer.

Fixes #860.
2019-02-20 22:48:55 +01:00
Aleksey Kladov
9738fb48a6 remove ignored macro tests
we need to significantly reengineer macros, so the tests as they exist
are useless
2019-02-19 20:06:53 +03:00
Aleksey Kladov
a92db7c848 more compact edits in insta 2019-02-18 12:24:25 +03:00
Aleksey Kladov
92aa0f9c87 Don't use additional_text_edits API internally 2019-02-18 12:24:20 +03:00
Aleksey Kladov
79f35cc699 More orthogonal method naming 2019-02-18 12:07:47 +03:00
Aleksey Kladov
864fd5ee25 More compact debug representation for completion 2019-02-18 10:31:00 +03:00
Aleksey Kladov
e503ffe9ff Don't render () in calls to assoc functions 2019-02-17 21:30:46 +03:00
bors[bot]
982f72c022 Merge #844
844: Refactor find_all_refs to return ReferenceSearchResult r=vipentti a=vipentti

This refactors `find_all_refs` to return a new `ReferenceSearchResult` based on feedback in #839.

There are few questions/notes regarding the refactor:

1. Introducing `NavigationTarget::from_bind_pat` this simply forwards the call to `NavigationTarget::from_named`, could we just expose `from_named` directly as `pub(crate)` ?
2. Added an utility method `NavigationTarget::range` since there were few places where you would use `self.focus_range.unwrap_or(self.full_range)`
3. Implementing `IntoIterator` for `ReferenceSearchResult`. This turns `ReferenceSearchResult` into an iterator over `FileRanges` and allows previous code to mostly stay as it was based on the order that `find_all_refs` previously had (declaration first and then the references). I'm not sure if there is a way of doing the conversion to `IntoIter` without the allocation of a new vector
4. Is it possible to have a binding without a name? I'm not sure if the `NavigationTarget::from_bind_pat` can cause some edge-cases that previously were ok



This fixes #835.

Co-authored-by: Ville Penttinen <villem.penttinen@gmail.com>
2019-02-17 15:38:33 +00:00
Ville Penttinen
fd5307e60d Remove leading :: 2019-02-17 17:25:19 +02:00
Florian Diebold
795d718ba1 Unify with the autorefed/autoderefed receiver type during method resolution 2019-02-17 14:44:39 +01:00
Ville Penttinen
85a6bf3424 Refactor find_all_refs to return ReferenceSearchResult 2019-02-17 13:40:43 +02:00
Florian Diebold
0242acae53 Turn ImplBlock into a copy type just containing IDs
This makes it more like the other code model types.

Also make Module::definition_source/declaration_source return HirFileIds, to
make them more like the other source functions.
2019-02-16 22:08:13 +01:00
Aleksey Kladov
2d131d63f9 document design guideline 2019-02-16 15:15:52 +03:00
Aleksey Kladov
469301b603 use better label for &mut ref completion 2019-02-14 21:34:06 +03:00
bors[bot]
10bf61b83b Merge #831
831: tweak postfix completions r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-02-14 17:38:51 +00:00
Aleksey Kladov
5f8ec8aa10 tweak postfix completions
* better label
* add refm for &mut
2019-02-14 20:38:26 +03:00
Aleksey Kladov
434f1520df add ref postfix template 2019-02-14 20:13:39 +03:00
Jeremy Kolb
1cd5966462 Be precise about the argument list
Fixes #812
2019-02-14 10:28:48 -05:00
Florian Diebold
911e32bca9 Complete names from prelude 2019-02-13 21:13:08 +01:00
Florian Diebold
3a9934e2c3 Keep track of crate edition 2019-02-13 20:10:46 +01:00
Ville Penttinen
3973974de1 Fix possible issue where unnamed is_symbol_def would pop stack wrongly
This removes is_symbol_def as unnecessary.
2019-02-13 18:02:18 +02:00
Ville Penttinen
0c37a9cc28 Use cloned over map + clone 2019-02-13 17:42:15 +02:00
Ville Penttinen
d9905f7be5 Use clone directly rather than map + clone 2019-02-13 17:28:15 +02:00
Ville Penttinen
2ef6c469ef Remove unnecessary braces 2019-02-13 11:08:25 +02:00
Ville Penttinen
dd6307ddc4 Add support for container_name in workspace/symbol query 2019-02-12 22:06:14 +02:00
Laurențiu Nicola
040fb91387 Filter attributes from the completion details/label 2019-02-12 20:35:10 +02:00
Pascal Hertleif
4fd3613434 Fix some typos 2019-02-12 15:02:57 +01:00
Laurențiu Nicola
7e8527f748 Implement completion for associated items 2019-02-12 12:51:01 +02:00
Aleksey Kladov
8ef80086a0 fix regression in self-referential completion 2019-02-11 23:43:24 +03:00
Aleksey Kladov
0d060b073c remove hard-coded query-group macro 2019-02-11 22:24:39 +03:00
Aleksey Kladov
58ed8ee665 use extern prelude in Resolver
This fixes two bugs:

- completion for paths works again
- we handle extern prelude shadowing more correctly
2019-02-11 15:41:39 +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
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
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
kjeremy
6753051a45 Some clippy cleanups 2019-02-06 15:50:26 -05:00
Aleksey Kladov
0c5fd8f7cb move assists to a separate crate 2019-02-06 17:00:00 +03: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
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
kjeremy
8ec4b84013 Bump insta and proptest to latest 2019-02-04 14:11:51 -05:00
Aleksey Kladov
dbf9820e35 make HirDatabase object-safe 2019-02-03 22:15:31 +03:00
gfreezy
bfaefed3f6 fill match arm 2019-02-04 00:27:36 +08:00
Hoàng Đức Hiếu
9dd7ccf609 fold complete_postfix tests into one 2019-02-03 20:12:57 +07:00
Hoàng Đức Hiếu
1c5a63e3db add postfix completion for dbg!() with .dbg 2019-02-02 22:10:18 +07: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
csmoe
4dffdcf14a split HirDatabase api 2019-02-01 22:05:24 +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