4 ms·
No. When working with JVM/typescript libraries you have their autocomplete information. If you need method autocomplete scoped to a type you can use the `..` m
by ilikehurdles 2y ago
No. When working with JVM/typescript libraries you have their autocomplete information.
If you need method autocomplete scoped to a type you can use the `..` macro for more concise call syntax:
(ns my-project.core
(:import (java.util ArrayList Collections)))
(defn example []
(let [list (ArrayList.)] ; ArrayList constructor can be autocompleted
(.. list
(add "Hello") ; The .add method on ArrayLists will be autocompleted
(add "World")
(add "Clojure"))
(Collections/sort list) ; The Collections.sort method will be autocompleted
list))
this other form will a also autocomplete everything after the dot (.) to call a method on an object:
(.toUpperCase some-str)
but the trick with this arrangement is to write that variable some-str first, then if you write . in front of it the autocompletes will be relevant to that object. But I gratuitously used threading macros like .. or -> to make it match java-style code (in other words: (-> some-str (.toUpperCase))).
- createaccount99 2y agoThat's cool, I had no idea. In clojure itself I suppose you eval code and then get autocompeletes from the repl output? -- I mean for stuff with no types
- simongray 2y agoAutocomplete also works for the functions and vars in the namespaces. You don't really use methods in Clojure unless you're doing interop with Java or JS.