Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow parsing the whole module #759

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions dsymbol/src/dsymbol/conversion/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class AutocompleteParser : Parser
{
if (!currentIs(tok!"{"))
return null;
if (current.index > cursorPosition)
if (cursorPosition != -1 && current.index > cursorPosition)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (cursorPosition != -1 && current.index > cursorPosition)
if (cursorPosition == -1) return super.parseBlockStatement();
if (current.index > cursorPosition)

I'm thinking that's all that's needed, no? Otherwise the code always sets a bookmark, skips braces and then immediately rolls back again.

{
BlockStatement bs = allocator.make!(BlockStatement);
bs.startLocation = current.index;
Expand All @@ -126,7 +126,7 @@ class AutocompleteParser : Parser
immutable start = current.index;
auto b = setBookmark();
skipBraces();
if (tokens[index - 1].index < cursorPosition)
if (cursorPosition != -1 && tokens[index - 1].index < cursorPosition)
{
abandonBookmark(b);
BlockStatement bs = allocator.make!BlockStatement();
Expand All @@ -142,7 +142,7 @@ class AutocompleteParser : Parser
}

private:
size_t cursorPosition;
long cursorPosition;
}

class SimpleParser : Parser
Expand Down
Loading