Commit Graph

5819 Commits

Author SHA1 Message Date
bors[bot]
4ef9cab41a
Merge #2318
2318: Fix panic when use `Expand Macro` on `assert_eq` r=matklad a=edwin0cheng

The cause of this [bug](https://github.com/rust-analyzer/rust-analyzer/pull/2291#issuecomment-555651542) is, when calling `SourceAnalyzer::expand` when an `ast::MacroCall` which is outside of `SourceAnalyzer::node`. 

Note that if we use a node in `SourceAnalyzer::new` with a `MacroFile` file id, the resolver inside `SourceAnalyzer` still will not work properly. Another PR will need to fix it.

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-11-20 13:36:19 +00:00
Edwin Cheng
0a9c80053f Fix expand macro 2019-11-20 21:33:01 +08:00
bors[bot]
b568bcfe6d
Merge #2325
2325: Next gen IDs for functions r=matklad a=matklad

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

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-11-20 13:23:38 +00: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
bors[bot]
2d47f380ba
Merge #2324
2324: Move traits to hir_def r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-11-20 11:27:10 +00:00
Aleksey Kladov
06fa3d8389 Move traits to hir_def 2019-11-20 14:22:38 +03:00
bors[bot]
3d56e3d855
Merge #2323
2323: Rename with_ast -> with_value r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-11-20 10:10:03 +00:00
Aleksey Kladov
51baaf298d Rename with_ast -> with_value 2019-11-20 13:09:21 +03:00
bors[bot]
fa50b16cb2
Merge #2322
2322: Move Generics to hir_def r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-11-20 09:35:50 +00:00
Aleksey Kladov
e1a6e38767 Move Generics to hir_def 2019-11-20 12:34:48 +03:00
bors[bot]
d24e8f9ea4
Merge #2321
2321: Allow non-path default type parameters r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-11-20 08:47:42 +00:00
Aleksey Kladov
0e771915fa Allow non-path default type parameters 2019-11-20 11:46:44 +03:00
bors[bot]
4340d9b0e4
Merge #2320
2320: Cleanup imports r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-11-20 06:51:40 +00:00
Aleksey Kladov
7020167aa2 Cleanup imports 2019-11-20 09:47:14 +03:00
bors[bot]
4dae39a609
Merge #2319
2319: Rename Source::ast -> Source::value r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-11-20 06:44:37 +00:00
Aleksey Kladov
36e3fc9d54 Rename Source::ast -> Source::value 2019-11-20 09:42:30 +03:00
Aleksey Kladov
e975f6364c add ws 2019-11-20 09:20:53 +03:00
Aleksey Kladov
eec68e6f45
Merge pull request #2297 from kiljacken/master
Add fancy truncation of type hints.
2019-11-20 08:38:25 +03:00
bors[bot]
0e61ba3750
Merge #2314
2314: ⬆️ rowan r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-11-19 18:14:00 +00:00
Aleksey Kladov
83a8430e0a ⬆️ rowan 2019-11-19 21:13:36 +03:00
bors[bot]
545c21923e
Merge #2291
2291: Show expanded macro in vscode r=matklad a=edwin0cheng

*Edited*

![new_screen_shot](https://user-images.githubusercontent.com/11014119/69169852-00550c00-0b34-11ea-9c40-8ecebdca0621.gif)



Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-11-19 17:53:27 +00:00
Edwin Cheng
1d56b80250 Minor fix for outpu text formating 2019-11-20 01:22:28 +08:00
Edwin Cheng
e290171397 Add shot doc for expand_macro module 2019-11-20 01:12:56 +08:00
Edwin Cheng
47a4c3e77d Add document in features.md 2019-11-20 01:09:15 +08:00
Edwin Cheng
d16cc223e1 Use DocumentProvider instead of Hover 2019-11-20 01:06:10 +08:00
Emil Lauridsen
bf5ac4fe39 Add test for inlay hint truncation 2019-11-19 17:40:38 +01:00
Emil Lauridsen
dadad36bb9 Move type inlay hint truncation to language server
This commit implements a general truncation framework for HirFormatter
that keeps track of how much has been output so far. This information
can then be used to perform truncation inside the language server,
instead of relying on the client.

Initial support is implemented for truncating types hints using the
maxInlayHintLength server config option. The existing solution in the
VSCode extension has been removed in favor of letting the server
truncate type hints.
2019-11-19 17:23:50 +01:00
Edwin Cheng
80fe467ce8 Improve insert_whitespaces 2019-11-20 00:12:48 +08:00
Edwin Cheng
4012da07fd Change return type of expand_macro 2019-11-19 22:56:48 +08:00
Edwin Cheng
94c63d2802 Change to use Expansion::file_id and reordering 2019-11-19 22:56:28 +08:00
Edwin Cheng
8010b42b21 Fix npm formatting 2019-11-19 21:49:06 +08:00
Edwin Cheng
ae49a22b5c Rebase 2019-11-19 21:49:06 +08:00
Edwin Cheng
3ccd05fedc Add recursive expand in vscode 2019-11-19 21:49:06 +08:00
bors[bot]
d2782ab1c1
Merge #2312
2312: Fixed string literal quoting r=matklad a=edwin0cheng

It fixed a bug which `quote!` should return a literal escaped instead of original string. 

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-11-19 08:27:27 +00:00
Aleksey Kladov
c3e61d7e8e Run CI on trying as well 2019-11-19 11:24:18 +03:00
Edwin Cheng
f24bba74d0 Fixed a bug for string lit in quote 2019-11-19 12:15:20 +08:00
bors[bot]
c24ee09904
Merge #2309
2309: Goto type def through macros r=matklad a=kjeremy



Co-authored-by: kjeremy <kjeremy@gmail.com>
2019-11-18 20:04:36 +00:00
kjeremy
e939f740b3 Goto type def through macros 2019-11-18 14:57:42 -05:00
bors[bot]
c8fb5b491a
Merge #2307
2307: Support hover through macro r=matklad a=kjeremy

Allows hover to work through macros like `match_ast!`.

Co-authored-by: kjeremy <kjeremy@gmail.com>
2019-11-18 19:57:06 +00:00
kjeremy
90f6f6080e Fix test 2019-11-18 14:20:14 -05:00
bors[bot]
a4f21801c5
Merge #2308
2308: Remove the custom impl of AttrsOwner for ImplItem r=matklad a=DJMcNab

The default impl should have the same behaviour, and it can be generated by codegen.
See also `ModuleItem` and `NominalDef`.

Also see 5dbbfda34a (r36011245)

Co-authored-by: DJMcNab <36049421+djmcnab@users.noreply.github.com>
2019-11-18 18:21:44 +00: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
kjeremy
b2cc593381 Support hover through macro 2019-11-18 11:58:42 -05:00
bors[bot]
d071321973
Merge #2305
2305: Remove CI badge r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-11-18 16:28:04 +00:00
Aleksey Kladov
089e9ba52f Remove CI badge 2019-11-18 19:27:41 +03:00
bors[bot]
7614439033
Merge #2304
2304: Use Source<&ast::Name> in classify_name r=matklad a=kjeremy



Co-authored-by: kjeremy <kjeremy@gmail.com>
2019-11-18 15:50:47 +00:00
kjeremy
a22cb1daa7 Use Source<&ast::Name> in classify_name 2019-11-18 10:47:19 -05:00
bors[bot]
9cc4d058d2
Merge #2302
2302: Collapse TokenMap and RevTokenMap r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-11-18 13:09:29 +00:00
Aleksey Kladov
2b6f1ab0e2 Collapse TokenMap and RevTokenMap 2019-11-18 16:08:41 +03:00
bors[bot]
789a0d2a64
Merge #2301
2301: Don't create a separate bin for format hook r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-11-18 12:41:59 +00:00