Skip to content

Commit

Permalink
sync dsymbol to master
Browse files Browse the repository at this point in the history
  • Loading branch information
WebFreak001 committed Oct 12, 2022
1 parent 3521b4f commit 83e03ea
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
19 changes: 8 additions & 11 deletions dsymbol/src/dsymbol/conversion/first.d
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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(
Expand All @@ -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);
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -1217,7 +1215,6 @@ private:

ModuleCache* cache;

bool includeParameterSymbols;
bool skipBaseClassesOfNewAnon;

ubyte foreachTypeIndexOfInterest;
Expand Down
2 changes: 1 addition & 1 deletion dsymbol/src/dsymbol/conversion/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion dsymbol/src/dsymbol/modulecache.d
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions dsymbol/src/dsymbol/symbol.d
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
2 changes: 1 addition & 1 deletion dsymbol/src/dsymbol/tests.d
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 83e03ea

Please sign in to comment.