Make static completion context-aware#59
Merged
Merged
Conversation
The source discarded the completion context, so it couldn't tell where in the form the cursor was. It now parses the context once and uses it for two things compliment also does: - inside a (:require [some.ns :refer [__prefix__]]) clause it completes that namespace's public vars (scoped), instead of the usual grab-bag - special forms are only offered at the head of a list, not in argument position The require/refer detection is ported from compliment's vars source but wired to the cljs analyzer for the actual var lookup. Import-list completion is intentionally left out - cljs has no ready catalog of importable Closure classes to offer.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The static source discarded the completion context entirely, so it couldn't tell where in the form the cursor sat. It now parses the context once and uses it for two things compliment also does:
(:require [some.ns :refer [__prefix__]])clause, it completes that namespace's public vars (scoped) instead of the usual grab-bag - so[clojure.string :refer [bl|]]offersblank?, not everybl*in scope.The refer detection is ported from compliment's vars source but wired to the cljs analyzer for the actual var lookup. I left import-list completion out on purpose - unlike the JVM, cljs has no ready catalog of importable Closure classes to offer, so there's nothing clean to complete against there.
New tests for both, green under CLJS 1.11 and 1.12.