Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
8 changes: 8 additions & 0 deletions internal/ls/hover.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,17 @@ func (l *LanguageService) ProvideHover(ctx context.Context, documentURI lsproto.
}
c, done := program.GetTypeCheckerForFile(ctx, file)
defer done()

// Calculate the applicable range for the hover
rangeNode := getNodeForQuickInfo(node)
quickInfo, documentation := l.getQuickInfoAndDocumentation(c, node)
if quickInfo == "" {
return lsproto.HoverOrNull{}, nil
}

// Calculate range without leading trivia to avoid including whitespace
hoverRange := l.getRangeOfNode(rangeNode, nil, nil)

return lsproto.HoverOrNull{
Hover: &lsproto.Hover{
Contents: lsproto.MarkupContentOrStringOrMarkedStringWithLanguageOrMarkedStrings{
Expand All @@ -39,6 +46,7 @@ func (l *LanguageService) ProvideHover(ctx context.Context, documentURI lsproto.
Value: formatQuickInfo(quickInfo) + documentation,
},
},
Range: hoverRange,
},
}, nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
// ...args
// ): StylingFunction => {
// return curry(getStylingByKeys, 2)(mergedStyling, ...args);
// ^
// ^^^^
// | ----------------------------------------------------------------------
// | ```tsx
// | (parameter) args: []
Expand All @@ -108,6 +108,16 @@
"contents": {
"kind": "markdown",
"value": "```tsx\n(parameter) args: []\n```\n"
},
"range": {
"start": {
"line": 82,
"character": 60
},
"end": {
"line": 82,
"character": 64
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// }
// declare const a: ThingWithDeprecations<void>
// a.subscribe(() => {
// ^
// ^^^^^^^^^
// | ----------------------------------------------------------------------
// | ```tsx
// | (method) ThingWithDeprecations.subscribe(observer?: PartialObserver<void>): Subscription
Expand All @@ -47,6 +47,16 @@
"contents": {
"kind": "markdown",
"value": "```tsx\n(method) ThingWithDeprecations.subscribe(observer?: PartialObserver<void>): Subscription\n```\n"
},
"range": {
"start": {
"line": 22,
"character": 2
},
"end": {
"line": 22,
"character": 11
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
// | ----------------------------------------------------------------------
// /** @type {Null} */
// var Nl;
// ^
// ^^
// | ----------------------------------------------------------------------
// | ```tsx
// | var Nl: Null
Expand All @@ -74,7 +74,7 @@
// | ----------------------------------------------------------------------
// /** @type {Object} */
// var Obj;
// ^
// ^^^
// | ----------------------------------------------------------------------
// | ```tsx
// | var Obj: Object
Expand All @@ -83,7 +83,7 @@
// | ----------------------------------------------------------------------
// /** @type {Function} */
// var Func;
// ^
// ^^^^
// | ----------------------------------------------------------------------
// | ```tsx
// | var Func: Function
Expand All @@ -92,7 +92,7 @@
// | ----------------------------------------------------------------------
// /** @type {*} */
// var AnyType;
// ^
// ^^^^^^^
// | ----------------------------------------------------------------------
// | ```tsx
// | var AnyType: any
Expand All @@ -101,7 +101,7 @@
// | ----------------------------------------------------------------------
// /** @type {?} */
// var QType;
// ^
// ^^^^^
// | ----------------------------------------------------------------------
// | ```tsx
// | var QType: any
Expand All @@ -110,7 +110,7 @@
// | ----------------------------------------------------------------------
// /** @type {String|Number} */
// var SOrN;
// ^
// ^^^^
// | ----------------------------------------------------------------------
// | ```tsx
// | var SOrN: Number | String
Expand All @@ -132,6 +132,16 @@
"contents": {
"kind": "markdown",
"value": "```tsx\nvar S: String\n```\n"
},
"range": {
"start": {
"line": 1,
"character": 4
},
"end": {
"line": 1,
"character": 5
}
}
}
},
Expand All @@ -149,6 +159,16 @@
"contents": {
"kind": "markdown",
"value": "```tsx\nvar N: Number\n```\n"
},
"range": {
"start": {
"line": 3,
"character": 4
},
"end": {
"line": 3,
"character": 5
}
}
}
},
Expand All @@ -166,6 +186,16 @@
"contents": {
"kind": "markdown",
"value": "```tsx\nvar B: Boolean\n```\n"
},
"range": {
"start": {
"line": 5,
"character": 4
},
"end": {
"line": 5,
"character": 5
}
}
}
},
Expand All @@ -183,6 +213,16 @@
"contents": {
"kind": "markdown",
"value": "```tsx\nvar V: Void\n```\n"
},
"range": {
"start": {
"line": 7,
"character": 4
},
"end": {
"line": 7,
"character": 5
}
}
}
},
Expand All @@ -200,6 +240,16 @@
"contents": {
"kind": "markdown",
"value": "```tsx\nvar U: Undefined\n```\n"
},
"range": {
"start": {
"line": 9,
"character": 4
},
"end": {
"line": 9,
"character": 5
}
}
}
},
Expand All @@ -217,6 +267,16 @@
"contents": {
"kind": "markdown",
"value": "```tsx\nvar Nl: Null\n```\n"
},
"range": {
"start": {
"line": 11,
"character": 4
},
"end": {
"line": 11,
"character": 6
}
}
}
},
Expand All @@ -234,6 +294,16 @@
"contents": {
"kind": "markdown",
"value": "```tsx\nvar A: any[]\n```\n"
},
"range": {
"start": {
"line": 13,
"character": 4
},
"end": {
"line": 13,
"character": 5
}
}
}
},
Expand All @@ -251,6 +321,16 @@
"contents": {
"kind": "markdown",
"value": "```tsx\nvar P: Promise<any>\n```\n"
},
"range": {
"start": {
"line": 15,
"character": 4
},
"end": {
"line": 15,
"character": 5
}
}
}
},
Expand All @@ -268,6 +348,16 @@
"contents": {
"kind": "markdown",
"value": "```tsx\nvar Obj: Object\n```\n"
},
"range": {
"start": {
"line": 17,
"character": 4
},
"end": {
"line": 17,
"character": 7
}
}
}
},
Expand All @@ -285,6 +375,16 @@
"contents": {
"kind": "markdown",
"value": "```tsx\nvar Func: Function\n```\n"
},
"range": {
"start": {
"line": 19,
"character": 4
},
"end": {
"line": 19,
"character": 8
}
}
}
},
Expand All @@ -302,6 +402,16 @@
"contents": {
"kind": "markdown",
"value": "```tsx\nvar AnyType: any\n```\n"
},
"range": {
"start": {
"line": 21,
"character": 4
},
"end": {
"line": 21,
"character": 11
}
}
}
},
Expand All @@ -319,6 +429,16 @@
"contents": {
"kind": "markdown",
"value": "```tsx\nvar QType: any\n```\n"
},
"range": {
"start": {
"line": 23,
"character": 4
},
"end": {
"line": 23,
"character": 9
}
}
}
},
Expand All @@ -336,6 +456,16 @@
"contents": {
"kind": "markdown",
"value": "```tsx\nvar SOrN: Number | String\n```\n"
},
"range": {
"start": {
"line": 25,
"character": 4
},
"end": {
"line": 25,
"character": 8
}
}
}
}
Expand Down
Loading
Loading