Commit graph

2695 commits

Author SHA1 Message Date
Aleksey Kladov
2e3f5af9d4 move mbe to the new API 2019-05-28 17:39:01 +03:00
Aleksey Kladov
0efbcdf435 remove old parsing methods 2019-05-28 17:34:28 +03:00
Aleksey Kladov
310bfe57bd update test data 2019-05-28 17:09:45 +03:00
Aleksey Kladov
bc2550b196 update tests 2019-05-28 16:59:22 +03:00
Aleksey Kladov
afeaea7051 drop error from SOurceFile constructor 2019-05-28 16:34:23 +03:00
Aleksey Kladov
1cece9f219 return errors from tree builder 2019-05-28 16:26:14 +03:00
Aleksey Kladov
90926b9479 drop errors from SyntaxNode 2019-05-28 16:15:17 +03:00
Aleksey Kladov
f52eda675e add Parse 2019-05-28 16:15:17 +03:00
bors[bot]
0545e4781d Merge #1336
1336: Refactor SubtreeSource r=matklad a=edwin0cheng

This PR simplify `SubtreeSource` by removing `SubtreeWalk` and `Querier` and only walk through the top level `TokenTree` when collecting token from source, by comparing two cursors directly.

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-05-28 06:03:47 +00:00
Edwin Cheng
464a00814c Use cfg(test) instead of allow(unused) 2019-05-28 10:55:08 +08:00
Edwin Cheng
a3b9aecc9b Minor use module 2019-05-28 00:54:32 +08:00
Edwin Cheng
98aac6b751 Simpliy how collecting token from src 2019-05-28 00:38:55 +08:00
Edwin Cheng
c8c9230dd2 Add more helper func in Cursor 2019-05-27 23:51:52 +08:00
Edwin Cheng
d833ded3b4 Remove Queier and SubtreeWalk 2019-05-27 23:20:43 +08:00
bors[bot]
b2bf41b2ba Merge #1334
1334: check for cancellation during macro expansion r=matklad a=matklad

closes #1331

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-05-27 11:45:41 +00:00
Aleksey Kladov
a2845bb1f5 check cancellation when expanding macros 2019-05-27 14:41:14 +03:00
Aleksey Kladov
0d2f97e83e specifically profile cancellation 2019-05-27 14:27:05 +03:00
Aleksey Kladov
cf214ac4e7 enable profiling in tests 2019-05-27 14:20:11 +03:00
Pascal Hertleif
1e6ba19015 Make rainbows optional 2019-05-27 11:44:46 +02:00
Pascal Hertleif
4ac338b608
rename stray id field 2019-05-27 11:26:35 +02:00
Pascal Hertleif
5abcca516d
make it build again 2019-05-27 11:26:35 +02:00
Pascal Hertleif
2b200f6e1a
Disable broken struct field rainbowing 2019-05-27 11:26:35 +02:00
Pascal Hertleif
43d5a49653
More clever highlighting, incl draft for structs 2019-05-27 11:26:35 +02:00
Pascal Hertleif
ed89b0638b
Hash based on binding name and shadow counter 2019-05-27 11:26:35 +02:00
Pascal Hertleif
5bf3e949e8
Semantic highlighting spike
Very simple approach: For each identifier, set the hash of the range
where it's defined as its 'id' and use it in the VSCode extension to
generate unique colors.

Thus, the generated colors are per-file. They are also quite fragile,
and I'm not entirely sure why. Looks like we need to make sure the
same ranges aren't overwritten by a later request?
2019-05-27 11:26:33 +02:00
Aleksey Kladov
ce040aa907 add profile calls to real-time requests 2019-05-27 11:48:23 +03:00
bors[bot]
bdd779aa44 Merge #1277
1277: Improve macro item resolution r=matklad a=edwin0cheng

~This PR add a new namespace `Macros` in `per_ns.rs` to allow following use case:~
This PR improve macro item resolution to allow following use case:

