Commit Graph

2159 Commits

Author SHA1 Message Date
pcpthm
e734190c24 Refactor parser fuzz testing 2019-03-22 08:04:48 +09: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
bors[bot]
aa0cc0c609 Merge #1002
1002: Fill partial fields r=matklad a=c410-f3r

Fixes #992 

Co-authored-by: Caio <c410.f3r@gmail.com>
2019-03-21 11:03:15 +00:00
bors[bot]
b038832795 Merge #997
997: Improve filtering of file roots r=matklad a=vipentti

`ProjectWorkspace::to_roots` now returns a new `ProjectRoot` which contains
information regarding whether or not the given path is part of the current
workspace or an external dependency. This information can then be used in
`ra_batch` and `ra_lsp_server` to implement more advanced filtering. This allows
us to filter some unnecessary folders from external dependencies such as tests,
examples and benches.

Relates to discussion in #869 

Co-authored-by: Ville Penttinen <villem.penttinen@gmail.com>
2019-03-21 10:56:05 +00:00
Ville Penttinen
c6d6e6c625 Move actual include logic to ProjectRoot
This way the two IncludeRustFiles implementations can simply call the
ProjectRoots' methods, so that the include logic is in one place.
2019-03-21 10:43:47 +02:00
Caio
99c45609ef Improve performance and ordering 2019-03-20 20:31:14 -03:00
bors[bot]
1eb3bf41d7 Merge #1003
1003: make Name::new private r=flodiebold a=matklad

This maybe is overengineering, but it seems cool to keep names completely opaque.

r? @flodiebold 

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-03-20 22:08:30 +00: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
Caio
ba6863754e Fill partial fields 2019-03-20 16:52:29 -03:00
Aleksey Kladov
f5165af9a7 make Name::new private 2019-03-20 22:33:26 +03:00
Ville Penttinen
e32462c6d5 Improve filtering of file roots
`ProjectWorkspace::to_roots` now returns a new `ProjectRoot` which contains
information regarding whether or not the given path is part of the current
workspace or an external dependency. This information can then be used in
`ra_batch` and `ra_lsp_server` to implement more advanced filtering. This allows
us to filter some unnecessary folders from external dependencies such as tests,
examples and benches.
2019-03-20 11:55:38 +02:00
Vincent Esche
21f20d5deb Fixed typo in Interner’s name (Intener) 2019-03-20 09:29:10 +01:00
bors[bot]
d080c8f021 Merge #998
998: import resolution is immutable r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-03-19 15:35:32 +00:00
Aleksey Kladov
5641feeddb import resolution is immutable 2019-03-19 18:35:03 +03:00
bors[bot]
5b6ad0971c Merge #996
996: Allow attributes on top level expressions r=matklad a=pcpthm

This PR modifies parser to allow outer attributes on top level expression. Here, top level expression means either
- Expression statement e.g. `foo();`
- Last expression in a block without semicolon `bar()` in `{ foo(); bar() }`.

Except for binary operation expressions and `if` expressions, which are errors (feature gated) in rustc.
Attributes on inner expressions like `foo(#[a] 1)` are not implemented.

I first tried to implement this by passing `Maker` to expression parsers. However, this implementation couldn't parse `#[attr] foo()` correctly as `CallExpr(Attr(..), PathExpr(..), ArgList(..))` and instead parsed incorrectly as `CallExpr(PathExpr(Attr(..), ..), ArgList(..))` due to the way left recursion is handled.
In the end, I introduce `undo_completion` method. Which is not the suggested approach, but it seems not very bad.

Fix #759.


Co-authored-by: pcpthm <pcpthm@gmail.com>
2019-03-19 10:36:17 +00:00
pcpthm
4cf179c089 Replace contract_child to a less ad-hoc API 2019-03-19 18:44:23 +09:00
pcpthm
e2ed813e89 Mark non-code block as text 2019-03-19 18:12:05 +09:00
pcpthm
2fb110e1fa Error about attributes on
unallowed types of expression statement
2019-03-19 17:37:08 +09:00
pcpthm
ffed132e52 Allow attributes on top level expression
A top level expression is either
- a expression statement or
- the last expression in a block
2019-03-19 17:24:02 +09:00
bors[bot]
7fc35d391c Merge #993
993: Fix installing vscode extension on MacOS r=matklad a=funkill

VSCode often installed in MacOS as `Visual Studio Code.app` package and `code` binary located at `Contents/Resources/app/bin` in package. This path not exists in `$PATH` variable and we can't run `code`.

In previous version of `do_run` function all before space was command and all after - arguments. If path or command has spaces, extracting command breaks. To fix this i extracted command to separated argument of function.

All packages can be placed in system app dir (`/Applications`) or user app dir (`~/Applications`). I created helper function for find app in this directories.



Co-authored-by: funkill2 <funkill2@gmail.com>
2019-03-18 19:26:45 +00:00
funkill2
69edc10f35
set code less generic 2019-03-18 22:18:54 +03:00
Ville Penttinen
e70e2361b6 Upgrade ra_vfs to use new Filtering
Currently this matches the previous filtering, meaning all roots are filtered
using the same rules.
2019-03-18 20:53:08 +02:00
funkill2
9c2177026f
added setup environment 2019-03-18 20:27:31 +03:00
funkill2
d8f3b0d01d
added helper module for appending vscode path 2019-03-18 20:27:11 +03:00
bors[bot]
1cd18f9237 Merge #991
991: Use Marker argument for item parsers r=matklad a=pcpthm

Before doing this for expressions, I found that the pattern (Marker argument) should be applied to the item parsers because visiblity and modifiers are parsed in a separate function.

