Commit graph

378 commits

Author SHA1 Message Date
Adolfo Ochagavía
26d34cc443 Remove error publishing through publishDecorations 2018-10-10 16:49:32 +02:00
Adolfo Ochagavía
27a86cb7df Collapse comments upon join 2018-10-10 12:37:06 +02:00
bors[bot]
31c8ebb743 Merge #106
106: Add on-enter handler r=matklad a=matklad

Now, typing doc comments is much more pleasant

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2018-10-09 16:52:48 +00:00
Aleksey Kladov
2b956fd3a8 Add on-enter handler
Now, typing doc comments is much more pleasant
2018-10-09 19:52:06 +03:00
Aleksey Kladov
5d1dae83a1 Switch to absolute offsets for extend comment word 2018-10-09 18:53:35 +03:00
Aleksey Kladov
239213a3db Prepare gen_lsp_server for publishing 2018-10-09 12:55:23 +03:00
Aleksey Kladov
a05e09e9c5 Attach comments smartly 2018-10-08 17:36:38 +03:00
Aleksey Kladov
b642e6c645 replace loop with iterators 2018-10-08 15:46:14 +03:00
Aleksey Kladov
86a7ac2d31 Simplify event processing 2018-10-08 15:44:00 +03:00
Aleksey Kladov
3c12d38a32 tfn snippet 2018-10-08 14:08:31 +03:00
bors[bot]
e4fdfd1501 Merge #98
98: WIP: Add resolve_local_name to resolve names in a function scope r=kjeremy a=kjeremy

First step to resolving #80 

Co-authored-by: Jeremy A. Kolb <jkolb@ara.com>
2018-10-07 17:01:57 +00:00
Jeremy A. Kolb
ff1b2da502 Remove functional noop 2018-10-06 13:41:33 -04:00
Jeremy A. Kolb
828bd73195 Resolve local names first 2018-10-06 12:02:15 -04:00
Jeremy A. Kolb
1d4c767879 WIP: This doesn't currently work but I also don't think it's the right abstraction 2018-10-05 15:21:40 -04:00
Jeremy A. Kolb
91312a9ff9 Add resolve_local_name to resolve names in a function scope 2018-10-05 10:53:17 -04:00
Daniel McNab
80eefcbc05 Add cargo gen-kinds documentation 2018-10-04 21:43:58 +01:00
bors[bot]
81bf190f7a Merge #94
94: Extend comments by single word first r=matklad a=kjeremy

Fixes #88

Co-authored-by: Jeremy A. Kolb <jkolb@ara.com>
2018-10-04 14:25:53 +00:00
Jeremy A. Kolb
a30039ba62 Pull casts out of TextUnit 2018-10-04 09:39:02 -04:00
Jeremy A. Kolb
334d266b77 Simplify extend_single_word_in_comment 2018-10-04 09:35:55 -04:00
bors[bot]
7a025ad201 Merge #93
93: Support leading pipe in match arms r=matklad a=DJMcNab

This adds support for match arms of the form:
```rust
<...>
| X | Y => <...>,
| X => <...>,
| 1..2 => <...>,
etc
```

# Implementation discussion

This just naïvely 'eats' a leading pipe if one is available. The equivalent line in the reference `libsyntax` is in [`parse_arm`](441519536c/src/libsyntax/parse/parser.rs (L3552)).

As noted in the comment linked above, this feature was formally introduced as a result of rust-lang/rfcs#1925. This feature is in active use in the [`rust-analyzer` codebase](c87fcb4ea5/crates/ra_syntax/src/syntax_kinds/generated.rs (L231))

I have added some tests for this feature, but maybe more would be required

EDIT: Always looking for feedback - is this PR description over-engineered?

