Commit Graph

4927 Commits

Author SHA1 Message Date
Edwin Cheng
fccd045229 Add cached for SubtreeSource 2019-04-22 22:46:39 +08:00
bors[bot]
c416caeda2 Merge #1194
1194: Pr 1190 r=matklad a=matklad



Co-authored-by: Andrea Pretto <eulerdisk@gmail.com>
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-04-22 13:19:47 +00:00
Aleksey Kladov
aa1ef6ae9a unused import 2019-04-22 16:18:14 +03:00
Aleksey Kladov
c27a3da5e8 remove path_ident from CompletionContext
We really shouldn't be looking at the identifier at point. Instead,
all filtering and sorting should be implemented at the layer above.

This layer should probably be home for auto-import completions as
well, but, since that is not yet implemented, let's just stick this
into complete_scope.
2019-04-22 16:04:56 +03:00
Aleksey Kladov
e01052d1f0 move auto-imoprter into IDE
auto-import is purely an IDE concern, so it should be done outside of
HIR
2019-04-22 15:56:28 +03:00
bors[bot]
6162278075 Merge #1193
1193: Add a test for #1178 case r=edwin0cheng a=edwin0cheng

A little PR to add a test case for #1178

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-04-22 12:22:08 +00:00
Edwin Cheng
bb84fce1a4 Remove unused print out 2019-04-22 20:21:14 +08:00
Edwin Cheng
1cdfc38066 Add a test for #1178 case 2019-04-22 20:14:46 +08:00
bors[bot]
38c0a1e333 Merge #1184
1184: Start structured editing API r=matklad a=matklad

I think I finally understand how to provide nice, mutable structured editing API on top of red-green trees.

The problem I am trying to solve is that any modification to a particular `SyntaxNode` returns an independent new file. So, if you are editing a struct literal, and add a field, you get back a SourceFile, and you have to find the struct literal inside it yourself! This happens because our trees are immutable, but have parent pointers. 

The main idea here is to introduce `AstEditor<T>` type, which abstracts away that API. So, you create an `AstEditor` for node you want to edit and call various `&mut` taking methods on it. Internally, `AstEditor` stores both the original node and the current node. All edits are applied to the current node, which is replaced by the corresponding node in the new file. In the end, `AstEditor` computes a text edit between old and new nodes.

Note that this also should sole a problem when you create an anchor pointing to a subnode and mutate the parent node, invalidating anchor. Because mutation needs `&mut`, all anchors must be killed before modification. 

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-04-22 10:08:18 +00:00
Aleksey Kladov
b73a978b95 drop useless test 2019-04-22 13:05:01 +03:00
Aleksey Kladov
268e739c94 move add_missing_members to structured editing API
Currently, this is more code, and we also loose auto-indenting of
bodies, but, long-term, this is the right approach
2019-04-22 13:01:33 +03:00
bors[bot]
76e0129a21 Merge #1192
1192: Add mbe expand limit and poision macro set r=maklad a=edwin0cheng

As discussed in Zulip, this PR add a token expansion limit in `parse_macro` and a "poison" macro set in `CrateDefMap` to prevent stack over flow and limit a mbe macro size.

Note:
Right now it only handle a poison macro in a single crate, such that if other crate try to call that macro, the whole process will do again until it became poisoned in that crate.


Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-04-22 09:39:20 +00:00
Edwin Cheng
ad1c3b5bd6 Use map, sum in Subtree::coount instead of fold 2019-04-22 17:37:27 +08:00
Edwin Cheng
d6d9aa2003 Change macro stack monitor test to func ptr based 2019-04-22 17:15:22 +08:00
Aleksey Kladov
b811922a53 fix postfix match indent 2019-04-22 10:38:39 +03:00
Edwin Cheng
b177813f3b Add mbe expand limit and poision macro set 2019-04-22 15:33:55 +08:00
Aleksey Kladov
5b2fd86d25 more type safety 2019-04-22 10:11:06 +03:00
Andrea Pretto
200032852b complete_import: prevent panic when the anchor is the completion source range
(fix rebase mess)

 Please enter the commit message for your changes. Lines starting
2019-04-22 00:48:43 +02:00
Andrea Pretto
9144214958 complete_import: add new import resolver infrastructure with some hardcoded importable name.
Changes complete_scope to support that.
2019-04-22 00:14:58 +02:00
Andrea Pretto
cf0eff2e33 auto_import: better no anchor management 2019-04-22 00:13:00 +02:00
Andrea Pretto
766813898f auto_import: make auto import working with target as a list of SmolStr instead of ast::Path 2019-04-22 00:13:00 +02:00
Andrea Pretto
0e0ae47b47 auto_import: use TextEditBuilder instead of AssistBuilder to make it more reusable 2019-04-22 00:13:00 +02:00
Aleksey Kladov
97f41d7343 test short structs 2019-04-22 00:52:21 +03:00
bors[bot]
bbc5c1d24e Merge #1189
1189: Fix #1178 r=matklad a=edwin0cheng

This PR improves / fixes mbe :

