summary refs log tree commit diff stats
path: root/nimsuggest/tests
diff options
context:
space:
mode:
authorIvan Yonchovski <yyoncho@users.noreply.github.com>2022-07-15 20:56:05 +0300
committerGitHub <noreply@github.com>2022-07-15 19:56:05 +0200
commite636c211b0815497bc83a07424a06b03439119cd (patch)
treeaa8c75cde36a6912d792ff653db49973df4c8fe6 /nimsuggest/tests
parent417b90a7e5b88bfc0ad1bfbbc81a3205c99e128e (diff)
downloadNim-e636c211b0815497bc83a07424a06b03439119cd.tar.gz
Implement type command (#19944)
* Implement type command

- this will be mapped to textDocument/typeDefinition in LSP protocol. It will be
very useful for `nim` in particular because typically most of the time the type
is inferred.

* Update nimsuggest/nimsuggest.nim

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
Diffstat (limited to 'nimsuggest/tests')
-rw-r--r--nimsuggest/tests/tv3_typeDefinition.nim32
1 files changed, 32 insertions, 0 deletions
diff --git a/nimsuggest/tests/tv3_typeDefinition.nim b/nimsuggest/tests/tv3_typeDefinition.nim
new file mode 100644
index 000000000..f86d12cc6
--- /dev/null
+++ b/nimsuggest/tests/tv3_typeDefinition.nim
@@ -0,0 +1,32 @@
+# tests v3
+
+type
+  Foo* = ref object of RootObj
+    bar*: string
+
+proc test(ff: Foo) =
+  echo f#[!]#f.bar
+
+type
+  Fo#[!]#o2* = ref object of RootObj
+
+type
+  FooGeneric[T] = ref object of RootObj
+    bar*: T
+
+let fooGeneric = FooGeneric[string]()
+echo fo#[!]#oGeneric.bar
+
+# bad type
+echo unde#[!]#fined
+
+discard """
+$nimsuggest --v3 --tester $file
+>type $1
+type	skType	tv3_typeDefinition.Foo	Foo	$file	4	2	""	100
+>type $2
+type	skType	tv3_typeDefinition.Foo2	Foo2	$file	11	2	""	100
+>type $3
+type	skType	tv3_typeDefinition.FooGeneric	FooGeneric	$file	14	2	""	100
+>type $4
+"""