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