Commit Graph

1966 Commits

Author SHA1 Message Date
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
882c47f187 move syntax error to parser 2019-02-20 23:17:07 +03:00
Aleksey Kladov
61992dc1cd simplify 2019-02-20 23:05:59 +03:00
Aleksey Kladov
4c1f9b8d4e remove TokenPos 2019-02-20 23:02:24 +03:00
Aleksey Kladov
cce23fddba flattern module structure 2019-02-20 22:52:32 +03:00
Aleksey Kladov
2acb21e8f7 merge parse_impl and parser_api 2019-02-20 22:44:06 +03:00
Aleksey Kladov
e72ad0a2fa fix off by one error 2019-02-20 22:27:49 +03:00
Aleksey Kladov
2b5e336ce7 move abstract traits to top 2019-02-20 22:19:12 +03:00
Aleksey Kladov
d2bce118ae switch to dynamic dispatch for TokenSource
Benchmarks show no difference. This is probably because we are
bottlenecked on memory allocations, and we should fix that, but we are
not optimizing for performance just yet.

changes. Lines starting # with '#' will be ignored, and an empty
message aborts the commit. # # On branch token-source # Changes to be
committed: # modified: crates/ra_syntax/src/parsing/parser_api.rs #
modified: crates/ra_syntax/src/parsing/parser_impl.rs #
2019-02-20 22:02:03 +03:00
Aleksey Kladov
0c81b9deee route parsing via TokenSource trait 2019-02-20 21:50:07 +03:00
Aleksey Kladov
3517c175ac rename Sink -> TreeSink 2019-02-20 21:08:59 +03:00
Aleksey Kladov
86a67dce25 fix tests 2019-02-20 16:48:06 +03:00
Aleksey Kladov
45fc91cc47 rearrange modules in a suggestd reading order 2019-02-20 16:24:39 +03:00
Aleksey Kladov
a4a1e08ab8 flatten modules 2019-02-20 16:16:14 +03:00
Aleksey Kladov
9f6883fbf1 move reparsers to grammar 2019-02-20 16:02:06 +03:00
Aleksey Kladov
5a6eda528c tighten visibility 2019-02-20 15:57:26 +03:00
Aleksey Kladov
5222b8aba3 move all parsing related bits to a separate module 2019-02-20 15:47:32 +03:00
Aleksey Kladov
9d0cda4bc8 slightly better name 2019-02-20 15:03:31 +03:00
Aleksey Kladov
df6efe62c5 make stuff private 2019-02-20 14:53:19 +03: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
a6897a837c remove local-vfs 2019-02-18 16:43:48 +03:00
Aleksey Kladov
1bdd935e91 switch to crates.io vfs 2019-02-18 16:43:16 +03:00
Aleksey Kladov
d93097a493 better comments 2019-02-18 16:20:12 +03:00
Aleksey Kladov
def7bc0ec5 drop dependency on thread_worker 2019-02-18 15:30:58 +03:00
Aleksey Kladov
9da3705191 drop unused extern crate 2019-02-18 14:39:18 +03:00
Aleksey Kladov
c5a65466e2 hide TaskResult from the public API 2019-02-18 14:29:54 +03:00
Aleksey Kladov
062aa97235 move public API to top of the file 2019-02-18 14:29:39 +03:00
Aleksey Kladov
74288ae272 remove depedency on ra_arena 2019-02-18 14:20:54 +03:00
Aleksey Kladov
4c154c289e remove arena from Roots
we want to move ra_vfs to a new repo, so having fewer deps is useful.
Arena is a thin layer of sugar on top of Vec anyway.
2019-02-18 14:13:13 +03:00
Aleksey Kladov
d151b2a655 remove useless Arc 2019-02-18 14:05:08 +03:00
Aleksey Kladov
5823d3d042 drop unused deps 2019-02-18 12:46:08 +03:00
bors[bot]
16c7ebbb27 Merge #854
854: more compact edits in insta r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-02-18 09:26:24 +00: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
bors[bot]
564ab84b78 Merge #852
852: Handle != r=flodiebold a=matklad

