@@ -354,6 +354,10 @@ See `lsp-sonarlint-analyze-folder' to see which files are ignored."
354354 '((t :inherit 'lsp-face-semhl-keyword ))
355355 " Face used for the primary message in the list of secondary messages." )
356356
357+ (defface lsp-sonarlint-embedded-msg-face
358+ '((t :italic t :height 0.8 ))
359+ " Face used for the in-line secondary messages." )
360+
357361(defun lsp-sonarlint--get-range-positions (range )
358362 " Convert the RANGE hash table from SonarLint to a plist with positions."
359363 (let ((start-line (1- (ht-get range " startLine" )))
@@ -379,6 +383,32 @@ BEGIN-END-POSITIONS is a plist with :begin and :end positions."
379383 (propertize (number-to-string num)
380384 'face 'lsp-sonarlint--step-marker )))
381385
386+ (defun lsp-sonarlint--make-full-line-overlay (range )
387+ " Create an overlay covering entire line(s) rather than the precise RANGE."
388+ (save-excursion
389+ (goto-char (plist-get range :begin ))
390+ (let ((begin (line-beginning-position )))
391+ (goto-char (plist-get range :end ))
392+ (let ((end (line-end-position )))
393+ (lsp-sonarlint--make-overlay-between `(:begin , begin :end , end ))))))
394+
395+ (defun lsp-sonarlint--get-column (pos )
396+ " Get the column of the point position POS."
397+ (save-excursion
398+ (goto-char pos)
399+ (current-column )))
400+
401+ (defun lsp-sonarlint--secondary-msg-lens-offset (range )
402+ " Compute and return white-space string to align message with RANGE."
403+ (let* ((msg-height (face-attribute 'lsp-sonarlint-embedded-msg-face :height nil 'default ))
404+ (default-height (face-attribute 'default :height ))
405+ (msg-offset-in-chars
406+ (1+ (/ (* (lsp-sonarlint--get-column
407+ (plist-get range :begin ))
408+ default-height)
409+ msg-height))))
410+ (make-string msg-offset-in-chars ?\s )))
411+
382412(defun lsp-sonarlint--procure-overlays-for-secondary-locations (flows )
383413 " Create overlays for secondary locations in FLOWS.
384414
@@ -395,8 +425,13 @@ Returns a list of plists with the overlay, step number, and message."
395425 (let* ((range-ht (ht-get location " textRange" ))
396426 (range (lsp-sonarlint--get-range-positions range-ht))
397427 (overlay (lsp-sonarlint--make-overlay-between range))
428+ (fl-ovl (lsp-sonarlint--make-full-line-overlay range))
429+ (message-offset (lsp-sonarlint--secondary-msg-lens-offset range))
398430 (message (ht-get location " message" )))
399431 (overlay-put overlay 'face 'lsp-sonarlint-secondary-location-face )
432+ (overlay-put fl-ovl 'before-string
433+ (propertize (concat message-offset message " \n " )
434+ 'face 'lsp-sonarlint-embedded-msg-face ))
400435 (lsp-sonarlint--add-number-marker overlay step-num)
401436 `(:overlay , overlay :step-num , step-num :message , message )))
402437 locations)))
0 commit comments