From 41cb4cb897351273a5ad77397c31ff2ff5ab9eed Mon Sep 17 00:00:00 2001 From: ryuukk Date: Thu, 9 Feb 2023 03:44:23 +0100 Subject: [PATCH] build type lookup for casts with auto declaration --- dsymbol/src/dsymbol/conversion/first.d | 37 ++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/dsymbol/src/dsymbol/conversion/first.d b/dsymbol/src/dsymbol/conversion/first.d index e488566..7694e94 100644 --- a/dsymbol/src/dsymbol/conversion/first.d +++ b/dsymbol/src/dsymbol/conversion/first.d @@ -270,6 +270,43 @@ final class FirstPass : ASTVisitor currentSymbol.addChild(symbol, true); currentScope.addSymbol(symbol.acSymbol, false); + auto initializer = part.initializer.nonVoidInitializer; + if (initializer && initializer.assignExpression) + { + auto unary = cast(UnaryExpression) initializer.assignExpression; + if (unary) + { + if (auto castExpression = unary.castExpression) + { + if (castExpression.type && castExpression.type.type2) + { + auto t2 = castExpression.type.type2; + + auto l = symbol.typeLookups.front; + // get rid of initialier type + // instead feed it with cast expression one + l.breadcrumbs.clear(); + void buildChain(TypeLookup* lookup, TypeIdentifierPart tip) + { + if (tip.identifierOrTemplateInstance) + { + auto crumb = tip.identifierOrTemplateInstance.identifier.text; + lookup.breadcrumbs.insert(istring(crumb)); + } + if (tip.typeIdentifierPart) + buildChain(lookup, tip.typeIdentifierPart); + + // TODO: build template type + // tip.identifierOrTemplateInstance.templateInstance + } + + if (t2 && t2.typeIdentifierPart) + buildChain(l, t2.typeIdentifierPart); + } + } + } + } + if (currentSymbol.acSymbol.kind == CompletionKind.structName || currentSymbol.acSymbol.kind == CompletionKind.unionName) {