Skip to content

Commit

Permalink
update:codelens for proj test classfile
Browse files Browse the repository at this point in the history
  • Loading branch information
luoliwoshang committed May 11, 2024
1 parent 7f8a235 commit f97d0b4
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions gopls/internal/lsp/source/code_lens_gox.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,15 @@ func goxTestCodeLens(pgf *ParsedGopFile, classType string) ([]protocol.CodeLens,
if err != nil {
return nil, err
}
codelens := []protocol.CodeLens{
{Range: rng, Command: &protocol.Command{
Title: "run test package",
Command: "gop.test.package",
}},
}
if pgf.File.IsProj && classType == "main" { //goxls:proj gox test
return codelens, nil
}
args, err := command.MarshalArgs(
map[string]string{
"functionName": "Test_" + classType,
Expand All @@ -223,16 +232,13 @@ func goxTestCodeLens(pgf *ParsedGopFile, classType string) ([]protocol.CodeLens,
if err != nil {
return nil, err
}
codelens := []protocol.CodeLens{
{Range: rng, Command: &protocol.Command{
Title: "run test package",
Command: "gop.test.package",
}},
{Range: rng, Command: &protocol.Command{ // goxls: add test cursor as test file
codelens = append(codelens, protocol.CodeLens{
Range: rng,
Command: &protocol.Command{
Title: "run file tests",
Command: "gop.test.cursor",
Arguments: args,
}},
}
},
})
return codelens, nil
}

0 comments on commit f97d0b4

Please sign in to comment.