MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / handleHover

Method handleHover

pkg/lsp/handler.go:607–637  ·  view source on GitHub ↗

handleHover provides hover information for SQL keywords. When the user hovers over a SQL keyword in their editor, this handler returns markdown-formatted documentation with syntax examples. The handler supports 60+ SQL keywords across all major categories: - Core DML: SELECT, INSERT, UPDATE, DELET

(params json.RawMessage)

Source from the content-addressed store, hash-verified

605// - Empty Hover if position is not on a keyword
606// - Error if document not found or params invalid
607func (h *Handler) handleHover(params json.RawMessage) (*Hover, error) {
608 var p TextDocumentPositionParams
609 if err := json.Unmarshal(params, &p); err != nil {
610 return nil, err
611 }
612
613 doc, ok := h.server.Documents().Get(p.TextDocument.URI)
614 if !ok {
615 // Return empty hover response instead of nil for proper LSP compliance
616 return &Hover{}, nil
617 }
618
619 // Get word at position
620 word := doc.GetWordAtPosition(p.Position)
621 if word == "" {
622 return &Hover{}, nil
623 }
624
625 // Look up keyword documentation
626 doc_text := getKeywordDocumentation(strings.ToUpper(word))
627 if doc_text == "" {
628 return &Hover{}, nil
629 }
630
631 return &Hover{
632 Contents: MarkupContent{
633 Kind: Markdown,
634 Value: doc_text,
635 },
636 }, nil
637}
638
639// handleCompletion provides completion suggestions for SQL keywords and snippets.
640//

Callers 1

HandleRequestMethod · 0.95

Calls 4

getKeywordDocumentationFunction · 0.85
DocumentsMethod · 0.80
GetWordAtPositionMethod · 0.80
GetMethod · 0.45

Tested by

no test coverage detected