Fixed some parser bugs:
- Fix pub_expr: `pub 42;` was allowed.
- Fix incorrect parsing of crate::path: incorrectly parsed as `crate` as a visibility.

Co-authored-by: pcpthm <pcpthm@gmail.com>
2019-03-18 09:32:28 +00:00
bors[bot]
7c117567ab Merge #989
989: Implement naive version of fill_struct_fields assist r=matklad a=yanchith

Fixes #964

This implements the `fill_struct_fields` assist. Currently only works for named struct fields, but not for tuple structs, because we seem to be missing a `TupleStructLit` (akin to `StructLit`, but for tuple structs). I am happy to implement `TupleStructLit` parsing given some guidance (provided it's really missing) and make the assist work for tuple structs as well. Could do so either in this PR, or another one 🙂 

Sorry if I missed something important, this is my first PR for Rust Analyzer.

Btw is there any way to run the assists in emacs?

UPDATE: I just realized that parsing `TupleStructLit` would be quite difficult as it it really similar, if not identical to a function call...

Co-authored-by: yanchith <yanchi.toth@gmail.com>
2019-03-18 08:24:18 +00:00
yanchith
ca262fbab8 Only replace NamedFieldList and add test for preserving Self 2019-03-18 09:03:10 +01:00
yanchith
8d47e004b8 Remove unachievable TODO 2019-03-18 08:19:51 +01:00
pcpthm
76075c7410 Use Marker argument for item parsers
- Fix pub_expr
- Fix incorrect parsing of crate::path
2019-03-18 14:34:08 +09:00
bors[bot]
4c1ea0b628 Merge #987
987: Refactor maybe_item to use Marker argument r=pcpthm a=pcpthm

As suggested at <https://github.com/rust-analyzer/rust-analyzer/pull/980#issuecomment-473659745>.
For expression paring functions, changing signature
- from `fn(&mut Parser) -> Option<CompletedMarker>` to `fn(&mut Parser, Marker) -> Result<CompletedMarker, Marker>`
- from `fn(&mut Parser) -> CompletedMarker` to `fn(&mut Parser, Marker) -> CompletedMarker`
is my plan.

Co-authored-by: pcpthm <pcpthm@gmail.com>
2019-03-18 04:16:20 +00:00
pcpthm
3d9c2beb8e Apply stylistic changes suggested 2019-03-18 13:14:47 +09:00
bors[bot]
40c6dd1f4c Merge #982
982: Implement BindingMode for pattern matching. r=flodiebold a=mjkillough

Implement `BindingMode` for pattern matching, so that types can be
correctly inferred using match ergonomics. The binding mode defaults to
`Move` (referred to as 'BindingMode::BindByValue` in rustc), and is
updated by automatic dereferencing of the value being matched.

Fixes #888.

 - [Binding modes in The Reference](https://doc.rust-lang.org/reference/patterns.html#binding-modes)
 - [`rustc` implementation](e17c48e2f2/src/librustc_typeck/check/_match.rs (L77)) (and [definition of `BindingMode`](e957ed9d10/src/librustc/ty/binding.rs))
 - [Match Ergonomics RFC](https://github.com/rust-lang/rfcs/blob/master/text/2005-match-ergonomics.md#binding-mode-rules)

Co-authored-by: Michael Killough <michaeljkillough@gmail.com>
2019-03-17 21:41:37 +00:00
Michael Killough
6299ccd350 Split test case and use tested_by!. 2019-03-17 19:08:51 +00:00
Michael Killough
33add0ee30 Simplify match statement. 2019-03-17 18:50:22 +00:00
yanchith
907f7307af Implement naive version of fill_struct_fields assist 2019-03-17 19:48:25 +01:00
Michael Killough
354134ffb4 impl Default for BindingMode.
This decouples callers from knowing what the default binding mode of
pattern matching is.
2019-03-17 18:46:01 +00:00
bors[bot]
91e7a3b6f2 Merge #983
983: support remainder assignment operator r=matklad a=JeanMertz

`%=` was returning errors for me, turns out it wasn't added as a valid assignment operation.

I'm not sure what the best location would be to add a test for this. Please let me know and I'll add one.

Co-authored-by: Jean Mertz <jean@mertz.fm>
2019-03-17 14:34:14 +00:00
Jean Mertz
a8ee994ae0
support remainder assignment operator 2019-03-17 14:11:24 +01:00
pcpthm
e570267515 Refactor maybe_item to use Marker argument 2019-03-17 22:04:25 +09:00
pcpthm
a67fe4ea7e Fix parse tree of attribute on match arm 2019-03-17 20:57:27 +09:00
bors[bot]
aea9c98f53 Merge #985
985: simplify parsing blocks a bit r=pcpthm a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-03-17 10:26:45 +00:00
Aleksey Kladov
a8271cb31f simplify parsing blocks a bit 2019-03-17 13:14:17 +03:00
pcpthm
a1d84f5fb0 Allow attribute on struct literal field 2019-03-17 19:08:35 +09:00
Aleksey Kladov
3a77023365 docs 2019-03-17 12:53:22 +03:00
Aleksey Kladov
4d7fa6d30b remove fixme 2019-03-17 12:53:22 +03:00
Aleksey Kladov
6955e392f8 remove old macro support 2019-03-17 12:53:22 +03:00
Aleksey Kladov
ee3cf6172b rename ModuleId -> CrateModuleId 2019-03-17 12:53:22 +03:00
Aleksey Kladov
c51a6a7bdd fix error on wrong path 2019-03-17 12:53:22 +03:00