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;
|
import std.range;
|
||||||
ACSymbol s = ACSymbol(name);
|
ACSymbol s = ACSymbol(name);
|
||||||
auto r = array(symbols.equalRange(&s));
|
auto er = symbols.equalRange(&s);
|
||||||
foreach (i; r)
|
if (!er.empty)
|
||||||
{
|
return cast(typeof(return)) array(er);
|
||||||
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;
|
|
||||||
if (parent is null)
|
if (parent is null)
|
||||||
return [];
|
return [];
|
||||||
return parent.getSymbolsByName(name);
|
return parent.getSymbolsByName(name);
|
||||||
|
|
@ -262,6 +257,13 @@ struct Scope
|
||||||
return s.getSymbolsByName(name);
|
return s.getSymbolsByName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ACSymbol*[] getSymbolsAtGlobalScope(string name)
|
||||||
|
{
|
||||||
|
if (parent !is null)
|
||||||
|
return parent.getSymbolsAtGlobalScope(name);
|
||||||
|
return getSymbolsByName(name);
|
||||||
|
}
|
||||||
|
|
||||||
/// Imports contained in this scope
|
/// Imports contained in this scope
|
||||||
UnrolledList!(ImportInformation*) importInformation;
|
UnrolledList!(ImportInformation*) importInformation;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -299,8 +299,16 @@ ACSymbol*[] getSymbolsByTokenChain(T)(Scope* completionScope,
|
||||||
Log.trace("Getting symbols from token chain",
|
Log.trace("Getting symbols from token chain",
|
||||||
tokens.map!stringToken);
|
tokens.map!stringToken);
|
||||||
// Find the symbol corresponding to the beginning of the chain
|
// Find the symbol corresponding to the beginning of the chain
|
||||||
ACSymbol*[] symbols = completionScope.getSymbolsByNameAndCursor(
|
ACSymbol*[] symbols;
|
||||||
stringToken(tokens[0]), cursorPosition);
|
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)
|
if (symbols.length == 0)
|
||||||
{
|
{
|
||||||
Log.error("Could not find declaration of ", stringToken(tokens[0]),
|
Log.error("Could not find declaration of ", stringToken(tokens[0]),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue