aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/from_source.rs
Commit message (Collapse)AuthorAgeFilesLines
* Merge #2479bors[bot]2019-12-051-2/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 <[email protected]>
| * Add expansion infrastructure for derive macrosFlorian Diebold2019-12-051-2/+2
| |
* | Reduce copy-pasteAleksey Kladov2019-12-051-20/+30
| |
* | Introduce ChildFromSourceAleksey Kladov2019-12-051-101/+40
|/
* One pub function less is good!ice10002019-12-051-5/+4
|
* No block at the momentice10002019-12-041-1/+1
|
* Remove almost unused `ModuleSource::new`ice10002019-12-041-1/+1
|
* Add `ModuleSource::Block`ice10002019-12-041-4/+4
|
* Rename Source -> InFileAleksey Kladov2019-11-281-31/+31
|
* ReformatAleksey Kladov2019-11-271-6/+5
|
* Rename module_id -> local_idAleksey Kladov2019-11-271-4/+4
|
* Fix hir for ast::UnionDefAleksey Kladov2019-11-251-7/+6
|
* Simplify ADT fieldsAleksey Kladov2019-11-241-2/+1
|
* SimplifyAleksey Kladov2019-11-241-4/+4
|
* SimplifyAleksey Kladov2019-11-241-1/+3
|
* Switch to StaticLoc for staticsAleksey Kladov2019-11-241-2/+13
|
* Cleanup importsAleksey Kladov2019-11-241-2/+1
|
* Move constants to new IDAleksey Kladov2019-11-201-3/+22
| | | | This allows us to get rid of trait item index
* Switch type aliases to new sourcesAleksey Kladov2019-11-201-41/+71
|
* Next gen IDs for functionsAleksey Kladov2019-11-201-7/+58
| | | | | | | | | | | | | | | | | 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
* Rename Source::ast -> Source::valueAleksey Kladov2019-11-201-19/+19
|
* Handle ast::MacroCall in classify_name and impl FromSource for MacroDefkjeremy2019-11-151-4/+19
| | | | Fixes #2260
* Sourcify some thingsAleksey Kladov2019-11-151-3/+2
| | | | | If we want to support macros properly, we need to get rid of those FileIds everywhere...
* Remove old impls infrastructureAleksey Kladov2019-11-151-8/+2
|
* Refactor Module::from_source to properly descend from root fileAleksey Kladov2019-11-151-32/+36
|
* Move body queries to hir_defAleksey Kladov2019-11-141-2/+2
|
* Handle macro-generated expressions slightly less wrongAleksey Kladov2019-11-141-1/+2
|
* Add hir::LocalAleksey Kladov2019-11-111-3/+27
|
* Unfork struct and union idsAleksey Kladov2019-11-091-4/+6
|
* Move CrateDefMap to hir_defAleksey Kladov2019-11-031-8/+14
|
* push name down to hir_expandAleksey Kladov2019-10-301-1/+1
|
* remove forward pointer for nameAleksey Kladov2019-10-301-1/+1
|
* move raw_items to hir_defAleksey Kladov2019-10-301-41/+1
|
* Move ids to hir_def crateAleksey Kladov2019-10-301-1/+1
|
* introduce ra_hir_defAleksey Kladov2019-10-301-1/+1
|
* start ra_hir_def crateAleksey Kladov2019-10-291-2/+2
|
* restore assertAleksey Kladov2019-10-231-0/+1
|
* classify module from declarationEkaterina Babshukova2019-10-221-1/+0
|
* replace trait by a bunch of functionsEkaterina Babshukova2019-10-221-58/+2
|
* return Declaration from classify_name_refEkaterina Babshukova2019-10-221-1/+39
|
* replace a chain of `if let` by macroEkaterina Babshukova2019-10-221-39/+1
|
* initial classify_nameEkaterina Babshukova2019-10-221-2/+58
|
* Prepare SourceDatabase API for lazy file loadingAleksey Kladov2019-10-141-5/+5
|
* Added test for check doc strings in crates.Alexander Andreev2019-09-301-0/+2
| | | | #1856
* Remove redundant clone()Shotaro Yamada2019-09-251-4/+4
|
* Drive by lintskjeremy2019-09-231-1/+1
|
* introduce FromSource traitEkaterina Babshukova2019-09-191-0/+211