Co-authored-by: Daniel McNab <36049421+djmcnab@users.noreply.github.com>
2018-10-04 07:02:19 +00:00
Jeremy A. Kolb
4c2be06a7e Extend comments by single word first
Fixes #88
2018-10-03 17:04:00 -04:00
Daniel McNab
a55ef9b3ed Support leading pipe in match arms 2018-10-03 21:47:03 +01:00
Aleksey Kladov
1a2a8dec14 Make siblings an inherent method 2018-10-02 18:14:33 +03:00
Aleksey Kladov
d323c81d5c make ancestors and descendants inherent 2018-10-02 18:02:57 +03:00
Aleksey Kladov
dccaa5e45e use aliases 2018-10-02 17:50:56 +03:00
Aleksey Kladov
a261a1836b Move to rowan for syntax tree impl 2018-10-02 17:09:23 +03:00
Aleksey Kladov
804e29402a fix code actions 2018-09-29 21:59:34 +03:00
Aleksey Kladov
baaf027da0 support 2018 paths 2018-09-29 14:53:23 +03:00
bors[bot]
5e1d109cbb Merge #81
81: [WIP] Reject impl keyword inside impl header r=matklad a=csmoe

Closes #77 

Co-authored-by: csmoe <35686186+csmoe@users.noreply.github.com>
2018-09-26 20:14:28 +00:00
csmoe
8b710e9535 generate testsuite for impl_type 2018-09-26 16:53:16 +08:00
csmoe
edf1cc3582 parse impl type 2018-09-25 22:21:16 +08:00
Jeremy A. Kolb
4d52d004d5 Unit Tests 2018-09-24 10:48:13 -04:00
Jeremy A. Kolb
ff0a706a30 Split folding ranges into editor and lsp parts 2018-09-24 09:52:33 -04:00
csmoe
cacb32d88a reject impl keyword in impl header 2018-09-24 11:44:43 +08:00
csmoe
e446316585 add test for impl recovery 2018-09-24 11:44:43 +08:00
Jeremy A. Kolb
bd2b2f1b48 Implement folding ranges 2018-09-23 11:19:36 -04:00
Jeremy A. Kolb
e293a16d6b Support LSP 3.13 2018-09-23 11:10:57 -04:00
bors[bot]
f5808b21a4 Merge #75
75: libsyntax2 -> rust-analyzer r=matklad a=kjeremy

Change a few `libsyntax2` to `rust-analyzer`

Co-authored-by: Jeremy A. Kolb <jkolb@ara.com>
2018-09-19 10:56:31 +00:00
Aleksey Kladov
4d5cfd7229 prefer lifetimes in extend selection 2018-09-19 13:55:47 +03:00
Aleksey Kladov
d6c7030aeb Add emacs function for extend shirnk selection 2018-09-19 00:46:10 +03:00
Jeremy A. Kolb
8845b50438 libsyntax2 -> rust-analyzer 2018-09-18 17:40:33 -04:00
Aleksey Kladov
79293d2593 eprintln 2018-09-16 17:24:18 +03:00
Aleksey Kladov
b5021411a8 rename all things 2018-09-16 13:07:39 +03:00
Aleksey Kladov
ba0bfeee12 fix derecated call 2018-09-16 03:06:56 +03:00
Aleksey Kladov
5b70e5cf0c fix installation for windows 2018-09-16 00:02:25 +01:00
Aleksey Kladov
722706fe41 get rid of commandspeck 2018-09-16 02:12:53 +03:00
bors[bot]
3993bb4de9 Merge #67
67: Salsa r=matklad a=matklad

The aim of this PR is to transition from rather ad-hock FileData and ModuleMap caching strategy to something resembling a general-purpose red-green engine. 

