Commit Graph

7516 Commits

Author SHA1 Message Date
Veetaha
8153b60e1d vscode: eliminate floating promises and insane amount of resource handle leaks 2020-02-05 22:39:47 +02:00
bors[bot]
2471b6bc3a
Merge #3015
3015: vscode: yet another refactor commit r=matklad a=Veetaha

It compiles, it runs in dev extension host, It bundles, it runs when bundled and installed.
Removed 5 lines of code as you like less code, especially TypeScript code)

Co-authored-by: Veetaha <gerzoh1@gmail.com>
2020-02-05 20:29:50 +00:00
Veetaha
49a6814048 vscode: removed changes to integrity hash in package-lock.json 2020-02-05 21:38:19 +02:00
bors[bot]
8d0f7da2f5
Merge #3018
3018: Refactor if-let -> match assist to use ast::make r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-02-05 13:20:32 +00:00
Aleksey Kladov
a4c6e8c4e2 Refactor if-let -> match assist to use ast::make 2020-02-05 14:08:16 +01:00
bors[bot]
83dc22e1fb
Merge #3019
3019: Better cursor placement when merging arms r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-02-05 12:44:00 +00:00
Aleksey Kladov
f756d5da06 Better cursor placement when merging arms 2020-02-05 13:41:43 +01:00
bors[bot]
1b1bca4567
Merge #3016
3016: Fix unneeded `.` in `docs/user/README.md` r=kjeremy a=fusillicode

I hope I got the typo right 😅 

Thanks a lot of this wonderful project 🙇 

Co-authored-by: Gian D <fusillicode@users.noreply.github.com>
2020-02-05 12:32:59 +00:00
Aleksey Kladov
28acd01c63 Merge match arms works with many arms 2020-02-05 12:26:43 +01:00
bors[bot]
514ff113cb
Merge #3017
3017: Normalize dashes in crate names r=matklad a=SomeoneToIgnore

A follow-up for https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/Yet.20another.20auto.20import.20bug

In theory, I could have used the same new type in the `Dependency` `name`  field, but since the `add_dep` method that actually adds a dependency is private, it seems like an unnecessary change now.

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-02-05 10:49:25 +00:00
Kirill Bulatov
78092c7c66 Apply the reviews suggestions 2020-02-05 12:47:28 +02:00
Aleksey Kladov
45dd90b0e8 Cleanup 2020-02-05 11:46:05 +01:00
Gian D
0ef96f982c
Further fix docs/user/README.md
Co-Authored-By: Laurențiu Nicola <lnicola@users.noreply.github.com>
2020-02-05 11:09:08 +01:00
Kirill Bulatov
2b9952625b Normalize dashes in crate names 2020-02-05 11:53:54 +02:00
Gian D
13211ed701
Fix unneeded . in docs/user/README.md 2020-02-05 10:38:53 +01:00
Veetaha
b89b22e43e vscode: yet another refactor commit 2020-02-05 00:13:46 +02:00
bors[bot]
c9e1aab880
Merge #2948
2948: Allow add_explicit_type to replace a placeholder type r=matklad a=lnicola



Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-02-04 16:12:05 +00:00
bors[bot]
9f580825b8
Merge #3011
3011: Update aho-corasick (removes unsafety) and serde_json r=matklad a=kjeremy



Co-authored-by: kjeremy <kjeremy@gmail.com>
2020-02-04 15:39:22 +00:00
kjeremy
793eb51b3b Update aho-corasick (removes unsafety) and serde_json 2020-02-04 10:37:01 -05:00
bors[bot]
2cfba36deb
Merge #3010
3010: minor, if let else -> match r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-02-04 12:42:32 +00:00
Aleksey Kladov
f5a20014ce minor, if let else -> match 2020-02-04 13:41:56 +01:00
bors[bot]
1f7a54cfa7
Merge #3009
3009: Make sure that newly created nodes are the root of the tree r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-02-04 12:23:37 +00:00
Aleksey Kladov
4ea0c12cf1 Make sure that newly created nodes are the root of the tree 2020-02-04 13:22:32 +01:00
bors[bot]
c1a06499fa
Merge #2981
2981: vscode: Add ability to call onEnter without overriding "type". r=matklad a=71

Before this PR, the only way to get enhanced typing (right now, only with `onEnter`) was to override VS Code's `type` command. This leads to issues with extensions like [VsCodeVim](https://github.com/VSCodeVim/Vim) that need to override `type` as well.

This PR adds an additional command, `onEnter`. This command can be used with the following keybinding, which allows the user to get smart `onEnter` behavior without overriding `type`.

```json
{
    "key": "enter",
    "command": "rust-analyzer.onEnter",
    "when": "editorTextFocus && editorLangId == rust"
}
```

Co-authored-by: Gregoire Geis <git@gregoirege.is>
Co-authored-by: Grégoire Geis <git@gregoirege.is>
2020-02-04 09:52:57 +00:00
bors[bot]
73c36fdbd2
Merge #2962
2962: Differentiate underscore alias from named aliases r=matklad a=zombiefungus

pre for Fixing Issue 2736 
edited to avoid autoclosing the issue

Co-authored-by: zombiefungus <divmermarlav@gmail.com>
2020-02-04 09:44:31 +00:00
Grégoire Geis
875dc6d1a4
Merge two if statements into one in editors/code/src/commands/on_enter.ts.
Co-Authored-By: Veetaha <veetaha2@gmail.com>
2020-02-04 01:44:12 +01:00
bors[bot]
918547dbe9
Merge #2911
2911: Implement collecting errors while tokenizing r=matklad a=Veetaha

