Skip to content

Commit ed22a4b

Browse files
committed
Added implementation for 'textDocument/hover' message
1 parent 436052b commit ed22a4b

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

Diff for: handler/handler.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,15 @@ func (handler *InoHandler) HandleMessageFromIDE(ctx context.Context, conn *jsonr
147147
err = handler.ino2cppTextDocumentPositionParams(&p.TextDocumentPositionParams)
148148
log.Printf(" --> completion(%s:%d:%d)\n", p.TextDocument.URI, p.Position.Line, p.Position.Character)
149149

150+
case *HoverParams:
151+
// method: "textDocument/hover"
152+
uri = p.TextDocument.URI
153+
doc := &p.TextDocumentPositionParams
154+
log.Printf("--> hover(%s:%d:%d)\n", doc.TextDocument.URI, doc.Position.Line, doc.Position.Character)
155+
156+
err = handler.ino2cppTextDocumentPositionParams(doc)
157+
log.Printf(" --> hover(%s:%d:%d)\n", doc.TextDocument.URI, doc.Position.Line, doc.Position.Character)
158+
150159
case *lsp.DidChangeTextDocumentParams: // "textDocument/didChange":
151160
uri = p.TextDocument.URI
152161
err = handler.ino2cppDidChangeTextDocumentParams(ctx, p)
@@ -162,8 +171,6 @@ func (handler *InoHandler) HandleMessageFromIDE(ctx context.Context, conn *jsonr
162171
err = handler.ino2cppCodeActionParams(p)
163172
// case "textDocument/signatureHelp":
164173
// fallthrough
165-
// case "textDocument/hover":
166-
// fallthrough
167174
// case "textDocument/definition":
168175
// fallthrough
169176
// case "textDocument/typeDefinition":

Diff for: handler/protocol.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ func readParams(method string, raw *json.RawMessage) (interface{}, error) {
4141
case "textDocument/signatureHelp":
4242
fallthrough
4343
case "textDocument/hover":
44-
fallthrough
44+
params := new(HoverParams)
45+
err := json.Unmarshal(*raw, params)
46+
return params, err
4547
case "textDocument/definition":
4648
fallthrough
4749
case "textDocument/typeDefinition":
@@ -222,6 +224,12 @@ func (entry *commandOrCodeAction) MarshalJSON() ([]byte, error) {
222224
return nil, nil
223225
}
224226

227+
// HoverParams structure according to LSP
228+
type HoverParams struct {
229+
lsp.TextDocumentPositionParams
230+
// lsp.WorkDoneProgressParams
231+
}
232+
225233
// Hover structure according to LSP
226234
type Hover struct {
227235
Contents MarkupContent `json:"contents"`

0 commit comments

Comments
 (0)