1. Fixed a offest bug in `SourceTreeWalker`
2. Handle `*+` matcher properly
3. Add missing separator in rhs macro expansion.
4. Fixed bug in single token with empty delimiter subtree case. It is because the current `mbe_expander` will create an delimiter subtree for each expansion. But in `tt` case, all puncts expansion will be incorrect because of it. 
5. Fixed lifetime bug
6. Add more information on parse_macro fail
7. Add tests for above.



Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-04-21 21:28:06 +00:00
Edwin Cheng
120bfde3c2 Add tests 2019-04-22 05:04:37 +08:00
Edwin Cheng
3d1cdc834d Fix offset bug in SourceWalker 2019-04-22 05:04:37 +08:00
Edwin Cheng
49c9686c3c Handle *+ case and single token case 2019-04-22 05:04:37 +08:00
Edwin Cheng
bcf5cf8ac6 fix mbe_parser rhs colon parsing 2019-04-22 05:04:37 +08:00
Edwin Cheng
9a5b9638c1 Add more information on parse_macro fail 2019-04-22 05:04:37 +08:00
Edwin Cheng
da05bbcfb1 Fix lifetime in tt to syntax node conversion 2019-04-22 05:04:36 +08:00
Aleksey Kladov
f313ac45af use structured editing API for fill struct assist 2019-04-21 22:13:52 +03:00
Aleksey Kladov
7cc845e88d start structured editing API 2019-04-21 20:51:20 +03:00
bors[bot]
ee94edc722 Merge #1186
1186: remove appveyor r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-04-21 16:26:25 +00:00
Aleksey Kladov
7ef6b9e5f9 remove appveyor 2019-04-21 19:26:01 +03:00
bors[bot]
5e1c29543c Merge #1182
1182: Add HIR for where clauses & ignore impls with where clauses in trait resolution r=matklad a=flodiebold

This prevents any `impl<T> Trait for T where ...` from being treated as a
blanket impl while we don't handle where clauses yet.


Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2019-04-21 13:01:48 +00:00
Florian Diebold
787fb3e5ec Add HIR for where clauses & ignore impls with where clauses in trait resolution
This prevents any `impl<T> Trait for T where ...` from being treated as a
blanket impl while we don't handle where clauses yet.
2019-04-21 15:01:17 +02:00
bors[bot]
7f94119171 Merge #1181
1181: ⬆️ lsp r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-04-21 12:17:50 +00:00
Aleksey Kladov
47672726d8 ⬆️ lsp 2019-04-21 15:17:22 +03:00
bors[bot]
fa15c4d75e Merge #1175
1175: Fix bugs and add error log about macro expansion r=matklad a=edwin0cheng

This PR fixed / add following things:

* Add a fused count which stop recursion of macro expansion in name resolution.
* Add some logs when macro expansion fails
* Add `$crate` meta variable support in mbe, which create a `$crate` ident token in token tree.
* Fixed matching a `$REPEAT` pattern inside a subtree, e.g. `(fn $name:ident {$($i:ident)*} ) => {...}`
* Remove composite-able punct token in syntax node to token conversion. 

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-04-21 10:34:07 +00:00
Aleksey Kladov
493bf20b3d fix docs 2019-04-21 12:52:54 +03:00
bors[bot]
57608ecd9d Merge #1179
1179: switch to official extend selection API r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-04-21 09:14:10 +00:00
Aleksey Kladov
fa12ed2b8f switch to official extend selection API 2019-04-21 12:13:48 +03:00
bors[bot]
31b7697cf6 Merge #1177
1177: ⬆️ code r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-04-21 08:33:11 +00:00
Aleksey Kladov
bf7cdec9dd ⬆️ code 2019-04-21 11:32:48 +03:00
bors[bot]
e4a58ee1f4 Merge #1176
1176: Add a simple test for str method completion r=flodiebold a=flodiebold

Somehow I forgot that we should add a test for this in #1154 until after it was already merging. So I'll just add one now :)

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2019-04-20 16:31:37 +00:00
Florian Diebold
82751f8a4a Add a simple test for str method completion 2019-04-20 18:26:53 +02:00
bors[bot]
4ad2e4ce4e Merge #1154
1154: Initial support for lang items (and str completion) r=flodiebold a=marcogroppo

This PR adds partial support for lang items.
For now, the only supported lang items are the ones that target an impl block.

Lang items are now resolved during type inference - this means that `str` completion now works.

Fixes #1139.

(thanks Florian Diebold for the help!)


Co-authored-by: Marco Groppo <marco.groppo@gmail.com>
2019-04-20 16:13:50 +00:00
Edwin Cheng
9e35bf91b8 Fix bugs 2019-04-20 23:53:39 +08:00
bors[bot]
526a6aba10 Merge #1174
1174: improve cargo watch r=matklad a=vemoo

- Add start and stop commands
- Cleanup trypescript code to avoid definite assignment assertions (`!` after possibly undefined value)
- Recover `rustc-watch` problem matcher because it's still useful, can be used with any command, for example `cargo test`

Co-authored-by: Bernardo <berublan@gmail.com>
2019-04-20 14:02:36 +00:00
Bernardo
4cd0a96c96 update user docs 2019-04-20 10:02:23 +02:00