Now we are collecting errors from `rustc_lexer` and returning them in `ParsedToken { token, error }` and `ParsedTokens { tokens, errors }` structures **([UPD]: this is now simplified, see updates bellow)**.

The main changes are introduced in `ra_syntax/parsing/lexer.rs`. It now exposes the following functions and types:

```rust
pub fn tokenize(text: &str) -> ParsedTokens;
pub fn tokenize_append(text: &str, parsed_tokens_to_append_to: &mut ParsedTokens);
pub fn first_token(text: &str) -> Option<ParsedToken>; // allows any number of tokens in text
pub fn single_token(text: &str) -> Option<ParsedToken>; // allows only a single token in text

pub struct ParsedToken  { pub token: Token,       pub error: Option<SyntaxError> }
pub struct ParsedTokens { pub tokens: Vec<Token>, pub errors: Vec<SyntaxError>   }

pub enum TokenizeError { /* Simple enum which reflects rustc_lexer tokenization errors */ }
```
In the first commit I implemented it with iterators, but then decided that since this crate is ad hoc for `rust-analyzer` and we clearly see the places of its usage it would be better to simplify it to vectors.

This is currently WIP, because I want to add tests for error messages generated by the lexer.
I'd like to listen to you thoughts how to define these tests in `ra_syntax/test-data` dir.

Related issues: #223 

**[UPD]**

After the PR review the API was simplified:
```rust
pub fn tokenize(text: &str) -> (Vec<Token>, Vec<SyntaxError>);
// Both lex functions do not check for unescape errors
pub fn lex_single_syntax_kind(text: &str) -> Option<(SyntaxKind, Option<SyntaxError>)>;
pub fn lex_single_valid_syntax_kind(text: &str) -> Option<SyntaxKind>;

// This will be removed in the next PR in favour of simlifying `SyntaxError` to `(String, TextRange)`
pub enum TokenizeError { /* Simple enum which reflects rustc_lexer tokenization errors */ }

// this is private, but may be made public if such demand would exist in future (least privilege principle)
fn lex_first_token(text: &str) -> Option<(Token, Option<SyntaxError>)>;
```

Co-authored-by: Veetaha <gerzoh1@gmail.com>
2020-02-03 22:51:17 +00:00
Veetaha
a3e5663ae0 ra_syntax: added tests for tokenization errors 2020-02-04 00:00:55 +02:00
Veetaha
9367b9a292 ra_syntax: add backticks around tokens specimen 2020-02-04 00:00:55 +02:00
Veetaha
c3117eea31 ra_syntax: removed unnecessary init statement from reparsing tests 2020-02-04 00:00:55 +02:00
Veetaha
58e01d8754 ra_syntax: rename first_token() -> lex_first_token() 2020-02-04 00:00:55 +02:00
Veetaha
b1764d85fc ra_syntax: fixed a typo in doc comment 2020-02-04 00:00:55 +02:00
Veetaha
9e7eaa959f ra_syntax: refactored the lexer design as per @matklad and @kiljacken PR review 2020-02-04 00:00:55 +02:00
Veetaha
bf60661aa3 ra_syntax: remove backticks from TokenizeError message since that is not Markdown ;( 2020-02-04 00:00:55 +02:00
Veetaha
c6d0881382 add better docs for tokenize errors 2020-02-04 00:00:55 +02:00
Veetaha
ffe00631d5 ra_syntax: moved ParsedToken derive attribute under the doc comment 2020-02-04 00:00:55 +02:00
Veetaha
a2bc4c2a74 ra_syntax: fixed doc comment 2020-02-04 00:00:55 +02:00
Veetaha
ac37a11f04 Reimplemented lexer with vectors instead of iterators 2020-02-04 00:00:55 +02:00
Veetaha
ad24976da3 ra_syntax: changed added diagnostics information returned from tokenize() (implemented with iterators) 2020-02-04 00:00:55 +02:00
Gregoire Geis
7fd661f085 vscode: Only handle enter if the suggest widget is hidden. 2020-02-03 22:26:20 +01:00
Gregoire Geis
b70ad7e5f3 Remove enableEnhancedTyping and type overriding infrastructure. 2020-02-03 20:24:50 +01:00
Gregoire Geis
58c007674b Change default enhanced typing behavior from using type to using keybindings. 2020-02-03 20:18:11 +01:00
Gregoire Geis
23ef22dd48 Add regular onEnter command, allowing onEnter to be called without overriding the type command. 2020-02-03 20:18:10 +01:00
bors[bot]
b090ee5a65
Merge #3003
3003: Remove rollup-typescript r=matklad a=matklad

It seems like just calling typescript directly is simpler and more reliable?


@Veetaha what do you think about this approach?

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-02-03 17:11:36 +00:00
Aleksey Kladov
f0323de7e8 Remove unnecessary flags 2020-02-03 18:05:54 +01:00
Aleksey Kladov
9b8e3b80ee Remove rollup-typescript
It seems like just calling typescript directly is simpler and more reliable?
2020-02-03 17:39:34 +01:00
bors[bot]
8d18b151e4
Merge #3002
3002: Update some rollup packages r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-02-03 15:49:56 +00:00
Aleksey Kladov
0a68dfb491 Update some rollup packages 2020-02-03 16:49:25 +01:00
bors[bot]
35e0c706d8
Merge #3001
3001: Use simple prng instead of a dependency r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-02-03 15:38:27 +00:00
Aleksey Kladov
ad57726f91 Use simple prng instead of a dependency
closes #2999
2020-02-03 16:37:12 +01:00