Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'workhorse/internal/lsif_transformer/parser/code_hover.go')
-rw-r--r--workhorse/internal/lsif_transformer/parser/code_hover.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/workhorse/internal/lsif_transformer/parser/code_hover.go b/workhorse/internal/lsif_transformer/parser/code_hover.go
index dbdaba643d1..5651ea8e5a3 100644
--- a/workhorse/internal/lsif_transformer/parser/code_hover.go
+++ b/workhorse/internal/lsif_transformer/parser/code_hover.go
@@ -50,9 +50,29 @@ func (ts *truncatableString) MarshalJSON() ([]byte, error) {
return json.Marshal(ts.Value)
}
+func newCodeHovers(contents json.RawMessage) ([]*codeHover, error) {
+ var rawContents []json.RawMessage
+ if err := json.Unmarshal(contents, &rawContents); err != nil {
+ rawContents = []json.RawMessage{contents}
+ }
+
+ codeHovers := []*codeHover{}
+ for _, rawContent := range rawContents {
+ c, err := newCodeHover(rawContent)
+ if err != nil {
+ return nil, err
+ }
+
+ codeHovers = append(codeHovers, c)
+ }
+
+ return codeHovers, nil
+}
+
func newCodeHover(content json.RawMessage) (*codeHover, error) {
// Hover value can be either an object: { "value": "func main()", "language": "go" }
// Or a string with documentation
+ // Or a markdown object: { "value": "```go\nfunc main()\n```", "kind": "markdown" }
// We try to unmarshal the content into a string and if we fail, we unmarshal it into an object
var c codeHover
if err := json.Unmarshal(content, &c.TruncatedValue); err != nil {