Skip to content

Commit 05c67e9

Browse files
committed
internal/lsp: add tests for cgo package users
We now have pretty good support for users of cgo packages. Add tests. Closes golang/go#35720. Change-Id: Icdc596038bc6fca1c08eacd199def12264cf512d Reviewed-on: https://go-review.googlesource.com/c/tools/+/208503 Run-TryBot: Heschi Kreinick <[email protected]> Reviewed-by: Rebecca Stambler <[email protected]>
1 parent ef6787d commit 05c67e9

File tree

5 files changed

+61
-2
lines changed

5 files changed

+61
-2
lines changed
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package cgo
2+
3+
/*
4+
#include <stdio.h>
5+
#include <stdlib.h>
6+
7+
void myprint(char* s) {
8+
printf("%s\n", s);
9+
}
10+
*/
11+
import "C"
12+
13+
import "fmt"
14+
15+
import "unsafe"
16+
17+
func Example() { //@mark(funccgoexample, "Example"),item(funccgoexample, "Example", "func()", "func")
18+
fmt.Println()
19+
cs := C.CString("Hello from stdio\n")
20+
C.myprint(cs)
21+
C.free(unsafe.Pointer(cs))
22+
}
23+
24+
func _() {
25+
Example()
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
-- funccgoexample-definition --
2+
cgo/declarecgo.go:17:6-13: defined here as func cgo.Example()
3+
-- funccgoexample-definition-json --
4+
{
5+
"span": {
6+
"uri": "file://cgo/declarecgo.go",
7+
"start": {
8+
"line": 17,
9+
"column": 6,
10+
"offset": 153
11+
},
12+
"end": {
13+
"line": 17,
14+
"column": 13,
15+
"offset": 160
16+
}
17+
},
18+
"description": "func cgo.Example()"
19+
}
20+
21+
-- funccgoexample-hover --
22+
func cgo.Example()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package cgoimport
2+
3+
import (
4+
"golang.org/x/tools/internal/lsp/cgo"
5+
)
6+
7+
func _() {
8+
cgo.Example() //@godef("ample", funccgoexample),complete("ample", funccgoexample)
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- funcexample-hover --
2+
func cgo.Example()

internal/lsp/testdata/summary.txt.golden

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-- summary --
2-
CompletionsCount = 215
2+
CompletionsCount = 216
33
CompletionSnippetCount = 51
44
UnimportedCompletionsCount = 3
55
DeepCompletionsCount = 5
@@ -11,7 +11,7 @@ FoldingRangesCount = 2
1111
FormatCount = 6
1212
ImportCount = 7
1313
SuggestedFixCount = 1
14-
DefinitionsCount = 37
14+
DefinitionsCount = 38
1515
TypeDefinitionsCount = 2
1616
HighlightsCount = 22
1717
ReferencesCount = 7

0 commit comments

Comments
 (0)