Skip to content

Commit

Permalink
what if we didn't parse the document for every token in the document
Browse files Browse the repository at this point in the history
  • Loading branch information
brianush1 committed Dec 10, 2023
1 parent 584b245 commit 51ad21d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/dcd/server/autocomplete/localuse.d
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,13 @@ public AutocompleteResponse findLocalUse(AutocompleteRequest request,
config.fileName = "";
const(Token)[] tokenArray = getTokensForParser(cast(ubyte[]) request.sourceCode,
config, &cache);
auto sortedTokens = assumeSorted(tokenArray);
ScopeSymbolPair pair = generateAutocompleteTrees(tokenArray,
&rba, request.cursorPosition, moduleCache);

SymbolStuff getSymbolsAtCursor(size_t cursorPosition)
{
auto sortedTokens = assumeSorted(tokenArray);
auto beforeTokens = sortedTokens.lowerBound(cursorPosition);
ScopeSymbolPair pair = generateAutocompleteTrees(tokenArray,
&rba, request.cursorPosition, moduleCache);
auto expression = getExpression(beforeTokens);
return SymbolStuff(getSymbolsByTokenChain(pair.scope_, expression,
cursorPosition, CompletionType.location), pair.symbol, pair.scope_);
Expand Down

0 comments on commit 51ad21d

Please sign in to comment.