Commit graph

5080 commits

Author SHA1 Message Date
bors[bot]
c447fe9bc0
Merge #3026
3026: ra_syntax: reshape SyntaxError for the sake of removing redundancy r=matklad a=Veetaha

Followup of #2911, also puts some crosses to the todo list of #223.

**AHTUNG!** A big part of the diff of this PR are test data files changes.

Simplified `SyntaxError` that was `SyntaxError { kind: { /* big enum */  }, location: Location }` to `SyntaxError(String, TextRange)`. I am not sure whether the tuple struct here is best fit, I am inclined to add names to the fields, because I already provide getters `SyntaxError::message()`, `SyntaxError::range()`.
I also removed `Location` altogether ...

This is currently WIP, because the following is not done:
- [ ] ~~Add tests to `test_data` dir for unescape errors *// I don't know where to put these errors in particular, because they are out of the scope of the lexer and parser. However, I have an idea in mind that we move all validators we have right now to parsing stage, but this is up to discussion...*~~ **[UPD]** I came to a conclusion that tree validation logic, which unescape errors are a part of, should be rethought of, we currently have no tests and no place to put tests for tree validations. So I'd like to extract potential redesign (maybe move of tree validation to ra_parser) and adding tests for this into a separate task.

Co-authored-by: Veetaha <gerzoh1@gmail.com>
Co-authored-by: Veetaha <veetaha2@gmail.com>
2020-02-18 12:57:26 +00:00
Aleksey Kladov
865759925b Rename folder 2020-02-18 12:37:45 +01:00
Aleksey Kladov
c0fa5e2246 Rename the binary to rust-analyzer 2020-02-18 12:33:16 +01:00
Aleksey Kladov
4d307ff802 Fully document ra_lsp_server 2020-02-18 12:25:26 +01:00
Aleksey Kladov
1f142d79ed Refactor 2020-02-18 12:17:47 +01:00
Aleksey Kladov
42c766b2bd Reduce visibility 2020-02-18 12:16:40 +01:00
Aleksey Kladov
b6740060f6 Refactor 2020-02-18 12:15:12 +01:00
Aleksey Kladov
93b969003d Some docs 2020-02-18 12:11:32 +01:00
Aleksey Kladov
59e1207dac Better folder structure 2020-02-18 11:56:18 +01:00
Veetaha
053ccf4121 ra_syntax: fix reparsing merging errors, also now reparse_token() reports errors 2020-02-18 02:11:16 +02:00
Kirill Bulatov
e29dbdb139 Simplify the command execution 2020-02-18 00:38:01 +02:00
Kirill Bulatov
67d30312d0 Simplify the code further 2020-02-18 00:18:26 +02:00
Kirill Bulatov
addb61df36 Idempotent location and installation of rust src 2020-02-18 00:07:15 +02:00
Kirill Bulatov
5cea8a37b7 Install rust-src when it is not found 2020-02-17 23:40:34 +02:00
Veetaha
fc5e7b8807 ra_syntax: migrate test data to 0-length text-range of SyntaxError when constructed from TextUnit 2020-02-17 23:14:31 +02:00
Veetaha
cd8e56c580 ra_syntax: remove message() method and use only Display trait in SyntaxError as per matklad 2020-02-17 23:13:38 +02:00
Veetaha
e05eb631d4 ra_syntax: change module-level documentation for syntax_error to "see X" as per matklad 2020-02-17 22:50:58 +02:00
Veetaha
b510e77fbe ra_syntax: followup fix for making SyntaxError::range() to return by value 2020-02-17 22:24:38 +02:00
Veetaha
e00922d113 ra_syntax: SyntaxError::range() now returns by value 2020-02-17 22:24:38 +02:00
Veetaha
acdab6f0f2 ra_syntax: moved reexport declaration after imports as per matklad 2020-02-17 22:24:38 +02:00
Veetaha
6ae4850c89 ra_syntax: Apply Aleksei Kladov suggestion about TextRange of TextUnit
Co-Authored-By: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-02-17 22:24:33 +02:00
Veetaha
c58276673a Change semmantical analyzis to tree validation as per @matklad
Co-Authored-By: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-02-17 22:24:33 +02:00
Veetaha
9fdf984958 ra_syntax: reshape SyntaxError for the sake of removing redundancy 2020-02-17 22:24:33 +02:00
Laurențiu Nicola
b6b8fd9525 Replace ra_cli mentions 2020-02-17 22:07:24 +02:00
Aleksey Kladov
2c9b91ad32 Merge ra_vfs_glob and ra_lsp_server 2020-02-17 19:07:30 +01:00
Aleksey Kladov
659b0e73cf Merge cli and ra_lsp_server 2020-02-17 19:03:03 +01:00
Aleksey Kladov
2d1b3da5fb Use anyhow 2020-02-17 18:19:25 +01:00
Aleksey Kladov
8e86d12771 Cleanup 2020-02-17 18:15:19 +01:00
Aleksey Kladov
06e37b273e Better name 2020-02-17 18:10:15 +01:00
Aleksey Kladov
3ef916061b More precise types 2020-02-17 18:09:07 +01:00
Aleksey Kladov
c818f5c65e Unify verbosity handling 2020-02-17 18:05:45 +01:00
Aleksey Kladov
fa482a9fee Move interesting stuff to main 2020-02-17 18:03:48 +01:00
Aleksey Kladov
a51b2603f9 Stronger Types 2020-02-17 18:02:59 +01:00
Aleksey Kladov
017f0e4e53 Refactor arg parsing 2020-02-17 18:02:10 +01:00
Aleksey Kladov
90e61ac75d Sort deps 2020-02-17 17:41:53 +01:00
Aleksey Kladov
d7be1da8df Inline ra_batch 2020-02-17 17:32:17 +01:00
Aleksey Kladov
559c5f37f6 Cleanup imports 2020-02-17 17:19:55 +01:00
Aleksey Kladov
d5371b5dec Inline help 2020-02-17 17:18:45 +01:00
Aleksey Kladov
0353e1c6f4 Use Arguments::from_os 2020-02-17 17:12:37 +01:00
Aleksey Kladov
57140f1730 Drop proptest tests
It takes waaay to long to compile.

