Skip to content

Commit

Permalink
Merge pull request #758 from kmichaelk/trim-hover
Browse files Browse the repository at this point in the history
Remove unnecessary whitespace from hover, highlight code as TTCN-3
  • Loading branch information
moosq authored Sep 13, 2024
2 parents 90d2d70 + 30946a1 commit 60d62d3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions internal/lsp/hover.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func removeDuplicateNodes(nodes []*ttcn3.Node) []*ttcn3.Node {
func (md *MarkdownHover) Print(sign string, comment string, posRef string) protocol.MarkupContent {
// make line breaks conform to markdown spec
comment = strings.ReplaceAll(comment, "\n", " \n")
res := "```typescript\n" + string(sign) + "\n```\n"
res := "```ttcn3\n" + string(sign) + "\n```\n"
if len(comment) > 0 {
res += " - - -\n" + comment
}
Expand Down Expand Up @@ -114,14 +114,14 @@ func getSignature(def *ttcn3.Node) string {
sig.Write(content[node.Return.Pos():node.Return.End()])
}
case *syntax.ValueDecl, *syntax.TemplateDecl, *syntax.FormalPar, *syntax.StructTypeDecl, *syntax.MapTypeDecl, *syntax.ComponentTypeDecl, *syntax.EnumTypeDecl, *syntax.PortTypeDecl:
sig.Write(content[def.Node.Pos()-1 : def.Node.End()])
sig.Write(content[def.Node.Pos():def.Node.End()])
case *syntax.Field:
if parent := def.ParentOf(node); parent != nil {
if _, ok := parent.(*syntax.SubTypeDecl); ok {
prefix = "type "
}
}
sig.Write(content[def.Node.Pos()-1 : def.Node.End()])
sig.Write(content[def.Node.Pos():def.Node.End()])
case *syntax.Module:
fmt.Fprintf(&sig, "module %s\n", node.Name)
default:
Expand Down
6 changes: 3 additions & 3 deletions internal/lsp/hover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestMarkdownHoverForFunction(t *testing.T) {
&lsp.MarkdownHover{})

expected :=
"```typescript\n" +
"```ttcn3\n" +
"function myfunc(integer x)\n" +
" runs on Component\n" +
" system System\n" +
Expand All @@ -77,7 +77,7 @@ func TestPlainTextHoverForPortDefFromDecl(t *testing.T) {
&lsp.PlainTextHover{})

expected :=
" port P p1\n" +
"port P p1\n" +
"possible map / connect statements\n" +
"_________________________________\n" +
"/TestPlainTextHoverForPortDefFromDecl.ttcn3:9\n"
Expand All @@ -102,7 +102,7 @@ func TestPlainTextHoverForPortDefFromUsage(t *testing.T) {
&lsp.PlainTextHover{})

expected :=
" port P p1\n" +
"port P p1\n" +
"possible map / connect statements\n" +
"_________________________________\n" +
"/TestPlainTextHoverForPortDefFromUsage.ttcn3:9\n"
Expand Down

0 comments on commit 60d62d3

Please sign in to comment.