Commit graph

1411 commits

Author SHA1 Message Date
bors[bot]
4a58522119
Merge #2562
2562: Fix NavigationTarget ranges r=matklad a=edwin0cheng

Fix the issue described in https://github.com/rust-analyzer/rust-analyzer/pull/2544#issuecomment-565572553

This PR change the order for finding `full_range` of `focus_range` in following orders:
1. map both ranges to macro_call
2. map focus range to a token inside macro call, and full range to the whole of macro call
3. map both ranges to the whole of macro call

And fix the corresponding tests and make these tests easily to follow.

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-12-17 13:37:32 +00:00
Aleksey Kladov
2619950b3b Use different types for path with and without generics 2019-12-14 19:15:40 +01:00
Edwin Cheng
b53587c7bd Re-export Origin to replace ExpansionOrigin 2019-12-15 01:46:39 +08:00
Edwin Cheng
61360fdfec Fix original_source find order 2019-12-15 01:24:51 +08:00
Florian Diebold
f02fcc1644 Use path macro 2019-12-13 22:33:38 +01:00
Florian Diebold
6911bc89a7 Rename N! to name! 2019-12-13 22:33:38 +01:00
Florian Diebold
259c42f00e Add macros for known names and paths 2019-12-13 22:33:37 +01:00
Aleksey Kladov
8e65b77387 Dedupe from_source impls 2019-12-12 15:50:16 +01:00
Aleksey Kladov
56710f119b Move enum&union to new loc 2019-12-12 15:11:57 +01:00
Aleksey Kladov
f135a8ea55 Move structs to new loc 2019-12-12 14:58:04 +01:00
Aleksey Kladov
63c192b34a Simplify from_source 2019-12-12 14:48:33 +01:00
Aleksey Kladov
82e9b24558 Move traits to the new loc 2019-12-12 14:36:14 +01:00
Aleksey Kladov
7b0644d81e Switch to the new location for impls 2019-12-12 14:25:34 +01:00
Aleksey Kladov
d89996fd5b Build correct SourceAnalyzer for traits 2019-12-10 13:52:04 +01:00
Aleksey Kladov
61c3887b70 Remove one more Ty 2019-12-08 17:50:43 +01:00
Aleksey Kladov
a1639d0d1e Remove more dead code 2019-12-08 17:45:14 +01:00
Aleksey Kladov
6805bb01e2 Cleanup module structure 2019-12-08 17:45:14 +01:00
Aleksey Kladov
e2cc552076 Remove dead code 2019-12-08 12:51:25 +01:00
Aleksey Kladov
b37c6a746b Remove ty from code_model 2019-12-08 12:44:14 +01:00
Aleksey Kladov
b77d7c24aa Remove bodies from code_model 2019-12-08 12:27:21 +01:00
Aleksey Kladov
b017bae837 remove infer method from CodeModel 2019-12-08 12:26:53 +01:00
Aleksey Kladov
7aacf9a197 Drop some unused methods 2019-12-08 12:24:21 +01:00
Aleksey Kladov
200bda3daf Cleanup Field ty 2019-12-08 12:16:57 +01:00
Aleksey Kladov
08d3166c8b Cleanup Crate API 2019-12-08 12:02:53 +01:00
Edwin Cheng
509fedd9d2 Remove MacroFileKind 2019-12-08 16:16:52 +08:00
Aleksey Kladov
6e2e60cbc9 Discover type parameters in more cases 2019-12-07 21:55:02 +01:00
Aleksey Kladov
88c5b1282a Rename GenericParam -> TypeParam
We don't have LifetimeParam yet, but they are planned!
2019-12-07 20:25:48 +01:00
Aleksey Kladov
f4f8b81474 Get the right analyzer for impls 2019-12-07 20:05:08 +01:00
Aleksey Kladov
7d2080a031 Classify name works for TypeParams 2019-12-07 19:52:09 +01:00
Aleksey Kladov
1692f07393 ToNav for GenericParam 2019-12-07 19:44:43 +01:00
Aleksey Kladov
dda9587e75 Track source of type parameters 2019-12-07 19:44:43 +01:00
Aleksey Kladov
8e9837df21 Remove idx and parent generics from generics
This makes `hir_def::GenericParams` flatter. The logic for
re-numbering the params is moved to hir instead.
2019-12-07 13:05:56 +01:00
bors[bot]
431836f4a0
Merge #2489
2489: Implement `format_args` r=flodiebold a=flodiebold