r? @flodiebold

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-02-18 09:13:51 +00: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
4e8a3f565b handle != operator 2019-02-18 10:09:44 +03:00
bors[bot]
8b95c0e0c2 Merge #850
850: Handle tuple structs / enum variants properly in type inference r=matklad a=flodiebold



Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2019-02-18 06:22:07 +00:00
Ville Penttinen
58d14bcaf7 Enable parsing attributes for generic lifetimes and type parameters 2019-02-17 23:32:10 +02:00
Florian Diebold
b82db68400 Handle tuple structs / enum variants properly in type inference 2019-02-17 20:53:13 +01:00
bors[bot]
a725dd4f7a Merge #849
849: Don't render `()` in calls to assoc functions r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-02-17 18:47:09 +00:00
bors[bot]
646b53ace3 Merge #846
846: WIP: Enable parsing of attributes inside a match block r=matklad a=vipentti

We allow invalid inner attributes to be parsed, e.g. inner attributes that are
not directly after the opening brace of the match block.

Instead we run validation on `MatchArmList` to allow better reporting of errors.

This fixes #845 and works towards #759 



Co-authored-by: Ville Penttinen <villem.penttinen@gmail.com>
2019-02-17 18:39:26 +00:00
Ville Penttinen
bb25958705 Remove match_armlist validator 2019-02-17 20:32:10 +02:00
Aleksey Kladov
e503ffe9ff Don't render () in calls to assoc functions 2019-02-17 21:30:46 +03:00
bors[bot]
3dcde0b2ab Merge #847
847: Refactor vfs r=matklad a=matklad

Some slight refctorings of VFS, in preparation for moving it to a separate repo

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-02-17 18:19:27 +00:00
Aleksey Kladov
aea986001f marginally better names 2019-02-17 21:10:40 +03:00
Aleksey Kladov
bb393e2d11 fix-tests 2019-02-17 21:05:33 +03:00
Aleksey Kladov
143e5b628e remove overlay removes overlay 2019-02-17 20:58:28 +03:00
Aleksey Kladov
e8bc29f122 simplify overlay handling 2019-02-17 20:54:11 +03:00
Ville Penttinen
96e3ac389f Parse only outer_attributes for match arms for now 2019-02-17 19:48:08 +02:00
Aleksey Kladov
b719a6cc07 simplify 2019-02-17 20:34:01 +03:00
Ville Penttinen
1c97c1ac11 Enable parsing of attributes inside a match block
We allow invalid inner attributes to be parsed, e.g. inner attributes that are
not directly after the opening brace of the match block.

Instead we run validation on `MatchArmList` to allow better reporting of errors.
2019-02-17 19:26:57 +02:00
Aleksey Kladov
7187fc5c2a rename method 2019-02-17 20:25:52 +03:00
Aleksey Kladov
e95fb7c9f9 remove duplicated method 2019-02-17 20:25:35 +03:00
Aleksey Kladov
162dea51bf hide root config 2019-02-17 20:22:46 +03:00
Aleksey Kladov
6b5d90972a move roots to a module 2019-02-17 19:46:55 +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
3c7c7e5a04 Make GenericArgs::from_ast pub(crate) 2019-02-17 14:55:04 +01: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
a1bda3fc08 Handle generic args for method calls 2019-02-16 23:06:41 +01:00
Florian Diebold
65bd9bc3a8 Handle impl generics in method calls 2019-02-16 23:06:41 +01:00
Florian Diebold
2af067b391 Resolve impl generic params 2019-02-16 23:06:41 +01:00
Florian Diebold
da7056245d Add generic params to impl blocks 2019-02-16 23:06:41 +01:00
Florian Diebold
ccfc6b11c1 Add a test for impl generics 2019-02-16 23:06:41 +01: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
bors[bot]
13f464edbd Merge #836
836: auto_import: fix bug when the common path was shorter than both the c… r=matklad a=eulerdisk

Fix bug when the common path was shorter than both the current use and target path.

Wrong 1 (unnecessary self)
```
use std::fmt::nested::Debug;
std::fmt::Display<|>
```
--->
```
use std::fmt::{ self, Display, nested::Debug};
Display<|>
```

Wrong 2 (unnecessary, Debug disappear!!)
```
use std::fmt::Debug;
std::fmt::nested::Display
```
-->
```
use std::fmt::Debug::{ self, nested::Display, };
Display<|>
```

Co-authored-by: Andrea Pretto <eulerdisk@gmail.com>
2019-02-16 11:29:03 +00:00
Felix S. Klock II
cc15d3613c Dont slow down everyone else's testing (especially the CI's Linux) just for OS X.
Namely, the allowance for up to 7 events, and thus requiring anyone
with fewer than 7 events to wait for the 3 second timeout, is only
relevant to fsevents (i.e. Mac OS X)
2019-02-15 13:26:19 +01:00
Felix S. Klock II
f7e711b77f Generalize tests/vfs.rs processing to address wildly-varying time-dependent behavior on Mac OS X. 2019-02-15 12:55:30 +01:00
bors[bot]
17370463e2 Merge #830
830: Fix test_vfs_works failing on Windows due to extra Write events r=pnkfelix a=vipentti

