store the type name into its own field, so we could resolve templates later

This commit is contained in:
ryuukk 2023-02-01 19:57:27 +01:00
parent 674f72750a
commit 7822f78056
3 changed files with 12 additions and 7 deletions

View File

@ -64,13 +64,14 @@ ScopeSymbolPair generateAutocompleteTrees(const(Token)[] tokens,
visited.insert(cast(size_t) part); visited.insert(cast(size_t) part);
// no type but a callTip, let's resolve its type // no type but a callTip, let's resolve its type
if (part.type is null && part.callTip !is null) if (part.type is null && part.typeSymbolName !is null)
{ {
auto typeName = part.callTip; import std.string: indexOf;
auto typeName = part.typeSymbolName;
// check if it is available in the scope // check if it is available in the scope
// otherwise grab its module symbol to check if it's publickly available // otherwise grab its module symbol to check if it's publickly available
auto result = sc.getSymbolsAtGlobalScope(typeName); auto result = sc.getSymbolsAtGlobalScope(istring(typeName));
if (result.length > 0) if (result.length > 0)
{ {
part.type = result[0]; part.type = result[0];
@ -80,7 +81,7 @@ ScopeSymbolPair generateAutocompleteTrees(const(Token)[] tokens,
{ {
if (part.symbolFile == "stdin") return; if (part.symbolFile == "stdin") return;
auto moduleSymbol = cache.getModuleSymbol(part.symbolFile); auto moduleSymbol = cache.getModuleSymbol(part.symbolFile);
auto first = moduleSymbol.getFirstPartNamed(typeName); auto first = moduleSymbol.getFirstPartNamed(istring(typeName));
if (first !is null) if (first !is null)
{ {
part.type = first; part.type = first;

View File

@ -246,9 +246,8 @@ do
currentSymbol = symbols[0]; currentSymbol = symbols[0];
else else
{ {
// store the callTip, that'll be useful to resolve the type later // store the part, that'll be useful to resolve the type later
if (symbol.callTip is null) symbol.typeSymbolName = istring(part);
symbol.callTip = istring(part);
return; return;
} }
} }

View File

@ -386,6 +386,11 @@ struct DSymbol
*/ */
DSymbol*[] functionParameters; DSymbol*[] functionParameters;
/**
* Used to resolve the type
*/
istring typeSymbolName;
private uint _location; private uint _location;
/** /**