```rust
//- /main.rs     
use foo::bar;
bar!();

//- /lib.rs  (crate foo)
#[macro_export]
macro_rules! bar{
() => {
    struct Foo { field: u32 } 
}
```


Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-05-27 07:38:21 +00:00
Edwin Cheng
6d68d60d32 Formatting 2019-05-27 15:37:22 +08:00
bors[bot]
ce694ae118 Merge #1328
1328: Change TokenSource to iteration based r=matklad a=edwin0cheng

This PR change the `TokenSource` trait from random access to be an iteration based trait:
```rust

/// `TokenSource` abstracts the source of the tokens parser operates one.
///
/// Hopefully this will allow us to treat text and token trees in the same way!
pub trait TokenSource {
    fn current(&self) -> Token;

    /// Lookahead n token
    fn lookahead_nth(&self, n: usize) -> Token;

    /// bump cursor to next token
    fn bump(&mut self);

    /// Is the current token a specified keyword?
    fn is_keyword(&self, kw: &str) -> bool;
}

/// `TokenCursor` abstracts the cursor of `TokenSource` operates one.
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub struct Token {
    /// What is the current token?
    pub kind: SyntaxKind,

    /// Is the current token joined to the next one (`> >` vs `>>`).
    pub is_jointed_to_next: bool,
}
```

Note that the refactoring based on this new trait will be separated to incoming PRs

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-05-27 07:28:13 +00:00
Edwin Cheng
d6e6a98c03 Add Test for new item resolution 2019-05-26 20:11:18 +08:00
Edwin Cheng
b72074a715 Use ItemOrMacro in item resolution 2019-05-26 20:10:56 +08:00
Edwin Cheng
c0dc14ba5a Add Either dep 2019-05-26 20:10:05 +08:00
Edwin Cheng
d5fbce4458 Put back unexpaned_macros after resolve 2019-05-26 13:38:03 +08:00
Edwin Cheng
90764fc54b Remove duplicated code 2019-05-26 02:41:00 +08:00
Edwin Cheng
816147c4b5 Simplify token_tree_to_xxx 2019-05-25 21:55:46 +08:00
Edwin Cheng
fcb1eef323 Change TokenSource to iteration based 2019-05-25 20:41:03 +08:00
Aleksey Kladov
c6e905a79f Colorize Rust code as HTML 2019-05-25 13:42:34 +03:00
Aleksey Kladov
0270b4bc57 reformat 2019-05-24 01:48:44 +03:00
Aleksey Kladov
53ae63835d ⬆️ rustc 2019-05-24 01:46:23 +03:00
bors[bot]
de87fe293e Merge #1317
1317: profile highlighting r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-05-23 18:25:35 +00:00
Aleksey Kladov
f6d2c3f9d5 profile highlighting 2019-05-23 21:19:54 +03:00
bors[bot]
afb792acb7 Merge #1316
1316: Simplify code model r=matklad a=matklad

* remove references from types which are now id-based
* remove api/impl separation, as the impl is a tiny fraction of API anyway 

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-05-23 18:16:46 +00:00
Aleksey Kladov
ef3169a33a rename code_model_api -> code_model 2019-05-23 21:14:19 +03:00
Aleksey Kladov
0e57d58dd0 kill code_model_impl 2019-05-23 21:13:22 +03:00
Aleksey Kladov
ce82fbfc44 remove more references 2019-05-23 21:08:10 +03:00
Aleksey Kladov
bde9cab66e remove references 2019-05-23 21:01:31 +03:00
Aleksey Kladov
7f22f90503 kill krate_impl 2019-05-23 20:30:09 +03:00
Aleksey Kladov
dbd02546b9 fix signature 2019-05-23 20:25:55 +03:00
bors[bot]
1dc9adc6e2 Merge #1290
1290: Add Union to code_model r=matklad a=matklad

@flodiebold I am conflicted about two possible implementation approaches:

* we can add a separate `struct Union` to code model
* we can add `fn is_union(&self)` to existing `Struct`

This PR goes with the former approach, because it seems like Unions are sufficiently different in semantics to warrant a separate types. Which is in contrast to Syntax Tree, where both structs and unions share the same node kind, because their syntax is the same. 

What would be the right thing to do here?

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-05-23 17:23:17 +00:00
Aleksey Kladov
5d54aa6781 add union to code_model 2019-05-23 20:18:47 +03:00