branch: elpa/scala-mode commit 03cfbe43ddba49f86abdc3893a6d21b62b86bd6c Author: Ivan Malison <ivanmali...@gmail.com> Commit: Ivan Malison <ivanmali...@gmail.com>
Add types to index items. --- scala-mode2-imenu.el | 11 +++++++++-- scala-mode2-syntax.el | 9 +++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/scala-mode2-imenu.el b/scala-mode2-imenu.el index 658e629..d16a896 100644 --- a/scala-mode2-imenu.el +++ b/scala-mode2-imenu.el @@ -6,6 +6,8 @@ (defcustom scala-imenu:should-flatten-index nil "Controls whether or not the imenu index is flattened or hierarchical.") +(defcustom scala-imenu:should-show-type t + "Controls whether or not the imenu index has definition type information.") (defun scala-imenu:create-index () (interactive) @@ -22,10 +24,15 @@ (if (eq (point) last-point) nil (progn (save-excursion (re-search-forward scala-syntax:all-definition-re) - (setq class-name (match-string-no-properties 2))) + (setq class-name (scala-imenu:get-tag-from-last-match))) `(,class-name . ,(cons `("<class>" . ,(point-marker)) (scala-imenu:class-members))))))) +(defun scala-imenu:get-tag-from-last-match () + (if scala-imenu:should-show-type (concat (match-string-no-properties 1) + ":" (match-string-no-properties 2)) + (match-string-no-properties 2))) + (defun scala-imenu:class-members () (interactive) (let ((start-point (point))) @@ -39,7 +46,7 @@ (if (< stop-at-point (point)) (let ((member-name (save-excursion (re-search-forward scala-syntax:all-definition-re) - (match-string-no-properties 2)))) + (scala-imenu:get-tag-from-last-match)))) (cons `(,member-name . ,marker) (scala-imenu:get-class-members stop-at-point))) nil))) diff --git a/scala-mode2-syntax.el b/scala-mode2-syntax.el index be79a8d..ec74d54 100644 --- a/scala-mode2-syntax.el +++ b/scala-mode2-syntax.el @@ -908,20 +908,21 @@ not. A list must be either enclosed in parentheses or start with (defconst scala-syntax:whitespace-delimeted-modifiers-re (concat "\\(?:" scala-syntax:modifiers-re "\\(?: *\\)" "\\)*")) -(defconst scala-syntax:definition-words-re - (regexp-opt '("class" "object" "trait" "val" "var" "def" "type") 'words)) +(defconst scala-syntax:definition-words-re + (mapconcat 'regexp-quote '("class" "object" "trait" "val" "var" "def" "type") "\\|")) (defun scala-syntax:build-definition-re (words-re) (concat " *" scala-syntax:whitespace-delimeted-modifiers-re words-re - "\\(?1: *\\)" + "\\(?: *\\)" "\\(?2:" scala-syntax:id-re "\\)")) (defconst scala-syntax:all-definition-re - (scala-syntax:build-definition-re scala-syntax:definition-words-re)) + (scala-syntax:build-definition-re + (concat "\\(?1:" scala-syntax:definition-words-re "\\)"))) ;; Functions to help with beginning and end of definitions.