Commit graph

348 commits

Author SHA1 Message Date
bors[bot]
18a8f48039 Merge #1031
1031: Move most things out of ra_ide_api_light r=matklad a=detrumi

This moves everything except `structure` out of `ra_ide_api_light`. So this PR and #1019 finish up #1009, whichever is merged last should probably remove the `ra_ide_api_light` crate.

Also, `LocalEdit` was removed since it wasn't used any more.

Co-authored-by: Wilco Kusee <wilcokusee@gmail.com>
2019-03-23 17:25:40 +00:00
Wilco Kusee
a3711e08dc Move highlighting and matching_brace 2019-03-23 17:34:49 +01:00
Wilco Kusee
a656b891fb Remove LocalEdit usage 2019-03-23 17:00:49 +01:00
Aleksey Kladov
46a21b07e6 remove obsolete diagnostic 2019-03-23 16:31:11 +03:00
Aleksey Kladov
3f0cf6ebe1 rename persistent hir database -> def database 2019-03-23 15:44:24 +03:00
bors[bot]
331220fee2 Merge #1025
1025: Disable fork feature for proptest r=matklad a=detrumi



Co-authored-by: Wilco Kusee <wilcokusee@gmail.com>
2019-03-23 12:09:07 +00:00
Wilco Kusee
0c15deac76 Move typing to ra_ide_api 2019-03-23 12:11:46 +01:00
Aleksey Kladov
4fd8cfd6ad replace todo with fixme 2019-03-23 11:07:09 +03:00
Wilco Kusee
497934a7b4 Disable fork feature for proptest 2019-03-23 08:57:07 +01:00
bors[bot]
15189bc724 Merge #1021
1021: Wasm dependencies r=matklad a=detrumi

As a first step towards running RA on WASM (see #1007), this tweaks the dependencies somewhat so that projects built using `wasm-pack` can use `ra_ide_api` as a dependency.

There were two problems:
- use of undeclared type or module `MmapInner`
This error occurred because of the `memmap` crate, as a dependency of `fst`
Solution: specify `default-features = false` for the `fst` package (see https://github.com/BurntSushi/fst/issues/70)

- use of undeclared type or module `imp`
This happened in the `wait-timeout` crate ([which uses `Command` under the hood](https://github.com/alexcrichton/wait-timeout/issues/18)), a dependency of `rusty-fork` which is a dependency of `proptest`.
Solution: move `proptest` to dev-dependencies and add `#[cfg(test)]` to the `test_utils` crate.
**Edit:** Oh, that causes trouble with resolving the import when running the tests. Hmm...

Co-authored-by: Wilco Kusee <wilcokusee@gmail.com>
2019-03-22 20:22:37 +00:00
Wilco Kusee
4e6d0933cc
Disable memmap feature in fst dependency 2019-03-22 21:22:03 +01:00
Wilco Kusee
01bca7114c Simplify changes and fix tests 2019-03-22 17:12:32 +01:00
Wilco Kusee
9bd8336c51 Remove LocalEdit usage 2019-03-22 17:12:32 +01:00
Wilco Kusee
58e77660de Move join_lines to ra_ide_api 2019-03-22 17:12:31 +01:00
Sergey Parilin
47c501bcfb Move folding_ranges to ra_ide_api 2019-03-22 16:31:21 +03:00
Sergey Parilin
fda70badf8 line_index and line_index_utils moved to ra_ide_api 2019-03-22 15:24:43 +03:00
Florian Diebold
cbb418ebb8 Rename name field to ctor as well 2019-03-21 22:29:12 +01:00
Florian Diebold
f10f5a81b3 TypeName => TypeCtor 2019-03-21 22:20:03 +01:00
Florian Diebold
8a5fbf4713 Remove the old variants replaced by Ty::Apply 2019-03-21 22:17:00 +01:00
Aleksey Kladov
1b58e3e410 cleanup 2019-03-21 19:21:58 +03:00
Aleksey Kladov
7cae9ddeeb move diagnostics to ide_api 2019-03-21 19:08:54 +03:00
Aleksey Kladov
b931a472c4 move extend selection from ra_ide_api_light to ra_ide_api 2019-03-20 23:52:55 +03:00
Aleksey Kladov
3eb56f7a6a introduce Analysis::from_single_file 2019-03-20 23:38:59 +03:00
Aleksey Kladov
6955e392f8 remove old macro support 2019-03-17 12:53:22 +03:00
Aleksey Kladov
b2a6c17362 remove lower module 2019-03-17 12:52:52 +03:00
Aleksey Kladov
2195d1db6d Replace module_tree with CrateDefMap 2019-03-17 12:49:07 +03:00
Florian Diebold
c5ee60e05b Replace Display by a pretty printing trait for Ty
This allows removing the names from Adt and FnDef (and more later), as a first
step towards aligning more with chalk's Ty :)
2019-03-16 16:36:59 +01:00
Aleksey Kladov
8774067a87 sort navigations to make tests stable 2019-03-14 13:28:45 +03:00
kjeremy
27fc99776f Remove superfluous semicolons
Doesn't change the result of the test but it does prevent the
syntax tree from rendering.
2019-03-08 16:45:26 -05:00
Ville Penttinen
b168104d95 Use ast::Name::text() instead of name().syntax().text() 2019-03-07 20:58:41 +02:00
Ville Penttinen
5c0556c2ca Fix EnumVariants not showing properly when hovering
This fixes documentation as well for EnumVariants
2019-03-07 20:33:33 +02:00
Ville Penttinen
4a0bb3d7c5 Add support for goto definition and hover on Self
This fixes #943
2019-03-07 17:34:44 +02:00
kjeremy
064707c5a0 Use source map 2019-03-06 14:40:42 -05:00
kjeremy
aac421b135 Hover for associated items in patterns 2019-03-06 11:39:11 -05:00
kjeremy
eb3ee7b8e5 Updates 2019-03-05 10:26:36 -05:00
Aleksey Kladov
d1c982d3c7 dont produce giant debug dumps 2019-03-05 17:09:48 +03:00
kjeremy
1578375b89 Make ExpOrPatId private 2019-03-04 09:49:18 -05:00
Jeremy Kolb
79f61dcb0e Format 2019-03-04 08:34:41 -05:00
Jeremy Kolb
e1b59bfe0b Add NavigationTarget::from_impl_item 2019-03-04 08:27:08 -05:00
Jeremy Kolb
3d8d880c59 Use ImplItems instead of just Function 2019-03-04 08:27:08 -05:00
kjeremy
49da9a3e81 Make goto definition/hover resolve constructors 2019-03-04 08:27:08 -05:00
Ville Penttinen
1ef2c06131 Allow syntax strings to contain test markers
We simply remove all the CUSTOM_MARKERS before attempting to parse the file.
This allows for the syntax selection to work with most of the test strings.
2019-03-04 09:19:46 +02:00
Ville Penttinen
16ecd276f0 Implement syntax tree support for syntax inside string
This allows us to select a string or portions of it and try parsing it as rust
syntax. This is mostly helpful when developing tests where the test
itself contains some rust syntax as a string.
2019-03-04 09:02:01 +02:00
Ville Penttinen
ac52d9a1f1 Add optional range parameter to SyntaxTreeParams
When range is provided, instead of showing the syntax for the whole file, we'll
show the syntax tree for the given range.
2019-03-03 19:49:50 +02:00
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