This fixes a huge amount of type mismatches (because every format call was a type mismatch so far); I also hoped to get go to def working within `format!` etc., and the test says it should, but in practice it still doesn't seem to...

Also remove the `len` parameter from `Name::new_inline_ascii`, which I'm assuming was only there because of `const fn` limitations?

cc @edwin0cheng 

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2019-12-06 20:59:51 +00:00
Florian Diebold
b2c01f446e Implement ancestors_with_macros in a better way 2019-12-06 21:53:31 +01:00
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
Florian Diebold
a565072dde Try to make go to definition work in format!
SourceAnalyzer didn't work properly within expression macro expansions because
it didn't find the enclosing function. Fix this by going up the expansion chain
to find ancestors. This makes the test work, but apparently in real usage it's
still not working.
2019-12-06 21:25:22 +01:00
bors[bot]
6e10a9f578
Merge #2479
2479: Add expansion infrastructure for derive macros r=matklad a=flodiebold

I thought I'd experiment a bit with attribute macro/derive expansion, and here's what I've got so far. It has dummy implementations of the Copy / Clone derives, to show that the approach works; it doesn't add any attribute macro support, but I think that fits into the architecture.

Basically, during raw item collection, we look at the attributes and generate macro calls for them if necessary. Currently I only do this for derives, and just add the derive macro calls as separate calls next to the item. I think for derives, it's important that they don't obscure the actual item, since they can't actually change it (e.g. sending the item token tree through macro expansion unnecessarily might make completion within it more complicated).

Attribute macros would have to be recognized at that stage and replace the item (i.e., the raw item collector will just emit an attribute macro call, and not the item). I think when we implement this, we should try to recognize known inert attributes, so that we don't do macro expansion unnecessarily; anything that isn't known needs to be treated as a possible attribute macro call (since the raw item collector can't resolve the macro yet).

There's basically no name resolution for attribute macros implemented, I just hardcoded the built-in derives. In the future, the built-ins should work within the normal name resolution infrastructure; the problem there is that the builtin stubs in `std` use macros 2.0, which we don't support yet (and adding support is outside the scope of this).

One aspect that I don't really have a solution for, but I don't know how important it is, is removing the attribute itself from its input. I'm pretty sure rustc leaves out the attribute macro from the input, but to do that, we'd have to create a completely new syntax node. I guess we could do it when / after converting to a token tree.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2019-12-05 20:00:20 +00:00
Florian Diebold
18f6a995d0 Add expansion infrastructure for derive macros 2019-12-05 17:23:09 +01:00
Aleksey Kladov
1a567f5ca2 Reduce copy-paste 2019-12-05 16:56:13 +01:00
Aleksey Kladov
0c0ce1ae41 Introduce ChildFromSource 2019-12-05 16:55:54 +01:00
ice1000
7702f690a9 One pub function less is good! 2019-12-05 08:28:31 -05:00
ice1000
088f50c0ab No block at the moment 2019-12-04 18:30:42 -05:00
ice1000
032eb3d68e Remove almost unused ModuleSource::new 2019-12-04 18:30:42 -05:00
ice1000
5c5f90ba57 Confluent ModuleSource usage 2019-12-04 18:30:42 -05:00
ice1000
38853459e3 Add ModuleSource::Block 2019-12-04 18:30:42 -05:00
ice1000
009437f5d9 Replace ra_hir_expand::either with crate 2019-12-03 11:07:56 -05:00
Edwin Cheng
bb601e7eaf Add BuiltinShadowMode 2019-11-30 23:29:21 +08:00
Aleksey Kladov
8f1f5a783a Move source-related traits to a separate module 2019-11-28 19:05:21 +03:00
Aleksey Kladov
e823c578c9 Use InFile for AstId 2019-11-28 16:02:38 +03:00
Aleksey Kladov
ccd1b0800a Rename Source -> InFile 2019-11-28 12:50:26 +03:00