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>
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>
`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.
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>
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>
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>
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>
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>
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>