On Windows `notify` generates extra `Write` events for folders, which caused
`process_tasks` to not handle all tasks generated on Windows.

This fixes #827

Co-authored-by: Ville Penttinen <villem.penttinen@gmail.com>
2019-02-14 22:00:11 +00:00
Andrea Pretto
e8f3c1650a auto_import: fix bug when the common path was shorter than both the current use and target path.
Shorter test names.
2019-02-14 21:58:36 +01:00
bors[bot]
f8d4cec342 Merge #834
834: use better label for &mut ref completion r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-02-14 18:34:47 +00:00
Aleksey Kladov
469301b603 use better label for &mut ref completion 2019-02-14 21:34:06 +03:00
Aleksey Kladov
e0b8942c56 simplify 2019-02-14 21:14:47 +03:00
Aleksey Kladov
bf352cd251 automatically wait for worker threads
closes #817
2019-02-14 21:11:07 +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
Ville Penttinen
50e49e0bc0 Fix test_vfs_works failing on Windows due to extra Write events
On Windows `notify` generates extra `Write` events for folders, which caused
`process_tasks` to not handle all tasks generated on Windows.

This fixes #827
2019-02-14 18:30:21 +02:00
Jeremy Kolb
1cd5966462 Be precise about the argument list
Fixes #812
2019-02-14 10:28:48 -05:00
Ville Penttinen
f7a78b2846 Remove call to canonicalize in BatchDatabase::load_cargo
Instead of using canonicalize, we now join the given path to
`std::env::current_dir()`, which either replaces the path, if the given path is
absolute, or joins the paths.

This fixes #821.
2019-02-14 10:57:06 +02:00
bors[bot]
ebfa26658e Merge #818
818: In `RootConfig::contains`, check against canonicalized version of root path r=matklad a=pnkfelix

In `RootConfig::contains`, check against canonicalized version of root path since OS may hand us data that uses the canonical form rather than the root as specified by the user.

This is a step towards a resolution of issue #734 but does not completely fix the problem there.

Co-authored-by: Felix S. Klock II <pnkfelix@pnkfx.org>
2019-02-13 21:33:31 +00:00
Felix S. Klock II
da300fd553 rustfmt 2019-02-13 22:31:33 +01:00
Florian Diebold
911e32bca9 Complete names from prelude 2019-02-13 21:13:08 +01:00
Florian Diebold
92c595a6a6 Handle extern crates better, so they work correctly in 2015 edition
(see the removed comment.)
2019-02-13 21:13:08 +01:00
Florian Diebold
70839b7ef8 Make edition handling a bit nicer and allow specifying edition in crate_graph macro 2019-02-13 20:31:47 +01:00
Florian Diebold
d5ad38cbb8 Resolve 2015 style imports 2019-02-13 20:10:46 +01:00
Florian Diebold
3a9934e2c3 Keep track of crate edition 2019-02-13 20:10:46 +01:00
Florian Diebold
1526eb25c9 Import the prelude 2019-02-13 20:10:09 +01:00
bors[bot]
65266c644a Merge #813
813: Add support for container_name in workspace/symbol query r=matklad a=vipentti

Currently this does not fill in the container_info if a type is defined on the top level in a file. 

e.g. `foo.rs`
```rust
enum Foo { }
```
`Foo` will have None as the container_name, however

```rust
mod foo_mod {
    enum Foo { } 
}
```
`Foo` has `foo_mod` as the container_name. 

This closes #559 

Co-authored-by: Ville Penttinen <villem.penttinen@gmail.com>
2019-02-13 16:17:10 +00:00
Felix S. Klock II
cfed7c59f4 In RootConfig::contains, check against canonicalized version of root
path since OS may hand us data that uses that rather than the root as
specified by the user.
2019-02-13 17:16:28 +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
bors[bot]
74d03d57e7 Merge #814
814: auto_import: import in enclosing module by default r=matklad a=eulerdisk

Simpler version of #795 

Co-authored-by: Andrea Pretto <eulerdisk@gmail.com>
2019-02-13 08:26:34 +00:00
Florian Diebold
e5f9d54661 Fix another crash 2019-02-12 21:49:54 +01:00