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

Autocomplete for scratch.u definition names #3874

Draft
wants to merge 5 commits into
base: trunk
Choose a base branch
from

Conversation

ChrisPenner
Copy link
Contributor

@ChrisPenner ChrisPenner commented Mar 20, 2023

Overview

Currently auto-complete only includes definitions are checked into the codebase, so it won't include any new definitions in the file. This PR adds local definitions to autocomplete.

  • TODO: Add the type signature to autocomplete if the file typechecks.

Implementation notes

The actual addition of the names is trivial, but it's not useful to only include these names when the file is parsing/typechecking since auto-complete is usually triggered while typing in an invalid state, so we add a new FileAnalysisTriple type which includes:

  1. An analysis of the file as it exists at the current moment
  2. The most recent analysis that successfully typechecked
  3. The most recent analysis that successfully parsed

So I make some changes to the LSP's update loop to keep track of those.

Test coverage

Manual testing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No changes here, just moved to fix cyclic imports

@@ -97,6 +98,7 @@ checkFile doc = runMaybeT $ do
& toRangeMap
let fileSummary = mkFileSummary parsedFile typecheckedFile
let tokenMap = getTokenMap tokens
let fileCompletions = fromMaybe mempty ((namesToCompletionTree . UF.typecheckedToNames <$> typecheckedFile) <|> (namesToCompletionTree . UF.toNames <$> parsedFile))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the line that actually computes the new completions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant