Stream: t-compiler/wg-rls-2.0

Topic: About SourceAnalyzer


Edwin Cheng (Nov 19 2019 at 20:28, on Zulip):

The SourceAnalyzer constructor :

impl SourceAnalyzer {
    pub fn new(
        db: &impl HirDatabase,
        node: Source<&SyntaxNode>,
        offset: Option<TextUnit>,
    ) -> SourceAnalyzer {

@matklad What node can I put in ? Can I put in a Source(HirFileId::MacroFile, ast)? If so, how SourceAnalyzer::expand resolve other macro call?

Edwin Cheng (Nov 19 2019 at 20:31, on Zulip):

And must Source::ast is inside Source::file_id ?

matklad (Nov 19 2019 at 20:34, on Zulip):

@Edwin Cheng in theory you should be able to use just about any syntax node as node: Source<SyntxNOde>, as long as you use the ast is contained in db.parse_or_expand(node.file_id). However, the resolver for macro files will indeed be wrong, this needs to be fixed somehow inside the SourceAnalyzer itself

Last update: Dec 12 2019 at 00:55UTC