Last active
February 14, 2017 00:13
-
-
Save cursive-ide/f4f877b32c298ffeac77dfb0bdec3f83 to your computer and use it in GitHub Desktop.
This file contains 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
; Before | |
(defn light-keys [symbol language] | |
(let [states (light.resolve/resolve-states (psi/containing-file symbol) language)] | |
(loop [current (psi/parent symbol)] ; <- infinite loop if current is nil | |
(if-let [state (get states current)] ; because psi/parent nil puns | |
(light.resolve/resolve-keys symbol state) | |
(if (psi/file? (psi/parent current)) | |
(recur (first (filter psi/significant? (psi/prev-siblings current)))) ; <- first can return nil | |
(recur (psi/parent current))))))) | |
; After | |
(defn light-keys [symbol language] | |
(let [states (light.resolve/resolve-states (psi/containing-file symbol) language)] | |
(loop [current (psi/parent symbol)] | |
(when current ; <- fix | |
(if-let [state (get states current)] | |
(light.resolve/resolve-keys symbol state) | |
(if (psi/file? (psi/parent current)) | |
(recur (first (filter psi/significant? (psi/prev-siblings current)))) | |
(recur (psi/parent current)))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment