diff --git a/dsymbol/src/dsymbol/conversion/first.d b/dsymbol/src/dsymbol/conversion/first.d index e1713c4..a3da11f 100644 --- a/dsymbol/src/dsymbol/conversion/first.d +++ b/dsymbol/src/dsymbol/conversion/first.d @@ -272,7 +272,7 @@ final class FirstPass : ASTVisitor else if (typeIdentifierPart.identifierOrTemplateInstance.templateInstance.templateArguments.templateSingleArgument) { auto singleArg = typeIdentifierPart.identifierOrTemplateInstance.templateInstance.templateArguments.templateSingleArgument; - symbol.acSymbol.tmplArgNames.insert(istring(singleArg.token.text)); + symbol.acSymbol.tmplArgNames ~= istring(singleArg.token.text); } } } diff --git a/dsymbol/src/dsymbol/conversion/second.d b/dsymbol/src/dsymbol/conversion/second.d index aad3e5d..f10453c 100644 --- a/dsymbol/src/dsymbol/conversion/second.d +++ b/dsymbol/src/dsymbol/conversion/second.d @@ -33,6 +33,7 @@ import std.experimental.allocator.gc_allocator : GCAllocator; import std.experimental.logger; import dparse.ast; import dparse.lexer; +import std.compiler; void secondPass(SemanticSymbol* currentSymbol, Scope* moduleScope, ref ModuleCache cache) { @@ -55,13 +56,6 @@ void secondPass(SemanticSymbol* currentSymbol, Scope* moduleScope, ref ModuleCac resolveType(currentSymbol.acSymbol, currentSymbol.typeLookups, moduleScope, cache); } - - if (currentSymbol.acSymbol.tmplArgNames.length > 0 && currentSymbol.acSymbol.type) - { - auto type = currentSymbol.acSymbol.type; - if (type.kind == structName || type.kind == className) - resolveTemplate(currentSymbol.acSymbol, type, moduleScope, cache); - } break; case importSymbol: if (currentSymbol.acSymbol.type is null) @@ -101,6 +95,19 @@ void secondPass(SemanticSymbol* currentSymbol, Scope* moduleScope, ref ModuleCac resolveMixinTemplates(currentSymbol.acSymbol, currentSymbol.typeLookups, moduleScope, cache); break; + case variableName: + if (currentSymbol.acSymbol.tmplArgNames.length > 0 && currentSymbol.acSymbol.type) + { + auto tArgNames = currentSymbol.acSymbol.tmplArgNames; + auto type = currentSymbol.acSymbol.type; + if (type.kind == structName || type.kind == className) + resolveTemplate(currentSymbol.acSymbol, type, tArgNames, moduleScope, cache); + } + else + { + warning("no type: ", currentSymbol.acSymbol.name," ", currentSymbol.acSymbol.kind); + } + break; default: break; } @@ -109,24 +116,30 @@ void secondPass(SemanticSymbol* currentSymbol, Scope* moduleScope, ref ModuleCac /** * Resolve template arguments */ -void resolveTemplate(DSymbol* sym, DSymbol* type, Scope* moduleScope, ref ModuleCache cache) +void resolveTemplate(DSymbol* sym, DSymbol* type, scope const istring[] tmplArgNames, Scope* moduleScope, ref ModuleCache cache) { - if (sym.tmplArgNames.length > 1) return; - auto argName = sym.tmplArgNames.back; + if (tmplArgNames.length > 1) return; + auto argName = tmplArgNames[0]; auto result = moduleScope.getSymbolsAtGlobalScope(argName); if (result.length > 0) { auto argSymbol = result[0]; - DSymbol* newType = GCAllocator.instance.make!DSymbol(type.name, type.kind, null); + DSymbol* newType = GCAllocator.instance.make!DSymbol("", CompletionKind.dummy, null); + newType.name = type.name; + newType.kind = type.kind; newType.qualifier = type.qualifier; newType.protection = type.protection; newType.symbolFile = type.symbolFile; newType.doc = type.doc; newType.callTip = type.callTip; + + DSymbol* currentT = null; foreach(part; type.opSlice()) { if (part.kind == CompletionKind.typeTmpParam) - { } + { + currentT = part; + } else if (part.type && part.type.kind == CompletionKind.typeTmpParam) { DSymbol* newPart = GCAllocator.instance.make!DSymbol(part.name, part.kind, argSymbol); @@ -135,14 +148,19 @@ void resolveTemplate(DSymbol* sym, DSymbol* type, Scope* moduleScope, ref Module newPart.symbolFile = part.symbolFile; newPart.doc = part.doc; newPart.callTip = part.callTip; + newPart.type = argSymbol; newType.addChild(newPart, true); } else { + if (part.tmplArgNames.length > 0) + { + auto innerArg = part.tmplArgNames[0]; + resolveTemplate(part, part.type, [argName], moduleScope, cache); + } newType.addChild(part, false); } } - sym.type = newType; sym.ownType = true; } diff --git a/dsymbol/src/dsymbol/symbol.d b/dsymbol/src/dsymbol/symbol.d index ad61b5c..6494f7a 100644 --- a/dsymbol/src/dsymbol/symbol.d +++ b/dsymbol/src/dsymbol/symbol.d @@ -384,7 +384,7 @@ struct DSymbol /** * Names of template arguments */ - UnrolledList!(istring) tmplArgNames; + istring[] tmplArgNames; /** * Function parameter symbols