A hover shows a signature with a where clause
A nameless (: Type) above a definition was only taken when keywords followed the type, so one ending in (where (Trait %a)) was not, and the hover over +milliseconds or any constrained function had no type. The signature is now shown whole, the name put in after the colon, so its constraint and keywords are in the hover too. 🤖 Generated with [ECA](https://eca.dev) (anthropic/claude-opus-4-8) Co-Authored-By: eca-agent <git@eca.dev>
This commit is contained in:
parent
28341632fd
commit
29977ca301
2 changed files with 64 additions and 5 deletions
|
|
@ -347,6 +347,56 @@ def documented(server, tmp):
|
|||
server.diagnostics_after("textDocument/didClose", uri)
|
||||
|
||||
|
||||
CONSTRAINED = """(import (std prelude)
|
||||
(std datetime))
|
||||
|
||||
(def/trait (Sized %a)
|
||||
(: size (-> %a int)))
|
||||
|
||||
(impl (Sized string)
|
||||
(defun (size s) (string-length s)))
|
||||
|
||||
(: (-> %a int) (where (Sized %a)))
|
||||
(defun (twice x) (* 2 (size x)))
|
||||
|
||||
(: main (-> (Vec string) int))
|
||||
(defun (main args)
|
||||
(ignore (+milliseconds (now) 5L))
|
||||
(twice "ab"))
|
||||
"""
|
||||
|
||||
|
||||
def constrained(server, tmp):
|
||||
path = os.path.join(tmp, "constrained.bjo")
|
||||
uri = "file://" + path
|
||||
with open(path, "w") as f:
|
||||
f.write(CONSTRAINED)
|
||||
found = server.diagnostics_after("textDocument/didOpen", uri, CONSTRAINED)
|
||||
expect("the constrained file checks", found == [], found)
|
||||
|
||||
def hover(needle):
|
||||
answer = server.send(
|
||||
"textDocument/hover",
|
||||
{"textDocument": {"uri": uri}, "position": position_of(CONSTRAINED, needle)},
|
||||
request=True,
|
||||
)
|
||||
return answer["result"]["contents"]["value"] if answer["result"] else None
|
||||
|
||||
h = hover("(twice \"ab")
|
||||
expect(
|
||||
"hover: a nameless signature with a where clause, named",
|
||||
h and "(: twice (-> %a int) (where (Sized %a)))" in h and "(defun (twice x))" in h,
|
||||
h,
|
||||
)
|
||||
h = hover("(+milliseconds")
|
||||
expect(
|
||||
"hover: an imported one with a where clause",
|
||||
h and "(: +milliseconds (-> %a long %a) (where (TimeArith %a)))" in h,
|
||||
h,
|
||||
)
|
||||
server.diagnostics_after("textDocument/didClose", uri)
|
||||
|
||||
|
||||
COMPLETING = """(import (std prelude))
|
||||
|
||||
(defun (list-unwind xs) xs)
|
||||
|
|
@ -1200,6 +1250,7 @@ with tempfile.TemporaryDirectory() as tmp:
|
|||
|
||||
symbols_and_definitions(server, tmp)
|
||||
documented(server, tmp)
|
||||
constrained(server, tmp)
|
||||
completing(server, tmp)
|
||||
locals_(server, tmp)
|
||||
inferred(server, tmp)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue