Golang language server - SkorikSergey/Language-servers-test-plan GitHub Wiki
Preconditions:
- Create workspace from the Go stack with desktop-go-simple project.
- Enable Golang language server in the Installers tab and start the workspace.
- Create "format.go" file with content:
package
main
import (
"fmt"
"math"
)
func print( ) {
fmt.Printf("Hello, world. Sqrt(2) = %v\n", math.Sqrt(2))
}
- Create "main.go" file with content:
package main
import (
"fmt"
"math"
)
func main() {
fmt.Printf("Hello, world. Sqrt(2) = %v\n", math.Sqrt(2))
}
- Create "print.go" file with content:
package main
import (
"fmt"
)
const COLOR_RED = "\x1b[31;1m "
const COLOR_GREEN = "\x1b[32;1m "
const COLOR_YELLOW = "\x1b[33;1m "
const COLOR_BLACK = "\x1b[34;1m "
func Print(color string, s string) {
fmt.Printf("%s %s\n", color, s)
}
- Create "towers.go" file with content:
package main
import (
"fmt"
)
var count int
func hanoi(n int, a, b, c string) {
if n == 1 {
count++
Print(COLOR_GREEN, fmt.Sprintf("Step %d: move disk from %s to %s\n", count, a, c))
return
}
hanoi(n-1, a, c, b)
count++
Print(COLOR_YELLOW, fmt.Sprintf("Step %d: move disk from %s to %s\n", count, a, c))
hanoi(n-1, b, a, c)
}
func main() {
hanoi(3, "1", "2", "3")
}
Testing process
- Language server initialization
- From the project open "main.go" file.
- Check
Finished running tool: /usr/local/go/bin/go buildmessage in the dev-machine console.
- Autocomplete feature
- Open "main.go" file.
- Create a new line on line 10.
- Add
fmt.Pcode and launch autocomplete by Ctrl+Space. - Check that proposal
Printfis present. - Delete created line.
- Find definition feature
- Open "towers.go" file.
- Set cursor to 12:5 position and invoke Assistant -> Find Definition. The "print.go" file should be opened and function
Printshould be selected. - Close the
print.gofile. And repeat previous step using F4 key instead of Assistant -> Find Definition invocation.
- Code validation feature, Comment line
- Open "main.go" file.
- Move cursor in 1:1 position.
- Type
psymbol there and check that error marker is appeared. Click on error marker - the proposal widget should be showexpected 'package', found 'IDENT' ppackagemessage. - Restore content. Error marker should disappear.
- Move cursor in line 1 position and comment this line by Ctrl+/ buttons.
- Check that text in line 3 was changed from
package mainto//package main. - Uncomment this line by Ctrl+/ buttons.
- Hover feature
- Open "towers.go" file.
- Move mouse pointer on position 12:15
- Wait hover popup is appeared with text
const COLOR_YELLOW string = "\x1b[33;1m ". - Move mouse pointer on position 22:8
- Wait hover popup is appeared with text
main redeclared in this block previous declaration at.
- Format code feature
- Open "format.go" file.
- Start Format option from context menu;
- Check that the file content was changed to:
package main
import (
"fmt"
"math"
)
func print() {
fmt.Printf("Hello, world. Sqrt(2) = %v\n", math.Sqrt(2))
}
Rename
- Open "towers.py" file.
- Select "n" variable in line 10.
- Start Rename feature by Shift+F6 or from Assistant menu.
- Type new variable name.
- Check that the variable name was changed.
Find References
- Open "towers.py" file.
- Select
countvariable - Start Find References feature by pressing Alt+F7 buttons or from Assistant menu.
- Check that Find References panel is opened with
/desktop-go-simple/towers.go From:7:5 To:7:10result in it.
Signature Help
- Open "towers.go" file.
- Type
hanoion line 24. - Type '(' symbol and wait for hover popup with
hanoi(n int, a, b, c string)text. - Delete added line.
Go To Symbol
- Open "towers.go" file.
- Start Go To Symbol feature by Ctrl+F12 buttons or from Assistant menu.
- Wait for Go To Symbol form is opened with next lines:
main symbols(4)
count
hanoi
main
- Click on any of them and check that it correctly selected in file.
Find Project Symbol
- Open "towers.go" file.
- Start Find Project Symbol feature by Alt+N buttons or from Assistant menu.
- Type
Printin Find Project Symbol form input. - Wait for
Print /desktop-go-simple/print.goline. - Type
hanoiin Find Project Symbol form input. - Wait for
hanoi /desktop-go-simple/towers.goline. - Click on any of them and check that it correctly selected in file.