@@ -429,21 +429,52 @@ MAX-COLL-SIZE if non nil."
429
429
430
430
(defun cider-inspector-render* (elements )
431
431
" Render ELEMENTS."
432
+ (setq cider-inspector-looking-at-java-p nil )
432
433
(dolist (el elements)
433
434
(cider-inspector-render-el* el)))
434
435
436
+ (defvar cider-inspector-looking-at-java-p nil )
437
+
438
+ (defun cider--to-java-string (s )
439
+ " Given `S`, returns a propertized string with Java syntax coloring."
440
+ (with-temp-buffer
441
+ (insert s)
442
+ (java-mode )
443
+ (font-lock-ensure )
444
+ (buffer-string )))
445
+
446
+ (defconst cider--inspector-java-headers
447
+ '(" --- Interfaces:" " --- Constructors:" " --- Fields:" " --- Methods:" " --- Imports:" ))
448
+
435
449
(defun cider-inspector-render-el* (el )
436
450
" Render EL."
437
- (cond ((symbolp el) (insert (symbol-name el)))
438
- ((stringp el) (insert (propertize el 'font-lock-face 'font-lock-keyword-face )))
439
- ((and (consp el) (eq (car el) :newline ))
440
- (insert " \n " ))
441
- ((and (consp el) (eq (car el) :value ))
442
- (cider-inspector-render-value (cadr el) (cl-caddr el)))
443
- (t (message " Unrecognized inspector object: %s " el))))
451
+ (let ((header-p (or (member el cider--inspector-java-headers)
452
+ (and (stringp el)
453
+ (string-prefix-p " --- " el)))))
454
+ ; ; Headers reset the Java syntax coloring:
455
+ (when header-p
456
+ (setq cider-inspector-looking-at-java-p nil ))
457
+
458
+ (cond ((symbolp el) (insert (symbol-name el)))
459
+ ((stringp el) (insert (if cider-inspector-looking-at-java-p
460
+ (cider--to-java-string el)
461
+ (propertize el 'font-lock-face (if header-p
462
+ 'font-lock-comment-face
463
+ 'font-lock-keyword-face )))))
464
+ ((and (consp el) (eq (car el) :newline ))
465
+ (insert " \n " ))
466
+ ((and (consp el) (eq (car el) :value ))
467
+ (cider-inspector-render-value (cadr el) (cl-caddr el)))
468
+ (t (message " Unrecognized inspector object: %s " el))))
469
+
470
+ ; ; Java-related headers indicate that the next elements to be rendered
471
+ ; ; should be syntax-colored as Java:
472
+ (when (member el cider--inspector-java-headers)
473
+ (setq cider-inspector-looking-at-java-p t )))
444
474
445
475
(defun cider-inspector-render-value (value idx )
446
476
" Render VALUE at IDX."
477
+ (setq cider-inspector-looking-at-java-p nil )
447
478
(cider-propertize-region
448
479
(list 'cider-value-idx idx
449
480
'mouse-face 'highlight )
0 commit comments