Commit Graph

434 Commits

Author SHA1 Message Date
bors[bot]
aa7bdfd37f Merge #1208
1208: [WIP] Goto for Macro's r=matklad a=Lapz

Adds goto definition for macros. Currently only works for macros in the current crate ~~otherwise it panics~~. Proper macro resolution needs to be added for it to resolve macros in other crates.

Todo
- [X] Allow goto from macro calls
- [X] Fix panics
- [x] Add tests



![Screen Recording 2019-04-25 at 18 00 24](https://user-images.githubusercontent.com/19998186/56754499-1dd01c00-6785-11e9-9e9a-1e36de70cfa3.gif)



Co-authored-by: Lenard Pratt <l3np27@gmail.com>
2019-05-04 18:38:10 +00:00
Florian Diebold
a4eb1a546c Differentiate Tuple / FnPtr type constructors by cardinality
This is necessary because Chalk (reasonably) expects each 'struct' to know how
many type parameters it takes.
2019-05-04 19:11:21 +02:00
Lenard Pratt
8198e13c26 Added local macro goto 2019-05-04 17:39:51 +01:00
Aleksey Kladov
ca5aedc9bf revert eagarly clean astd maps
This causes massive slowdown :-(
2019-05-04 15:29:35 +03:00
Aleksey Kladov
6c63a59425 eagarly clean astd maps 2019-05-04 11:53:44 +03:00
Florian Diebold
85633656df Fix hover on the beginning of a nested expression
E.g. in
```
let foo = 1u32;
if true {
   <|>foo;
}
```
the hover shows `()`, the type of the whole if expression, instead of the more
sensible `u32`. The reason for this was that the search for an expression was
slightly left-biased: When on the edge between two tokens, it first looked at
all ancestors of the left token and then of the right token. Instead merge the
ancestors in ascending order, so that we get the smaller of the two possible
expressions.
2019-04-28 16:03:49 +02:00
kjeremy
558bdf73c8 simplify match 2019-04-24 14:45:02 -04:00
kjeremy
f69bf6a12b See through references 2019-04-24 12:09:29 -04:00
bors[bot]
6009af9b7c Merge #1200
1200: Allows searching for case-equivalent symbols (fixes #1151) r=matklad a=jrvidal

I couldn't find a nice, functional way of calculating the ranges in one pass so I resorted to a plain old `for` loop.

Co-authored-by: Roberto Vidal <vidal.roberto.j@gmail.com>
2019-04-23 21:25:37 +00:00
Roberto Vidal
dd8c3840cb CR corrections 2019-04-23 22:19:45 +02:00
kjeremy
a5bf0cdb97 Simplify 2019-04-23 15:44:37 -04:00
kjeremy
7125192c1e Basic resolution for ADT 2019-04-23 14:32:47 -04:00
Roberto Vidal
b56f010201 Allows searching for case-equivalent symbols (fixes #1151) 2019-04-23 20:11:45 +02:00
bors[bot]
c416caeda2 Merge #1194
1194: Pr 1190 r=matklad a=matklad



Co-authored-by: Andrea Pretto <eulerdisk@gmail.com>
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-04-22 13:19:47 +00:00
Aleksey Kladov
c27a3da5e8 remove path_ident from CompletionContext
We really shouldn't be looking at the identifier at point. Instead,
all filtering and sorting should be implemented at the layer above.

This layer should probably be home for auto-import completions as
well, but, since that is not yet implemented, let's just stick this
into complete_scope.
2019-04-22 16:04:56 +03:00
Aleksey Kladov
e01052d1f0 move auto-imoprter into IDE
auto-import is purely an IDE concern, so it should be done outside of
HIR
2019-04-22 15:56:28 +03:00
Aleksey Kladov
b811922a53 fix postfix match indent 2019-04-22 10:38:39 +03:00
Andrea Pretto
200032852b complete_import: prevent panic when the anchor is the completion source range
(fix rebase mess)

 Please enter the commit message for your changes. Lines starting
2019-04-22 00:48:43 +02:00
Andrea Pretto
9144214958 complete_import: add new import resolver infrastructure with some hardcoded importable name.
Changes complete_scope to support that.
2019-04-22 00:14:58 +02:00
Marco Groppo
8ebb20edce New krate() method in Resolver.
Renamed Impl to ImplBlock.
2019-04-20 00:20:26 +02:00
Marco Groppo
e85ee60c42 Initial support for lang items. 2019-04-20 00:10:19 +02:00
Aleksey Kladov
c4a5aa45dc add a couple of profiling points 2019-04-15 01:10:07 +03:00
Florian Diebold
4f8a49f43c Refactor method candidate generation a bit
This fixes the order in which candidates are chosen a bit (not completely
though, as the ignored test demonstrates), and makes autoderef work with trait
methods. As a side effect, this also makes completion of trait methods work :)
2019-04-14 21:53:35 +02:00
Florian Diebold
413c87f155 Get substs for trait refs in impl blocks 2019-04-14 11:28:53 +02:00
Aleksey Kladov
62d01dd4df hide resolver 2019-04-13 11:00:15 +03:00
Aleksey Kladov
f4a94e74bc fold ScopeWithSyntax into SourceAnalyzer 2019-04-13 10:49:01 +03:00
Aleksey Kladov
cec67b2b65 obsolete fixm 2019-04-13 09:50:02 +03:00
Aleksey Kladov
3aae223d93 hide some scopes 2019-04-13 09:31:03 +03:00
Aleksey Kladov
0fd93bc14a use really correct resolver for expressions 2019-04-13 00:44:47 +03:00
Aleksey Kladov
20013de2ab fix typo 2019-04-11 17:15:20 +03:00
Aleksey Kladov
ebb0c377f0 remove resolver from CompletonContext 2019-04-11 16:49:35 +03:00
Aleksey Kladov
5471c1ef4b generalize SourceAnalyzer to handle all defs with bodies 2019-04-11 16:37:29 +03:00
Aleksey Kladov
07cc047b4f minimize the API 2019-04-11 16:29:33 +03:00
Aleksey Kladov
b6809b6695 rename 2019-04-11 16:29:33 +03:00
Aleksey Kladov
6c2ba945ed reduce visibility 2019-04-11 16:29:33 +03:00
Aleksey Kladov
505acc973b Make call info to use real name resolution 2019-04-11 16:29:33 +03:00
Aleksey Kladov
10d66d63d7 introduce SourceAnalyzer 2019-04-11 16:29:33 +03:00
bors[bot]
6d9acb8753 Merge #1131
1131: Use inline snapshots in complete_dot r=matklad a=vipentti

Relates to #1127 

Co-authored-by: Ville Penttinen <villem.penttinen@gmail.com>
2019-04-10 11:05:31 +00:00
Ville Penttinen
57283b4e5f Use inline snapshots in complete_dot 2019-04-10 13:47:20 +03:00
Ville Penttinen
1b19c1c8f2 Use inline snapshots in complete_fn_param 2019-04-10 13:22:50 +03:00
Aleksey Kladov
10726fdb65 type-safer source-map for bindings 2019-04-10 10:48:15 +03:00
Aleksey Kladov
6b993a9760 migrate to salsas interning 2019-04-09 22:51:22 +03:00
Ville Penttinen
45a2b92524 Fix doc comment 2019-04-09 16:08:24 +03:00
Ville Penttinen
07f0069f34 Move display related things from hover to display 2019-04-09 14:45:05 +03:00
Ville Penttinen
fead60aa27 Move FunctionSignature to display/function_signature 2019-04-09 14:45:05 +03:00
Ville Penttinen
bd6ddfcdde Make display modules private 2019-04-09 14:45:05 +03:00
Ville Penttinen
7821c56be7 Move structure to display/structure 2019-04-09 14:45:05 +03:00
Ville Penttinen
027d4d229d Move navigation_target to display/navigation_target 2019-04-09 14:45:05 +03:00
Ville Penttinen
946b5789d1 Move completion label functions to display 2019-04-09 14:45:05 +03:00
Ville Penttinen
dfaebd76ab Add FunctionSignature::from_hir 2019-04-09 14:45:05 +03:00
Ville Penttinen
2fe075f56e Normalize line-endings in display.rs
This changes from CRLF to LF
2019-04-09 14:45:05 +03:00
Ville Penttinen
f4aa15c16b Move FunctionSignature creation to display 2019-04-09 14:45:05 +03:00
Ville Penttinen
ed65e2619a Add no parameter test to call_info 2019-04-09 14:45:05 +03:00
Ville Penttinen
7ba22f1c19 Move FunctionSignature to display, remove write_joined
write_joined is replaced with `join_to_string::join` which provides the
necessary functionality.
2019-04-09 14:45:05 +03:00
Ville Penttinen
84fde47d00 Move test specific things 2019-04-09 14:45:04 +03:00
Ville Penttinen
751b454442 Update test snapshots 2019-04-09 14:45:04 +03:00
Ville Penttinen
0e49abb7fb Refactor CallInfo function signatures to new FunctionSignature type
This is used by CallInfo to create a pretty printed function signature that can
be used with completions and other places as well.
2019-04-09 14:45:04 +03:00
robojumper
2caa690ef6 Rudimentarily autocomplete tuple struct field access 2019-04-06 01:10:48 +02:00
Aleksey Kladov
0de89f786f always produce source for import 2019-04-02 17:58:04 +03:00
Aleksey Kladov
7d6bd5d137 always show token text 2019-04-02 14:49:46 +03:00
Aleksey Kladov
49f13d3a9b fix a panic with glob-import missing a source map 2019-04-02 13:26:09 +03:00
Aleksey Kladov
5287a2506c More future-proof comment kind 2019-04-02 12:18:52 +03:00
Aleksey Kladov
3f3ff2f0f4 fix comment naming 2019-04-02 10:48:59 +03:00
Aleksey Kladov
ae282d8da6 add ast::tokens 2019-04-02 10:23:29 +03:00
bors[bot]
b7e26c32a1 Merge #1067
1067: Take number of arguments at the call-site into account for signature help r=matklad a=kjeremy

Fixes #1065

Co-authored-by: kjeremy <kjeremy@gmail.com>
2019-04-01 11:15:34 +00:00
Aleksey Kladov
9e213385c9 switch to new rowan 2019-04-01 12:06:24 +03:00
kjeremy
80113876e2 Simplify 2019-03-27 11:02:06 -04:00
kjeremy
7b34c4c002 Take number of arguments at the call-site into account for signature help
Fixes #1065
2019-03-27 10:00:51 -04:00
bors[bot]
a82755e241 Merge #1059
1059: Typed ids r=matklad a=matklad

just some type-safety and refactorings. 

closes https://github.com/rust-analyzer/rust-analyzer/issues/1054

bors r+

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-03-26 16:16:54 +00:00
Aleksey Kladov
e28db444df rename 2019-03-26 19:11:01 +03:00
Wilco Kusee
e03189c110 Move ra_ide_api unit tests 2019-03-25 21:03:32 +01:00
bors[bot]
c4ead49361 Merge #1034
1034: HIR diagnostics API r=matklad a=matklad

This PR introduces diagnostics API for HIR, so we can now start issuing errors and warnings! Here are requirements that this solution aims to fulfill:

* structured diagnostics: rather than immediately rendering error to string, we provide a well-typed blob of data with error-description. These data is used by IDE to provide fixes
* open set diagnostics: there's no single enum with all possible diagnostics, which hopefully should result in better modularity

The `Diagnostic` trait describes "a diagnostic", which can be downcast to a specific diagnostic kind. Diagnostics are expressed in terms of macro-expanded syntax tree: they store pointers to syntax nodes. Diagnostics are self-contained: you don't need any context, besides `db`, to fully understand the meaning of a diagnostic. 

Because diagnostics are tied to the source, we can't store them in salsa. So subsystems like type-checking produce subsystem-local diagnostic (which is a closed `enum`), which is expressed in therms of subsystem IR. A separate step converts these proto-diagnostics into `Diagnostic`, by merging them with source-maps.

Note that this PR stresses type-system quite a bit: we now type-check every function in open files to compute errors!

Discussion on Zulip: https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/Diagnostics.20API

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-03-25 11:38:46 +00:00
Aleksey Kladov
309716cffe move tests to where they belong 2019-03-25 14:29:24 +03:00
Sergey Parilin
36cb58f76d structure moved to ra_ide_api
ra_ide_api_light removed completely
2019-03-25 11:41:21 +03:00
Aleksey Kladov
e9af69d9db simplify 2019-03-25 10:56:55 +03:00
Aleksey Kladov
5ce84f3cbc tweak diagnostics API 2019-03-25 10:52:50 +03:00
Aleksey Kladov
c7ffd939f6 more enterprisey diagnostics setup 2019-03-25 10:52:50 +03:00
Aleksey Kladov
7ee2887d1e fixes 2019-03-25 10:52:50 +03:00
Aleksey Kladov
45fbab2b1a check impls as well 2019-03-25 10:52:50 +03:00
Aleksey Kladov
79df62bc74 cleanup 2019-03-25 10:52:50 +03:00
Aleksey Kladov
3fb88e95aa switch modules to new diagnostics 2019-03-25 10:52:50 +03:00
Aleksey Kladov
fcca35969d allow dyn diagnostics 2019-03-25 10:52:12 +03:00
Aleksey Kladov
7e8f17188e diagnostics 2019-03-25 10:52:12 +03:00
Ville Penttinen
4d26bae46d Rename source_edit to source_file_edit to match file_system_edit 2019-03-25 09:13:58 +02:00
Ville Penttinen
b92fcbc956 Further improvements to the SourceChange convenience methods
Rename system_edit to file_system_edit, add more documentation, add
source_file_edit_from to create a SourceChange from `FileId` and `TextEdit`.
2019-03-25 09:03:10 +02:00
Ville Penttinen
22e1c7a112 Add convenience functions to SourceChange for creating single edits 2019-03-24 22:53:41 +02:00
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