Fix #73
This commit is contained in:
parent
9971f08513
commit
c3eaeafad1
|
@ -348,7 +348,11 @@ final class FirstPass : ASTVisitor
|
|||
{
|
||||
foreach (child; currentSymbol.children)
|
||||
{
|
||||
child.acSymbol.location = s.startLocation + 1;
|
||||
if (child.acSymbol.location == size_t.max)
|
||||
{
|
||||
// Log.trace("Reassigning location of ", child.acSymbol.name);
|
||||
child.acSymbol.location = s.startLocation + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (blockStatement.declarationsAndStatements !is null)
|
||||
|
@ -425,7 +429,7 @@ private:
|
|||
foreach (Parameter p; parameters.parameters)
|
||||
{
|
||||
SemanticSymbol* parameter = new SemanticSymbol(p.name.value.dup,
|
||||
CompletionKind.variableName, symbolFile, p.name.startIndex);
|
||||
CompletionKind.variableName, symbolFile, size_t.max);
|
||||
parameter.type = p.type;
|
||||
symbol.addChild(parameter);
|
||||
parameter.parent = symbol;
|
||||
|
@ -433,13 +437,13 @@ private:
|
|||
if (parameters.hasVarargs)
|
||||
{
|
||||
SemanticSymbol* argptr = new SemanticSymbol("_argptr",
|
||||
CompletionKind.variableName, null, 0);
|
||||
CompletionKind.variableName, null, size_t.max);
|
||||
argptr.type = argptrType;
|
||||
argptr.parent = symbol;
|
||||
symbol.addChild(argptr);
|
||||
|
||||
SemanticSymbol* arguments = new SemanticSymbol("_arguments",
|
||||
CompletionKind.variableName, null, 0);
|
||||
CompletionKind.variableName, null, size_t.max);
|
||||
arguments.type = argumentsType;
|
||||
arguments.parent = symbol;
|
||||
symbol.addChild(arguments);
|
||||
|
@ -511,8 +515,8 @@ private:
|
|||
|
||||
void assignToScopes(const(ACSymbol)* currentSymbol)
|
||||
{
|
||||
moduleScope.getScopeByCursor(currentSymbol.location).symbols
|
||||
~= currentSymbol;
|
||||
Scope* s = moduleScope.getScopeByCursor(currentSymbol.location);
|
||||
s.symbols ~= currentSymbol;
|
||||
foreach (part; currentSymbol.parts)
|
||||
assignToScopes(part);
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ import stupidlog;
|
|||
|
||||
AutocompleteResponse findDeclaration(const AutocompleteRequest request)
|
||||
{
|
||||
Log.info("Finding declaration");
|
||||
Log.trace("Finding declaration");
|
||||
AutocompleteResponse response;
|
||||
LexerConfig config;
|
||||
config.fileName = "stdin";
|
||||
|
@ -59,7 +59,7 @@ AutocompleteResponse findDeclaration(const AutocompleteRequest request)
|
|||
|
||||
auto beforeTokens = sortedTokens.lowerBound(cast(size_t) request.cursorPosition);
|
||||
|
||||
Log.info("Token at cursor: ", beforeTokens[$ - 1]);
|
||||
Log.trace("Token at cursor: ", beforeTokens[$ - 1]);
|
||||
|
||||
const(Scope)* completionScope = generateAutocompleteTrees(tokenArray, "stdin");
|
||||
auto expression = getExpression(beforeTokens);
|
||||
|
@ -85,14 +85,21 @@ AutocompleteResponse findDeclaration(const AutocompleteRequest request)
|
|||
const(ACSymbol)*[] getSymbolsByTokenChain(T)(const(Scope)* completionScope,
|
||||
T tokens, size_t cursorPosition, CompletionType completionType)
|
||||
{
|
||||
Log.trace("Getting symbols from token chain", tokens);
|
||||
// Find the symbol corresponding to the beginning of the chain
|
||||
const(ACSymbol)*[] symbols = completionScope.getSymbolsByNameAndCursor(
|
||||
tokens[0].value, cursorPosition);
|
||||
if (symbols.length == 0)
|
||||
{
|
||||
Log.trace("Could not find declaration of ", tokens[0].value);
|
||||
Log.error("Could not find declaration of ", tokens[0].value,
|
||||
" from position ", cursorPosition);
|
||||
return [];
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.trace("Found ", symbols[0].name, " at ", symbols[0].location,
|
||||
" with type ", symbols[0].type);
|
||||
}
|
||||
|
||||
if (completionType == CompletionType.identifiers
|
||||
&& symbols[0].kind == CompletionKind.memberVariableName
|
||||
|
|
2
dscanner
2
dscanner
|
@ -1 +1 @@
|
|||
Subproject commit 87ed0bd3b42758488ad59fb26f2180a01740dfa9
|
||||
Subproject commit 00768c371a6d81469a713a5e671d7a2fd7ac189d
|
Loading…
Reference in New Issue