Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary whitespace from hover, highlight code as TTCN-3 #758

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading