[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/d-mode b2c9831 252/346: Make imenu hierarchical
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/d-mode b2c9831 252/346: Make imenu hierarchical |
Date: |
Sun, 29 Aug 2021 11:00:40 -0400 (EDT) |
branch: elpa/d-mode
commit b2c98317b87884345649314ec5a1c777a7bb3ae0
Author: Vladimir Panteleev <git@thecybershadow.net>
Commit: Vladimir Panteleev <git@thecybershadow.net>
Make imenu hierarchical
Include the context of declarations in the entries.
---
d-mode.el | 98 ++++++++++++++++++++++++++++++++++++++++-----------------------
1 file changed, 63 insertions(+), 35 deletions(-)
diff --git a/d-mode.el b/d-mode.el
index 54098ff..4851637 100644
--- a/d-mode.el
+++ b/d-mode.el
@@ -7,7 +7,7 @@
;; Maintainer: Russel Winder <russel@winder.org.uk>
;; Vladimir Panteleev <vladimir@thecybershadow.net>
;; Created: March 2007
-;; Version: 201909101903
+;; Version: 201909102141
;; Keywords: D programming language emacs cc-mode
;; Package-Requires: ((emacs "25.1"))
@@ -843,7 +843,8 @@ Each list item should be a regexp matching a single
identifier."
(defun d-imenu-create-index-function ()
"Create imenu entries for D-mode."
(goto-char (point-min))
- (c-save-buffer-state (d-spots last-spot)
+ (c-save-buffer-state
+ (d-spots last-spot (d-blocks (make-hash-table)))
(c-find-decl-spots
(point-max)
c-decl-start-re
@@ -862,7 +863,8 @@ Each list item should be a regexp matching a single
identifier."
nil ; last-cast-end
))))
(when (and decl-or-cast (not (eq (car decl-or-cast) last-spot)))
- (let* ((id-start (progn
+ (let* ((decl-end (point))
+ (id-start (progn
(goto-char (car decl-or-cast))
(when (eq (char-after) ?=)
(c-backward-syntactic-ws)
@@ -892,41 +894,67 @@ Each list item should be a regexp matching a single
identifier."
(goto-char id-end)
(c-forward-syntactic-ws)
(char-after)))
- (kind (cond
- ((null name)
- nil)
- ((equal id-prev-token "else")
- nil) ; false positive after else
- ((equal name "{")
- nil) ; false positive with decl-start keyword and
{...} group
- ((equal id-prev-token "enum")
- "Enums")
- ((equal id-prev-token "class")
- "Classes")
- ((equal id-prev-token "struct")
- "Structs")
- ((equal id-prev-token "template")
- "Templates")
- ((equal id-prev-token "alias")
- "Aliases")
- ((equal type-prev-token "alias")
- "Aliases") ; old-style alias
- ((memq next-char '(?\; ?= ?,))
- "Variables")
- ((member name '("import" "if"))
- nil) ; static import/if
- ((memq next-char '(?\())
- t) ; function
- (t ; unknown
- id-prev-token))))
-
- (when kind
+ (res (cond
+ ((null name)
+ nil)
+ ((equal id-prev-token "else")
+ nil) ; false positive after else
+ ((equal name "{")
+ nil) ; false positive with decl-start keyword and
{...} group
+ ((equal id-prev-token "enum")
+ '("enum" t))
+ ((equal id-prev-token "class")
+ '("class" t))
+ ((equal id-prev-token "struct")
+ '("struct" t))
+ ((equal id-prev-token "template")
+ '("template" t))
+ ((equal id-prev-token "alias")
+ '("alias" nil))
+ ((equal type-prev-token "alias")
+ '("alias" nil)) ; old-style alias
+ ((memq next-char '(?\; ?= ?,))
+ '("variable" nil))
+ ((member name '("import" "if"))
+ nil) ; static import/if
+ ((memq next-char '(?\())
+ '("function" t)) ; function
+ (t ; unknown
+ (list id-prev-token nil))))
+ (kind (car res))
+ (have-block (cadr res))
+ (paren-state (when res (c-parse-state)))
+ (outer-brace match-pos)
+ d-context
+ d-fqpath)
+
+ (when res
+ (when paren-state
+ ;; Find brace with known context
+ (while (and outer-brace
+ (not d-context))
+ (setq outer-brace (c-most-enclosing-brace paren-state
outer-brace))
+ (setq d-context (gethash outer-brace d-blocks))))
+
+ (setq d-fqpath (append d-context (list (concat kind " "
name))))
+
+ (when have-block
+ (goto-char decl-end)
+ (when (and (c-syntactic-re-search-forward "[{};]" nil t)
+ (eq (char-before) ?{))
+ (puthash (1- (point)) d-fqpath d-blocks)))
+
(setq last-spot (car decl-or-cast)
d-spots
(cons
- (if (eq kind t)
- (cons name id-start)
- (list kind (cons name id-start)))
+ (let (res)
+ (mapc (lambda (e)
+ (setq res
+ (if res
+ (list e res)
+ (cons e id-start))))
+ (nreverse d-fqpath))
+ res)
d-spots)))))))))
(nreverse d-spots)))
- [nongnu] elpa/d-mode cb97457 297/346: Remove another obsolete hack, (continued)
- [nongnu] elpa/d-mode cb97457 297/346: Remove another obsolete hack, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode bc725ef 296/346: Use a conditional compilation macro for version checks, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode c77fc0a 307/346: Skip coverage analysis when byte-compiling, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode d9e9d06 311/346: Merge d-forward-module-clause into d-forward-keyword-clause, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode f76ba89 308/346: Fontify (type-inferred) lambda arguments, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 34f44cf 337/346: .github/workflows/test.yml: Add Emacs 27.1, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 379b00e 144/346: Tweak intro comments a bit, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 7d3edd2 234/346: Add test from issue #94, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 968306a 224/346: Add a test case against the now-removed fontification hack, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 8e208b2 232/346: Fix imenu display of functions for imenu-add-to-menubar, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode b2c9831 252/346: Make imenu hierarchical,
ELPA Syncer <=
- [nongnu] elpa/d-mode 69df4a3 254/346: Abbreviate symbol kind in imenu entries, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 12e45cf 258/346: Fix fontification of properties with inferred return type, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 26e7337 253/346: Don't put variables in imenu, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 372c135 274/346: Makefile: Fail on byte-compilation warnings, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode a0e95f4 282/346: Remove cl-lib dependency, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 2b48656 285/346: Simplify c-forward-decl-or-cast-1 advice, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 936944f 294/346: tests: Update test minimal versions, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode fb94d19 295/346: Fix fontification of "xxxmodule.yyy", ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 6cbba0e 301/346: Fix fontification of lone protection labels, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 2bb5809 304/346: Move conditional compilation to within function bodies, ELPA Syncer, 2021/08/29