Properly resolve symbols with the global-scope operator
This commit is contained in:
parent
74f93610c2
commit
1afdec1c63
18
actypes.d
18
actypes.d
|
|
@ -233,14 +233,9 @@ struct Scope
|
|||
{
|
||||
import std.range;
|
||||
ACSymbol s = ACSymbol(name);
|
||||
auto r = array(symbols.equalRange(&s));
|
||||
foreach (i; r)
|
||||
{
|
||||
import std.string;
|
||||
assert (i.name == name, format("%s %s %d", i.name, name, r.length));
|
||||
}
|
||||
if (r.length > 0)
|
||||
return cast(typeof(return)) r;
|
||||
auto er = symbols.equalRange(&s);
|
||||
if (!er.empty)
|
||||
return cast(typeof(return)) array(er);
|
||||
if (parent is null)
|
||||
return [];
|
||||
return parent.getSymbolsByName(name);
|
||||
|
|
@ -262,6 +257,13 @@ struct Scope
|
|||
return s.getSymbolsByName(name);
|
||||
}
|
||||
|
||||
ACSymbol*[] getSymbolsAtGlobalScope(string name)
|
||||
{
|
||||
if (parent !is null)
|
||||
return parent.getSymbolsAtGlobalScope(name);
|
||||
return getSymbolsByName(name);
|
||||
}
|
||||
|
||||
/// Imports contained in this scope
|
||||
UnrolledList!(ImportInformation*) importInformation;
|
||||
|
||||
|
|
|
|||
|
|
@ -299,8 +299,16 @@ ACSymbol*[] getSymbolsByTokenChain(T)(Scope* completionScope,
|
|||
Log.trace("Getting symbols from token chain",
|
||||
tokens.map!stringToken);
|
||||
// Find the symbol corresponding to the beginning of the chain
|
||||
ACSymbol*[] symbols = completionScope.getSymbolsByNameAndCursor(
|
||||
stringToken(tokens[0]), cursorPosition);
|
||||
ACSymbol*[] symbols;
|
||||
if (tokens[0] == tok!"." && tokens.length > 1)
|
||||
{
|
||||
tokens = tokens[1 .. $];
|
||||
Log.info("Looking for ", stringToken(tokens[0]), " at global scope");
|
||||
symbols = completionScope.getSymbolsAtGlobalScope(stringToken(tokens[0]));
|
||||
}
|
||||
else
|
||||
symbols = completionScope.getSymbolsByNameAndCursor(stringToken(tokens[0]), cursorPosition);
|
||||
|
||||
if (symbols.length == 0)
|
||||
{
|
||||
Log.error("Could not find declaration of ", stringToken(tokens[0]),
|
||||
|
|
|
|||
Loading…
Reference in New Issue