Ideally, we shouldn't recompute ModuleMap at all, unless the set of mod decls or files changes.



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2018-09-15 21:11:25 +00:00
Aleksey Kladov
fcdf3a52b4 everysalsa 2018-09-16 00:00:05 +03:00
Aleksey Kladov
e69ff21207 kill old module_map 2018-09-16 00:00:05 +03:00
Aleksey Kladov
3ebeb0db8d move readonly source to module tree descr 2018-09-16 00:00:05 +03:00
Aleksey Kladov
58674dc3c4 ModuleTreeDescriptor 2018-09-16 00:00:05 +03:00
Aleksey Kladov
d59413c895 yet another db api 2018-09-16 00:00:05 +03:00
Aleksey Kladov
0d7b1e442d minor 2018-09-16 00:00:05 +03:00
Aleksey Kladov
47be3a3a24 renames 2018-09-16 00:00:05 +03:00
Aleksey Kladov
8c737255ff use salsa for new module map 2018-09-16 00:00:05 +03:00
Aleksey Kladov
60fdfec327 eager invalidation 2018-09-16 00:00:05 +03:00
Aleksey Kladov
cecc7ad5b2 be generic over data 2018-09-16 00:00:05 +03:00
Aleksey Kladov
8cf9c27196 generic salsa algo 2018-09-16 00:00:05 +03:00
Aleksey Kladov
0e493160c0 store params in the graph 2018-09-16 00:00:05 +03:00
Aleksey Kladov
907d44a751 any-cache 2018-09-16 00:00:05 +03:00
Aleksey Kladov
dbdf72e2e2 fix dep tracking 2018-09-16 00:00:05 +03:00
Aleksey Kladov
c81d0d51bf add deps tracking 2018-09-16 00:00:05 +03:00
Aleksey Kladov
db14b4270c Add simplisitc global modification caching 2018-09-16 00:00:05 +03:00
Aleksey Kladov
3ae3b3eb06 initial query tracing 2018-09-16 00:00:05 +03:00
Aleksey Kladov
99d02fe583 start query-based modules 2018-09-16 00:00:05 +03:00
bors[bot]
2a56b5c4f0 Merge #69
69: Incremental reparsing for single tokens  r=matklad a=darksv

Implement incremental reparsing for `WHITESPACE`, `COMMENT`, `DOC_COMMENT`, `IDENT`, `STRING` and `RAW_STRING`. This allows to avoid reparsing whole blocks when a change was made only within these tokens.

Co-authored-by: darksv <darek969-12@o2.pl>
2018-09-15 20:57:06 +00:00
darksv
ab00639032 independent tests for incremental reparsing of blocks and leaves 2018-09-15 17:05:08 +02:00
darksv
46cee0415c move reparsing tests 2018-09-15 14:35:30 +02:00
darksv
16ad5384f0 commit missing file 2018-09-15 13:42:10 +02:00
darksv
a29211918b create separated mod for reparsing functionality 2018-09-15 13:35:55 +02:00
darksv
d825cffe3b adjust trailing newline 2018-09-14 23:45:19 +02:00
darksv
ecbfe68bf4 add missing files with inline tests 2018-09-14 23:33:29 +02:00
darksv
100968b689 Support for unions 2018-09-14 22:51:12 +02:00
darksv
bc94bf95ce correctly handle IDENTs when changed to contextual keywords 2018-09-14 19:26:48 +02:00
darksv
c300135322 create leaf directly without calling the parser 2018-09-14 19:23:10 +02:00
darksv
4356240fa4 Incremental reparsing for single tokens (WHITESPACE, COMMENT, DOC_COMMENT, IDENT, STRING, RAW_STRING) 2018-09-13 23:25:05 +02:00
Aleksey Kladov
b6f8037a6f don't get stuck in slice patterns 2018-09-12 11:26:52 +03:00
Aleksey Kladov
ccc75675b6 correctly setup path-map for fs-changes 2018-09-12 11:19:19 +03:00
bors[bot]
e240360ee2 Merge #68
68: Implement incremental reparsing for remaining braced blocks r=matklad a=darksv

Fixes #66

Co-authored-by: darksv <darek969-12@o2.pl>
2018-09-11 07:32:36 +00:00
darksv
d0cfeb4f16 Do not reparse token tree when it is not delimited by braces 2018-09-10 23:21:16 +02:00
darksv
64d07c1bd4 Implement reparsing for remaining blocks 2018-09-10 20:14:09 +02:00
Aleksey Kladov
505895a25f store file rsovler 2018-09-10 12:57:40 +03:00
bors[bot]
4f64709666 Merge #65
65: simplify r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2018-09-08 16:24:24 +00:00
Aleksey Kladov
f19a82beac simplify 2018-09-08 19:16:11 +03:00
Aleksey Kladov
a5c333c3ed Fix yet another parser infinite loop
This commit is an example of fixing a common parser error: infinite
loop due to error recovery.

