Commit graph

706 commits

Author SHA1 Message Date
Aleksey Kladov
8c86963d47 DynMap
This might, or might not help us to reduce boilerplate associated with
plumbing values from analysis to the IDE layer
2019-12-06 21:28:05 +01:00
Aleksey Kladov
193b1a7437 ⬆️ rowan 2019-12-04 17:15:55 +01:00
ice1000
379482068d Add ModuleItemsOwner to Block 2019-12-03 12:07:39 -05:00
Aleksey Kladov
5fd68b5929 Fix hir for ast::UnionDef 2019-11-25 17:50:49 +03:00
Aleksey Kladov
e1c0bdaf75 Introduce dedicated AST node for union
Although structs and unions have the same syntax and differ only in
the keyword, re-using the single syntax node for both of them leads to
confusion in practice, and propagates further down the hir in an
upleasent way.

Moreover, static and consts also share syntax, but we use different
nodes for them.
2019-11-25 17:50:49 +03:00
bors[bot]
7b6aa7c34e
Merge #2343
2343: implement assist invert_if r=matklad a=bravomikekilo

fix [issue 2219 invert if condition](https://github.com/rust-analyzer/rust-analyzer/issues/2219)
I put the assist cursor range to `if` of the if expression, because both condition and body will be replaced. Is there any way to replace them without cover the cursor position?
@matklad 

Co-authored-by: bravomikekilo <bmk1221@126.com>
2019-11-24 08:32:07 +00:00
bravomikekilo
adac4fc2f2 do refact and fix some issue 2019-11-24 13:14:57 +08:00
Aleksey Kladov
d8caf56dfc Uniformalize naming 2019-11-22 21:52:06 +03:00
Aleksey Kladov
cebeedc66f Next gen IDs for functions
The current system with AstIds has two primaraly drawbacks:

* It is possible to manufacture IDs out of thin air.
  For example, it's possible to create IDs for items which are not
  considered in CrateDefMap due to cfg. Or it is possible to mixup
  structs and unions, because they share ID space.

* Getting the ID of a parent requires a secondary index.

Instead, the plan is to pursue the more traditional approach, where
each items stores the id of the parent declaration. This makes
`FromSource` more awkward, but also more correct: now, to get from an
AST to HIR, we first do this recursively for the parent item, and the
just search the children of the parent for the matching def
2019-11-20 16:22:58 +03:00
Aleksey Kladov
0e771915fa Allow non-path default type parameters 2019-11-20 11:46:44 +03:00
Aleksey Kladov
83a8430e0a ⬆️ rowan 2019-11-19 21:13:36 +03:00
DJMcNab
27ce1e822b Remove the custom impl of AttrsOwner for ImplItem
The default impl should have the same behaviour, and it can be generated
by codegen.
See also `ModuleItem` and `NominalDef`
2019-11-18 18:13:56 +00:00
Aleksey Kladov
7e2f4b30db Disable doctests 2019-11-17 18:35:05 +03:00
Aleksey Kladov
5b54a93fe7 Add ast for plain and raw string literals 2019-11-16 22:50:41 +03:00
Aleksey Kladov
d898ecb8f2 Force passing Source when creating a SourceAnalyzer 2019-11-16 02:12:35 +03:00
Geoffry Song
5645c153e0 Attempt to implement typed accessors 2019-11-15 12:05:29 -08:00
Geoffry Song
a68aefdc46 Move inclusive range check to validation 2019-11-15 01:04:45 -08:00
Geoffry Song
989cebc99c Fix parsing of "postfix" range expressions.
Right now they are handled in `postfix_dot_expr`, but that doesn't allow it to
correctly handle precedence. Integrate it more tightly with the Pratt parser
instead.

Also includes a drive-by fix for parsing `match .. {}`.

Fixes #2242.
2019-11-15 00:18:28 -08:00
Aleksey Kladov
4cea6bb6f1 Make make:: builders slightly more convenient 2019-11-13 11:59:18 +03:00
Aleksey Kladov
e177c65e36 Use strongly-typed ast building for early-return assist 2019-11-13 11:54:21 +03:00
Aleksey Kladov
1860f9ab43 Forbid visibility qualifiers in traits 2019-11-11 11:26:57 +03:00
bors[bot]
fe6ba12a77
Merge #2149
2149: Handle IfLet in convert_to_guarded_return. r=matklad a=krk

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/2124

I could not move the cursor position out of `let`:
`le<|>t` vs `let<|>`.

Also, please suggest extra test cases.

Co-authored-by: krk <keremkat@gmail.com>
2019-11-04 09:06:53 +00:00
krk
91ab3f8760 Support paths other than "Some". 2019-11-01 18:18:58 +01:00
kjeremy
dcc0a9cd7e Attach docs to statics 2019-10-31 16:21:46 -04:00
krk
4a4d9f7a90 Handle IfLet in convert_to_guarded_return. 2019-10-31 21:10:58 +01:00
kjeremy
78f93c8033 traits => match_ast! 2019-10-30 16:08:59 -04:00
kjeremy
7ad55e976c Document match_ast! 2019-10-30 14:38:45 -04:00
kjeremy
b441b4e8ef Some clippy fixes 2019-10-30 13:36:37 -04:00
Aleksey Kladov
5a6db3ca29 fix parsing of for loops inside expressions
closes #2051
2019-10-28 15:41:34 +03:00
Jeremy Kolb
1438f38eb6 Preserve whitespace at the end of doc comments
Whitespace can have special meaning in markdown. For instance
ending a line with three spaces will render a new line.
Note that this behavior diverges from RLS.

Fixes #1997
2019-10-27 16:56:25 -04:00
Aleksey Kladov
4ef9b8d17a use correct spacing for enum pattern 2019-10-26 18:03:55 +03:00
Mikhail Modin
fb215dc192 Adds "replace with guarded return" assist 2019-10-20 19:14:32 +01:00
Aleksey Kladov
5376c769f0 rename tools -> xtask 2019-10-17 23:14:05 +03:00
Laurențiu Nicola
a6b980d6d4 Bump deps 2019-10-17 18:08:11 +03:00
bors[bot]
bc7de5d47a
Merge #2002
2002:  Remove unused dependencies r=matklad a=sinkuu



Co-authored-by: Shotaro Yamada <sinkuu@sinkuu.xyz>
2019-10-14 11:10:20 +00:00
Shotaro Yamada
e4ffa79b3e Enable serde feature in ra_syntax/Cargo.toml 2019-10-14 19:56:29 +09:00
Aleksey Kladov
c00f298fd2 add syntax-tree based indents 2019-10-12 22:07:47 +03:00
Shotaro Yamada
8c72c00abd Remove smol_str dependency from ra_syntax 2019-10-12 07:48:23 +09:00
bors[bot]
d9338dfa98
Merge #1951
1951: Lower the precedence of the `as` operator. r=matklad a=goffrie

Previously, the `as` operator was being parsed like a postfix expression, and
therefore being given the highest possible precedence. That caused it to bind
more tightly than prefix operators, which it should not. Instead, parse it
somewhat like a normal binary expression with some special-casing.

Fixes #1851.

Co-authored-by: Geoffry Song <goffrie@gmail.com>
2019-10-08 08:44:26 +00:00
Geoffry Song
b4fe06bc17 Move tests around 2019-10-05 16:33:05 -07:00
bors[bot]
d3872964f8
Merge #1960
1960: Replace AST visitors with macro r=viorina a=viorina

Fixes #1672.

Co-authored-by: Ekaterina Babshukova <ekaterina.babshukova@yandex.ru>
2019-10-05 14:54:25 +00:00
Ekaterina Babshukova
311dbb8545 remove visitor module 2019-10-05 17:48:31 +03:00
bors[bot]
ae6305b90c
Merge #1928
1928: Support `#[cfg(..)]` r=matklad a=oxalica

This PR implement `#[cfg(..)]` conditional compilation. It read default cfg options from `rustc --print cfg` with also hard-coded `test` and `debug_assertion` enabled.
Front-end settings are **not** included in this PR.

There is also a known issue that inner control attributes are totally ignored. I think it is **not** a part of `cfg` and create a separated issue for it. #1949

Fixes #1920 

Related: #1073 


Co-authored-by: uHOOCCOOHu <hooccooh1896@gmail.com>
Co-authored-by: oxalica <oxalicc@pm.me>
2019-10-05 14:25:59 +00:00
Ekaterina Babshukova
2fc2290173 replace AST visitors with macro 2019-10-05 17:03:03 +03:00
Geoffry Song
9638adaa40 Fix parsing of block expressions in "forbid_structs" contexts.
Forbidding block expressions entirely is too strict; instead, we should only
forbid them in contexts where we are parsing an optional RHS (i.e. the RHS of a
range expression).
2019-10-03 00:39:52 -07:00
Geoffry Song
b63f260bbc Lower the precedence of the as operator.
Previously, the `as` operator was being parsed like a postfix expression, and
therefore being given the highest possible precedence. That caused it to bind
more tightly than prefix operators, which it should not. Instead, parse it
somewhat like a normal binary expression with some special-casing.
2019-10-03 00:27:09 -07:00
uHOOCCOOHu
ffe179a736
Pass attributes as token tree to DefCollector 2019-10-03 02:27:11 +08:00
Alexander Andreev
81efd696cc Merge branch 'master' into feature/issue/1856
# Conflicts:
#	crates/ra_assists/src/ast_editor.rs
2019-09-30 12:07:26 +03:00
Alexander Andreev
fdbd6bb11a Added test for check doc strings in crates.
#1856
2019-09-30 11:58:53 +03:00
uHOOCCOOHu
f7e12559cb
Fixes 2019-09-30 16:17:54 +08:00
uHOOCCOOHu
5a4b4f507e
Fix API of Attr 2019-09-30 16:17:53 +08:00
uHOOCCOOHu
71efdaa636
Parse correct AttrInput 2019-09-30 16:11:40 +08:00
Aleksey Kladov
4acadbdca6 cleanup editor 2019-09-30 10:08:28 +03:00
Aleksey Kladov
05ca252fb5 remove ast_editor.rs 2019-09-30 10:05:12 +03:00
Aleksey Kladov
054c53aeb9 move remove bounds to ast/edit.rs 2019-09-30 09:56:20 +03:00
Aleksey Kladov
e010b144d5 move field list to ast/edit.rs 2019-09-30 09:27:26 +03:00
Aleksey Kladov
0840ec038b migrate add impl items to the new editing API 2019-09-28 20:10:53 +03:00
Aleksey Kladov
5dbbfda34a simplify strip attrs 2019-09-28 19:50:16 +03:00
bors[bot]
2b69c84396
Merge #1815
1815: Support correct `$crate` expansion in macros r=uHOOCCOOHu a=uHOOCCOOHu

This PR makes normal use cases of `$crate` from macros work as expected.

It makes more macros from `std` work. Type inference works well with `panic`, `unimplemented`, `format`, and maybe more.
Sadly that `vec![1, 2, 3]` still not works, but it is not longer an issue about macro.

Screenshot:
![Screenshot_20190927_022136](https://user-images.githubusercontent.com/14816024/65714465-b4568f80-e0cd-11e9-8043-dd44c2ae8040.png)




Co-authored-by: uHOOCCOOHu <hooccooh1896@gmail.com>
2019-09-27 02:58:26 +00:00
Aleksey Kladov
d847d53e36 Start simplifying editing API 2019-09-26 22:22:08 +03:00
uHOOCCOOHu
128dc5355b
Refactor Name ready for hygienic macro 2019-09-27 02:04:47 +08:00
Aleksey Kladov
1a4b424005 move diff to ra_syntax 2019-09-26 15:56:52 +03:00
Aleksey Kladov
183a38fb50 keep ast creation API simple 2019-09-26 15:29:28 +03:00
Aleksey Kladov
a525e830a6 add new editing API, suitable for modifying several nodes at once 2019-09-25 17:57:12 +03:00
Aleksey Kladov
b7422bd1ab fewer monomorphisations 2019-09-25 17:19:16 +03:00
Aleksey Kladov
66101e931c simplify 2019-09-24 09:28:16 +03:00
kjeremy
fef7fcf5a9 Support loop as argument 2019-09-20 16:35:29 -04:00
bors[bot]
3575f7c4a2
Merge #1884
1884: Add indexing to record_field_pat r=matklad a=kjeremy

Fixes #1870 

Co-authored-by: kjeremy <kjeremy@gmail.com>
2019-09-20 15:54:01 +00:00
kjeremy
5a65d4d9fb Add indexing to record_field_pat 2019-09-20 11:43:34 -04:00
Aleksey Kladov
d57b993ade fix infinite loop in the parser
closes #1866
2019-09-20 16:57:31 +03:00
Aleksey Kladov
0f70290b6e don't confuse macro with !=
closes #1871
2019-09-20 16:23:24 +03:00
uHOOCCOOHu
4926bed426
Support path starting with a type 2019-09-15 19:40:32 +08:00
bors[bot]
2d79a1ad83
Merge #1848
1848: Parse `..` as a full pattern r=matklad a=ecstatic-morse

Resolves #1479.

This PR implements [RFC 2707](https://github.com/rust-lang/rfcs/pull/2707) in the parser. It introduces a new `DotDotPat` AST node modeled on `PlaceholderPat` and changes the parsing of tuple and slice patterns to conform to the RFC.

Notably, this PR does *not* change the resulting AST when `..` appears in a struct pattern (e.g. `Struct { a, b: c, .. }`). I *think* this is the behavior mandated by RFC 2707, but someone should confirm this.

Co-authored-by: Dylan MacKenzie <ecstaticmorse@gmail.com>
2019-09-15 07:10:16 +00:00
Dylan MacKenzie
0956323bb7 Generate dot_dot_test 2019-09-14 17:08:22 -07:00
Dylan MacKenzie
da3815122d Bless old tests containing a .. pattern 2019-09-14 17:08:22 -07:00
Dylan MacKenzie
426112c97e Add DotDotPat to AST
This is modeled on `PlaceholderPat`.
2019-09-14 17:08:22 -07:00
Dylan MacKenzie
c413f444a0 Add tests for underscores in const and static items 2019-09-14 16:31:09 -07:00
Dylan MacKenzie
253a18f938 Allow an underscore as the identifier in const items 2019-09-14 16:31:09 -07:00
uHOOCCOOHu
8c078a0164
Infer box expression 2019-09-12 02:35:09 +08:00
Aleksey Kladov
ed726081d1 add a jointness parser tests
cc https://github.com/rust-lang/rust/issues/64242
2019-09-10 15:57:51 +03:00
Aleksey Kladov
40170885e7 WIP: switch to fully decomposed tokens internally 2019-09-10 15:46:39 +03:00
uHOOCCOOHu
f3cbdb07c5
Fix outer doc-comments of macro_rules 2019-09-09 11:13:14 +08:00
Florian Diebold
d21cdf3c99 Lower Fn(X, Y) -> Z paths 2019-09-07 15:13:05 +02:00
Aleksey Kladov
7a9d7dd637 switch to rustc_lexer crate 2019-09-05 23:07:17 +03:00
Aleksey Kladov
b2be998b7b better error recovery for use trees 2019-09-05 19:53:07 +03:00
bors[bot]
6702f5b7b5
Merge #1743
1743: Support `#[macro_use]` on `extern crate` r=matklad a=uHOOCCOOHu

Unfortunately, #1688 is still an issue. My guess is wrong :(

Co-authored-by: uHOOCCOOHu <hooccooh1896@gmail.com>
2019-09-05 09:04:02 +00:00
Aleksey Kladov
9c3b25177e Correctly build BodySourceMap for macro-expanded expressions 2019-09-03 11:04:38 +03:00
Aleksey Kladov
e94587e315 fix assists 2019-09-02 21:52:06 +03:00
Aleksey Kladov
5e3f291195 fix hir for new block syntax 2019-09-02 21:23:19 +03:00
Aleksey Kladov
dcf8e89503 fix generated AST 2019-09-02 20:15:51 +03:00
Aleksey Kladov
470fc4765c update test data 2019-09-02 20:15:51 +03:00
Aleksey Kladov
3c2dea7f55 always wrap block into an expression 2019-09-02 20:15:51 +03:00
Aleksey Kladov
f377b94628 remove useless trait 2019-09-02 19:45:41 +03:00
Florian Diebold
f92177cfb5 Add an expr_source method analogous to the source methods in the code model
... and use that instead of exposing the source map.
2019-09-02 14:56:38 +02:00
uHOOCCOOHu
f5bea9051b
Support resolution of #[macro_use] extern crate 2019-09-01 01:54:41 +08:00
bors[bot]
cd433ed194
Merge #1734
1734: Strip indents and empty lines in check_apply_diagnostic_fix_from_position r=matklad a=matklad



Co-authored-by: Phil Ellison <phil.j.ellison@gmail.com>
2019-08-25 09:58:54 +00:00
Phil Ellison
200470692f Cast SyntaxNodePtr to AstPtr directly 2019-08-25 12:56:23 +03:00
Dylan MacKenzie
c93903e9c7 Generate and bless tests 2019-08-23 16:24:30 -07:00
Dylan MacKenzie
83433cd1f0 Centralize box pattern tests in patterns.rs 2019-08-23 16:19:53 -07:00
Dylan MacKenzie
e6f3790106 Add BoxPat variant 2019-08-23 15:11:34 -07:00