Commit Graph

7449 Commits

Author SHA1 Message Date
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
bors[bot]
056a01502b
Merge #2997
2997: Use proper import name in the label r=matklad a=SomeoneToIgnore



Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-02-03 14:34:16 +00:00
bors[bot]
c57ed0cfb2
Merge #2998
2998: Remove recent improvements to the build script r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-02-03 14:26:22 +00:00
Aleksey Kladov
30f7e6590a Remove recent improvements to the build script
tslib as a dev dependency and commonjs modules are definitely *wrong*
in the ideal world, **but** in the real world that's the only
combination that works. See

https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/Problems.20with.20TypeScript.20build
2020-02-03 15:25:29 +01:00
Kirill Bulatov
bfbc5e2d37 Use proper import name in the label 2020-02-03 15:44:28 +02:00
bors[bot]
834fcecd31
Merge #2994
2994: Small cleanup r=matklad a=SomeoneToIgnore

A follow-up to https://github.com/rust-analyzer/rust-analyzer/pull/2990#discussion_r374044482

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-02-03 13:01:58 +00:00
bors[bot]
d828ea5351
Merge #2995
2995: Fix build of typscript extension r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-02-03 12:54:44 +00:00
Aleksey Kladov
ae42cfefbf Fix build of typscript extension 2020-02-03 13:54:12 +01:00
Kirill Bulatov
4f27155d5c Simplify paths searches 2020-02-03 13:56:03 +02:00
Kirill Bulatov
fcf5bbbbeb Fix inlay hints test snippet compilation 2020-02-03 13:35:14 +02:00
bors[bot]
d400fde66c
Merge #2959
2959: Rework how we send diagnostics to client r=matklad a=kiljacken

The previous way of sending from the thread pool suffered from stale diagnostics due to being canceled before we could clear the old ones.

The key change is moving to sending diagnostics from the main loop thread, but doing all the hard work in the thread pool. This should provide the best of both worlds, with little to no of the downsides.

This should hopefully fix a lot of issues, but we'll need testing in each individual issue to be sure.

Co-authored-by: Emil Lauridsen <mine809@gmail.com>
2020-02-03 11:27:31 +00:00
Emil Lauridsen
9f70f443a3 Update snapshot tests due to removed SuggestedFix 2020-02-03 12:24:57 +01:00
Emil Lauridsen
cde20bf8f0 Remove stray todo 2020-02-03 12:18:06 +01:00
bors[bot]
5b1b2cac39
Merge #2990
2990: Use name only when searching for an import candidate r=me a=SomeoneToIgnore



Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-02-03 11:10:55 +00:00
Laurențiu Nicola
e0c7ce8417 Allow add_explicit_type to replace a placeholder type 2020-02-03 13:09:38 +02:00
Emil Lauridsen
790788d5f4 Rework how we send diagnostics to client.
The previous way of sending from the thread pool suffered from stale
diagnostics due to being canceled before we could clear the old ones.

The key change is moving to sending diagnostics from the main loop
thread, but doing all the hard work in the thread pool. This should
provide the best of both worlds, with little to no of the downsides.

This should hopefully fix a lot of issues, but we'll need testing in
each individual issue to be sure.
2020-02-03 11:34:24 +01:00
bors[bot]
52456c4490
Merge #2993
2993: vscode: fix bundling by switching to es2015 target modules system r=matklad a=Veetaha

Quick fix

Co-authored-by: Veetaha <gerzoh1@gmail.com>
2020-02-03 08:54:04 +00:00
Veetaha
8f25408a12 vscode: fix bundling by switching to es2015 target modules system 2020-02-03 10:50:19 +02:00