This error typically happens when we parse a list of items and fail to
parse a specific item at the current position.

One choices is to skip a token and try to parse a list item at the
next position. This is a good, but not universal, default. When
parsing a list of arguments in a function call, you, for example,
don't want to skip over `fn`, because it's most likely that it is a
function declaration, and not a mistyped arg:

```
fn foo() {
    quux(1, 2

fn bar() {
}
```

Another choice is to bail out of the loop immediately, but it isn't
perfect either: sometimes skipping over garbage helps:

```
quux(1, foo:, 92) // should skip over `:`, b/c that's part of `foo::bar`
```

In general, parser tries to balance these two cases, though we don't
have a definitive strategy yet.

However, if the parser accidentally neither skips over a token, nor
breaks out of the loop, then it becomes stuck in the loop infinitely
(there's an internal counter to self-check this situation and panic
though), and that's exactly what is demonstrated by the test.

To fix such situation, first of all, add the test case to tests/data/parser/{err,fuzz-failures}.

Then, run

```
RUST_BACKTRACE=short cargo test --package libsyntax2
````

to verify that parser indeed panics, and to get an idea what grammar
production is the culprit (look for `_list` functions!).

In this case, I see

```
  10: libsyntax2::grammar::expressions::atom::match_arm_list
             at crates/libsyntax2/src/grammar/expressions/atom.rs:309
```

and that's look like it might be a culprit. I verify it by adding
`eprintln!("loopy {:?}", p.current());` and indeed I see that this is
printed repeatedly.

Diagnosing this a bit shows that the problem is that
`pattern::pattern` function does not consume anything if the next
token is `let`. That is a good default to make cases like

```
let
let foo = 92;
```

where the user hasn't typed the pattern yet, to parse in a reasonable
they correctly.

For match arms, pretty much the single thing we expect is a pattern,
so, for a fix, I introduce a special variant of pattern that does not
do recovery.
2018-09-08 19:10:40 +03:00
Aleksey Kladov
3ab9f4ad7f Add fuzz failures dir 2018-09-08 18:42:59 +03:00
Aleksey Kladov
ba4a697d8c move fuzz-invariants to the library 2018-09-08 18:34:41 +03:00
Pascal Hertleif
a37cd5ad43 Add trivial fuzzer for parser
As described in #61, fuzz testing some parts of this would be ~~fun~~
helpful. So, I started with the most trivial fuzzer I could think of:
Put random stuff into File::parse and see what happens.

To speed things up, I also did

    cp src/**/*.rs fuzz/corpus/parser/

in the `crates/libsyntax2/` directory (running the fuzzer once will
generate the necessary directories).
2018-09-08 16:55:53 +02:00
Aleksey Kladov
df05c5c3e2 Don't overflow when limiting symbol search 2018-09-08 15:39:28 +03:00
Aleksey Kladov
7daaddb2ac Some abstraction around workers 2018-09-08 13:15:01 +03:00
Aleksey Kladov
326ffcefe0 Deal with deadlocks in a more principaled way 2018-09-08 12:36:02 +03:00
Aleksey Kladov
d9ccebd913 fix deadlock 2018-09-08 12:08:46 +03:00
Aleksey Kladov
f48b9d9be7 Fix block structure in enums 2018-09-08 10:55:09 +03:00
Aleksey Kladov
749907d330 simplify 2018-09-08 10:38:53 +03:00
Aleksey Kladov
febbc9acdd Don't get stuck in tuple exprs 2018-09-08 10:35:05 +03:00
Aleksey Kladov
a0a347eac9 Don't get stuck in macros 2018-09-08 10:28:53 +03:00
Aleksey Kladov
bd3a26493f fix stuck parser 2018-09-08 10:13:32 +03:00
Aleksey Kladov
44334f6f56 fix labled expressions 2018-09-08 09:18:42 +03:00
Aleksey Kladov
127814d9a7 nested mod completion 2018-09-08 01:35:20 +03:00
Aleksey Kladov
ff1c82216c Remove dyn dispatch 2018-09-08 01:16:07 +03:00