From 83e03eac6a51a772fc200d353c0d97995e8ff0a8 Mon Sep 17 00:00:00 2001 From: WebFreak001 Date: Wed, 12 Oct 2022 15:42:27 +0200 Subject: [PATCH] sync dsymbol to master --- dsymbol/src/dsymbol/conversion/first.d | 19 ++++++++----------- dsymbol/src/dsymbol/conversion/package.d | 2 +- dsymbol/src/dsymbol/modulecache.d | 2 +- dsymbol/src/dsymbol/symbol.d | 6 ++++++ dsymbol/src/dsymbol/tests.d | 2 +- 5 files changed, 17 insertions(+), 14 deletions(-) diff --git a/dsymbol/src/dsymbol/conversion/first.d b/dsymbol/src/dsymbol/conversion/first.d index 3a8f1957..69b51a06 100644 --- a/dsymbol/src/dsymbol/conversion/first.d +++ b/dsymbol/src/dsymbol/conversion/first.d @@ -62,12 +62,10 @@ final class FirstPass : ASTVisitor * symbolFile = path to the file being converted * symbolAllocator = allocator used for the auto-complete symbols * semanticAllocator = allocator used for semantic symbols - * includeParameterSymbols = include parameter symbols as children of - * function decalarations and constructors */ this(const Module mod, istring symbolFile, RCIAllocator symbolAllocator, - RCIAllocator semanticAllocator, bool includeParameterSymbols, - ModuleCache* cache, CacheEntry* entry = null) + RCIAllocator semanticAllocator, + ModuleCache* cache, CacheEntry* entry = null) in { assert(mod); @@ -81,7 +79,6 @@ final class FirstPass : ASTVisitor this.symbolFile = symbolFile; this.symbolAllocator = symbolAllocator; this.semanticAllocator = semanticAllocator; - this.includeParameterSymbols = includeParameterSymbols; this.entry = entry; this.cache = cache; } @@ -158,11 +155,8 @@ final class FirstPass : ASTVisitor } else { - immutable ips = includeParameterSymbols; - includeParameterSymbols = false; processParameters(currentSymbol, dec.returnType, currentSymbol.acSymbol.name, dec.parameters, dec.templateParameters); - includeParameterSymbols = ips; } } @@ -970,8 +964,9 @@ private: const TemplateParameters templateParameters) { processTemplateParameters(symbol, templateParameters); - if (includeParameterSymbols && parameters !is null) + if (parameters !is null) { + currentSymbol.acSymbol.functionParameters.reserve(parameters.parameters.length); foreach (const Parameter p; parameters.parameters) { SemanticSymbol* parameter = allocateSemanticSymbol( @@ -981,6 +976,9 @@ private: addTypeToLookups(parameter.typeLookups, p.type); parameter.parent = currentSymbol; currentSymbol.acSymbol.argNames.insert(parameter.acSymbol.name); + + currentSymbol.acSymbol.functionParameters ~= parameter.acSymbol; + currentSymbol.addChild(parameter, true); currentScope.addSymbol(parameter.acSymbol, false); } @@ -1008,7 +1006,7 @@ private: void processTemplateParameters(SemanticSymbol* symbol, const TemplateParameters templateParameters) { - if (includeParameterSymbols && templateParameters !is null + if (templateParameters !is null && templateParameters.templateParameterList !is null) { foreach (const TemplateParameter p; templateParameters.templateParameterList.items) @@ -1217,7 +1215,6 @@ private: ModuleCache* cache; - bool includeParameterSymbols; bool skipBaseClassesOfNewAnon; ubyte foreachTypeIndexOfInterest; diff --git a/dsymbol/src/dsymbol/conversion/package.d b/dsymbol/src/dsymbol/conversion/package.d index 268d0e79..9249173f 100644 --- a/dsymbol/src/dsymbol/conversion/package.d +++ b/dsymbol/src/dsymbol/conversion/package.d @@ -43,7 +43,7 @@ ScopeSymbolPair generateAutocompleteTrees(const(Token)[] tokens, parseAllocator, cursorPosition); scope first = new FirstPass(m, internString("stdin"), symbolAllocator, - symbolAllocator, true, &cache); + symbolAllocator, &cache); first.run(); secondPass(first.rootSymbol, first.moduleScope, cache); diff --git a/dsymbol/src/dsymbol/modulecache.d b/dsymbol/src/dsymbol/modulecache.d index 5c6bdedc..b943d19c 100644 --- a/dsymbol/src/dsymbol/modulecache.d +++ b/dsymbol/src/dsymbol/modulecache.d @@ -205,7 +205,7 @@ struct ModuleCache assert (!symbolAllocator.isNull); scope first = new FirstPass(m, cachedLocation, symbolAllocator, - semanticAllocator.allocatorObject, false, &this, newEntry); + semanticAllocator.allocatorObject, &this, newEntry); first.run(); secondPass(first.rootSymbol, first.moduleScope, this); diff --git a/dsymbol/src/dsymbol/symbol.d b/dsymbol/src/dsymbol/symbol.d index 13837764..44263e16 100644 --- a/dsymbol/src/dsymbol/symbol.d +++ b/dsymbol/src/dsymbol/symbol.d @@ -375,8 +375,14 @@ struct DSymbol /** * Names of function arguments */ + // TODO: remove since we have function arguments UnrolledList!(istring) argNames; + /** + * Function parameter symbols + */ + DSymbol*[] functionParameters; + private uint _location; /** diff --git a/dsymbol/src/dsymbol/tests.d b/dsymbol/src/dsymbol/tests.d index 2d6f8788..4a56b698 100644 --- a/dsymbol/src/dsymbol/tests.d +++ b/dsymbol/src/dsymbol/tests.d @@ -538,7 +538,7 @@ ScopeSymbolPair generateAutocompleteTrees(string source, string filename, ref Mo Module m = parseModule(tokens, filename, &rba); scope first = new FirstPass(m, internString(filename), - theAllocator, theAllocator, true, &cache); + theAllocator, theAllocator, &cache); first.run(); secondPass(first.rootSymbol, first.moduleScope, cache);