diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-14 18:09:08 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-14 18:09:08 +0300 |
commit | b3a736ed88a1db0391cd9881e70b987bab7d89d1 (patch) | |
tree | a91ca3a06abd4c3412775ac3c49b11e3151df2be /app/services/projects/lsif_data_service.rb | |
parent | 5366964a10484c2783a646b35a6da9eece01b242 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services/projects/lsif_data_service.rb')
-rw-r--r-- | app/services/projects/lsif_data_service.rb | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/app/services/projects/lsif_data_service.rb b/app/services/projects/lsif_data_service.rb index 1282a0736e7..971885b680e 100644 --- a/app/services/projects/lsif_data_service.rb +++ b/app/services/projects/lsif_data_service.rb @@ -3,7 +3,7 @@ module Projects class LsifDataService attr_reader :file, :project, :path, :commit_id, - :docs, :doc_ranges, :ranges, :def_refs + :docs, :doc_ranges, :ranges, :def_refs, :hover_refs CACHE_EXPIRE_IN = 1.hour @@ -26,7 +26,8 @@ module Projects end_line: line_data.last, start_char: column_data.first, end_char: column_data.last, - definition_url: definition_url_for(def_refs[ref_id]) + definition_url: definition_url_for(def_refs[ref_id]), + hover: highlighted_hover(hover_refs[ref_id]) } end end @@ -54,6 +55,7 @@ module Projects @doc_ranges = data['doc_ranges'] @ranges = data['ranges'] @def_refs = data['def_refs'] + @hover_refs = data['hover_refs'] end def doc_id @@ -86,5 +88,16 @@ module Projects Gitlab::Routing.url_helpers.project_blob_path(project, definition_ref_path, anchor: line_anchor) end + + def highlighted_hover(hovers) + hovers&.map do |hover| + # Documentation for a method which is added as comments on top of the method + # is stored as a raw string value in LSIF file + next { value: hover } unless hover.is_a?(Hash) + + value = Gitlab::Highlight.highlight(nil, hover['value'], language: hover['language']) + { language: hover['language'], value: value } + end + end end end |