We should add quickcheck tests when we touch the relevant code next
time.
2020-02-17 16:57:06 +01:00
bors[bot]
fcf15cc05a
Merge #3169
3169: Show record field names in Enum completion r=flodiebold a=adamrk

Adresses https://github.com/rust-analyzer/rust-analyzer/issues/2947.
Previously the details shown when autocompleting an Enum variant would look like the variant was a tuple even if it was a record:
![2020-02-16-15:59:32_crop](https://user-images.githubusercontent.com/16367467/74607233-64f21980-50d7-11ea-99db-e973e29c71d7.png)

This change will show the names of the fields for a record and use curly braces instead of parentheses:
![2020-02-16-15:33:00_crop](https://user-images.githubusercontent.com/16367467/74607251-8ce17d00-50d7-11ea-9d4d-38d198a4aec0.png)

This required exposing the type `adt::StructKind` from `ra_hir` and adding a function 
```
kind(self, db: &impl HirDatabase) -> StructKind
```
in the `impl` of `EnumVariant`. 

There was also a previously existing function `is_unit(self, db: &impl HirDatabase) -> bool` for `EnumVariant` which I removed because it seemed redundant after adding `kind`.

Co-authored-by: adamrk <ark.email@gmail.com>
2020-02-17 10:54:32 +00:00
adamrk
0e260aa6b1 use 'if let' instead of match on kind in lower.rs 2020-02-17 11:53:12 +01:00
bors[bot]
93d28fb50c
Merge #3099
3099: Init implementation of structural search replace r=matklad a=mikhail-m1

next steps:
* ignore space and other minor difference
* add support to ra_cli
* call rust parser to check pattern
* documentation

original issue #2267 

Co-authored-by: Mikhail Modin <mikhailm1@gmail.com>
2020-02-17 10:02:54 +00:00
bors[bot]
8d8d542dfa
Merge #3108
3108: Magic Completion for `impl Trait for` Associated Items r=matklad a=kdelorey

# Summary
This PR adds a set of magic completions to auto complete associated trait items (functions/consts/types). 

![Associated Trait Impl](https://user-images.githubusercontent.com/2295721/74493144-d8f1af00-4e96-11ea-93a4-82725bf89646.gif)

## Notes
Since the assist and completion share the same logic when figuring out the associated items that are missing, a shared utility was created in the `ra_assists::utils` module.

Resolves #1046 

As this is my first PR to the rust-analyzer project, I'm new to the codebase, feedback welcomed!

Co-authored-by: Kevin DeLorey <2295721+kdelorey@users.noreply.github.com>
2020-02-17 09:34:08 +00:00
bors[bot]
953dbe3e02
Merge #3181
3181: Add ability to pass additional arguments to rustfmt. r=matklad a=Leonqn

relates to #2848

Co-authored-by: Ilya Titkov <ilya@titkov.me>
2020-02-17 09:05:01 +00:00
bors[bot]
c9989a524c
Merge #3153
3153: When a single test is run, do not run others with overlapping names r=matklad a=SomeoneToIgnore



Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-02-17 08:52:45 +00:00
Ilya Titkov
a2b0bdcc24 Add arguments to rustfmt 2020-02-17 11:44:58 +03:00
bors[bot]
daffdd8674
Merge #3179
3179: Introduce AsMacroCall trait r=matklad a=edwin0cheng

This PR introduce `AsMacroCall` trait to help convert `ast::MacroCall` to `MacroCallId`. The main goal here is to centralize various conversions to single place and make implementing eager macro calls without further ado.

```rust
pub trait AsMacroCall {
    fn as_call_id(
        &self,
        db: &(impl db::DefDatabase + AstDatabase),
        resolver: impl Fn(path::ModPath) -> Option<MacroDefId>,
    ) -> Option<MacroCallId>;
}
```

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-02-17 08:38:09 +00:00
Edwin Cheng
2d4e79e1e6 Introduce AsMacroCall trait 2020-02-17 12:57:24 +08:00
Aleksey Kladov
ca7e9ab0da 1-based columns 2020-02-16 18:30:48 +01:00