aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuchen Pei <hi@ypei.me>2022-10-05 10:32:41 +1100
committerYuchen Pei <hi@ypei.me>2022-10-05 10:32:41 +1100
commit3de0aca80d056901b4c355942e33581ec3ce7acb (patch)
tree24d31a759efbec579430f1acc64e90bd43b5e61b
parentdfa70bf16724a5a29e054af89fcf126438181e38 (diff)
clarifying names w.r.t identifiers
- identifier should refer to an IdentifierInfo type on server - internal-id <-> InternalId - external-id <-> ExternalId
-rw-r--r--hcel-haddorg.el11
-rw-r--r--hcel-minor.el10
-rw-r--r--hcel-results.el22
-rw-r--r--hcel-source.el50
4 files changed, 48 insertions, 45 deletions
diff --git a/hcel-haddorg.el b/hcel-haddorg.el
index a6961cc..0453f1d 100644
--- a/hcel-haddorg.el
+++ b/hcel-haddorg.el
@@ -58,14 +58,15 @@ is in ghc-8.10.1, hcel will attempt to look up in ghc-9.2.2.org."
(defun hcel-identifier-at-point-to-haddorg ()
(interactive)
- (when-let* ((identifier (hcel-text-property-near-point 'identifier))
- (id (alist-get (intern identifier) hcel-identifiers))
- (exported (alist-get 'isExported id))
- (external-id (alist-get 'externalId id)))
+ (when-let* ((internal-id (hcel-text-property-near-point 'internal-id))
+ (identifier (alist-get (intern internal-id) hcel-identifiers))
+ (exported (alist-get 'isExported identifier))
+ (external-id (alist-get 'externalId identifier)))
(if (and (eq exported json-false)
;; FIXME: Hacky. ExactLocation implies identifier is declared in
;; the current module.
- (equal (alist-get 'tag (alist-get 'locationInfo id)) "ExactLocation"))
+ (equal (alist-get 'tag (alist-get 'locationInfo identifier))
+ "ExactLocation"))
(message "%s is not exported." (hcel-occ-symbol-at-point))
(let* ((splitted (split-string external-id "|"))
(package-id (car splitted))
diff --git a/hcel-minor.el b/hcel-minor.el
index 85414fa..687c596 100644
--- a/hcel-minor.el
+++ b/hcel-minor.el
@@ -68,28 +68,28 @@
(t (error "%S not supported and not in eldoc doc buffer." major-mode))))
(defun hcel-minor-eldoc-id-type (cb)
- (when-let* ((identifier (hcel-text-property-near-point 'internal-id))
+ (when-let* ((internal-id (hcel-text-property-near-point 'internal-id))
(symbol (save-excursion
(buffer-substring-no-properties
(progn
(text-property-search-backward
- 'internal-id identifier 'string=)
+ 'internal-id internal-id 'string=)
(point))
(progn
(text-property-search-forward
- 'internal-id identifier 'string=)
+ 'internal-id internal-id 'string=)
(point)))))
(docstring
(cond ((derived-mode-p 'hcel-outline-mode)
(hcel-render-type-internal
(hcel-text-property-near-point 'package-id)
(hcel-text-property-near-point 'module-path)
- identifier))
+ internal-id))
((derived-mode-p 'hcel-ids-mode)
(hcel-render-type-internal
(alist-get 'packageId (hcel-text-property-near-point 'location-info))
(alist-get 'modulePath (hcel-text-property-near-point 'location-info))
- identifier))
+ internal-id))
(t nil))))
(funcall cb docstring
:thing symbol
diff --git a/hcel-results.el b/hcel-results.el
index 75b35a0..1e0dbb0 100644
--- a/hcel-results.el
+++ b/hcel-results.el
@@ -103,7 +103,8 @@
"hcel refs number of results per page."
:group 'hcel-refs :type '(natnum))
-(defvar-local hcel-refs-id nil)
+(defvar-local hcel-refs-id nil
+ "External ID of the identifier we are looking for refs in the current buffer")
(defvar-local hcel-refs-package-id nil)
(define-compilation-mode hcel-refs-mode "hcel-refs"
@@ -209,24 +210,25 @@ Start by choosing a package."
"Find references of the identifier at point."
(interactive)
(hcel-find-references-internal hcel-package-id hcel-module-path
- (hcel-text-property-near-point 'identifier)))
+ (hcel-text-property-near-point 'internal-id)))
(define-key hcel-mode-map (kbd "M-?") #'hcel-find-references-at-point)
-(defun hcel-find-references-internal (package-id module-path identifier)
- (when (and package-id module-path identifier)
+(defun hcel-find-references-internal (package-id module-path internal-id)
+ (when (and package-id module-path internal-id)
(let ((hcel-buffer (hcel-buffer-name package-id module-path)))
(when (or (get-buffer hcel-buffer)
(and (y-or-n-p "Open module source?")
(hcel-load-module-source
package-id module-path))))
(with-current-buffer hcel-buffer
- (when-let* ((id (alist-get
- 'externalId
- (alist-get (intern identifier) hcel-identifiers)))
- (buffer-name (hcel-refs-format-id id)))
+ (when-let* ((external-id
+ (alist-get
+ 'externalId
+ (alist-get (intern internal-id) hcel-identifiers)))
+ (buffer-name (hcel-refs-format-id external-id)))
(with-current-buffer (get-buffer-create buffer-name)
(hcel-refs-mode)
- (setq hcel-refs-id id)
+ (setq hcel-refs-id external-id)
(hcel-refs-update-references-package))
(switch-to-buffer-other-window buffer-name))))))
;; hcel-ids-mode
@@ -286,7 +288,7 @@ Start by choosing a package."
(concat
(propertize
(format "%s :: %s\n"
- (alist-get 'demangledOccName result)
+ (alist-get 'occName result)
(hcel-render-id-type (alist-get 'idType result)))
'location-info location-info
'match-line t)
diff --git a/hcel-source.el b/hcel-source.el
index 78fa2b8..0d96cfd 100644
--- a/hcel-source.el
+++ b/hcel-source.el
@@ -145,10 +145,10 @@ the location with pulsing.
(derived-mode-p 'hcel-mode))))))
(define-key hcel-mode-map "b" #'hcel-switch-buffer)
-(defun hcel-get-location-info (id occ)
- (or (when id (alist-get 'locationInfo id))
+(defun hcel-get-location-info (identifier occurrence)
+ (or (when identifier (alist-get 'locationInfo identifier))
;; happens for import modules
- (when occ (alist-get 'contents (alist-get 'sort occ)))))
+ (when occurrence (alist-get 'contents (alist-get 'sort occurrence)))))
(defun hcel-occ-symbol-at-point ()
(when-let* ((col-beg (hcel-text-property-near-point 'span-begin))
@@ -161,22 +161,22 @@ the location with pulsing.
(defun hcel-type-at-point ()
(interactive)
(hcel-render-type-internal hcel-package-id hcel-module-path
- (hcel-text-property-near-point 'identifier)
+ (hcel-text-property-near-point 'internal-id)
(hcel-text-property-near-point 'occurrence)))
-(defun hcel-render-type-internal (package-id module-path identifier
+(defun hcel-render-type-internal (package-id module-path internal-id
&optional occurrence)
- (when (and package-id module-path (or identifier occurrence))
+ (when (and package-id module-path (or internal-id occurrence))
(let ((hcel-buffer (hcel-buffer-name package-id module-path)))
(when (get-buffer hcel-buffer)
(with-current-buffer hcel-buffer
- (let* ((id (when identifier
- (alist-get (intern identifier) hcel-identifiers)))
- (id-type (or (alist-get 'idType id)
+ (let* ((identifier (when internal-id
+ (alist-get (intern internal-id) hcel-identifiers)))
+ (id-type (or (alist-get 'idType identifier)
(alist-get 'idOccType occurrence))))
(concat
(hcel-render-id-type id-type)
- (when-let* ((external-id (alist-get 'externalId id))
+ (when-let* ((external-id (alist-get 'externalId identifier))
(splitted (split-string external-id "|"))
(package-id (car splitted))
(module-name (cadr splitted)))
@@ -191,20 +191,20 @@ the location with pulsing.
(defun hcel-id-docs-at-point ()
(hcel-id-docs-internal hcel-package-id hcel-module-path
- (hcel-text-property-near-point 'identifier)))
+ (hcel-text-property-near-point 'internal-id)))
-(defun hcel-id-docs-internal (package-id module-path identifier)
- (when (and package-id module-path identifier)
+(defun hcel-id-docs-internal (package-id module-path internal-id)
+ (when (and package-id module-path internal-id)
(let ((hcel-buffer (hcel-buffer-name package-id module-path)))
(when (get-buffer hcel-buffer)
(with-current-buffer hcel-buffer
(when-let*
- ((id (alist-get (intern identifier) hcel-identifiers))
- (location-info (hcel-get-location-info id nil))
+ ((identifier (alist-get (intern internal-id) hcel-identifiers))
+ (location-info (hcel-get-location-info identifier nil))
(docs
(or
;; same module
- (alist-get 'doc id)
+ (alist-get 'doc identifier)
;; other module
(alist-get
'documentation
@@ -279,7 +279,7 @@ the location with pulsing.
;; if mark is active, change of face will deactivate the mark in transient
;; mark mode
(unless mark-active
- (let ((id (get-text-property (point) 'identifier))
+ (let ((id (get-text-property (point) 'internal-id))
(inhibit-read-only t))
(when (not (string= hcel-highlight-id id))
(hcel-highlight-stop hcel-highlight-id)
@@ -292,7 +292,7 @@ the location with pulsing.
(goto-char (point-min))
(let ((match))
(while (setq match
- (text-property-search-forward 'identifier id 'string=))
+ (text-property-search-forward 'internal-id id 'string=))
(font-lock--remove-face-from-text-property
(prop-match-beginning match)
(prop-match-end match) 'face 'hcel-highlight-id-face))))))
@@ -303,7 +303,7 @@ the location with pulsing.
(goto-char (point-min))
(let ((match))
(while (setq match
- (text-property-search-forward 'identifier id 'string=))
+ (text-property-search-forward 'internal-id id 'string=))
(add-face-text-property
(prop-match-beginning match)
(prop-match-end match) 'hcel-highlight-id-face))))))
@@ -320,7 +320,7 @@ the location with pulsing.
(content (dom-text span)))
(insert
(propertize content
- 'identifier (unless (string= id "") id)
+ 'internal-id (unless (string= id "") id)
'span-begin (when splitted
(1- (string-to-number (cadr splitted))))
'span-end (when splitted
@@ -413,12 +413,12 @@ the location with pulsing.
(defun hcel-find-definition ()
(hcel-find-definition-internal
hcel-package-id hcel-module-path
- (hcel-text-property-near-point 'identifier)
+ (hcel-text-property-near-point 'internal-id)
(hcel-text-property-near-point 'occurrence)))
-(defun hcel-find-definition-internal (package-id module-path identifier
+(defun hcel-find-definition-internal (package-id module-path internal-id
&optional occurrence)
- (when (and package-id module-path (or identifier occurrence))
+ (when (and package-id module-path (or internal-id occurrence))
(let ((hcel-buffer (hcel-buffer-name package-id module-path)))
(when (or (get-buffer hcel-buffer)
(and (y-or-n-p "Open module source?")
@@ -427,8 +427,8 @@ the location with pulsing.
(with-current-buffer hcel-buffer
(let ((location-info
(hcel-get-location-info
- (when identifier
- (alist-get (intern identifier) hcel-identifiers))
+ (when internal-id
+ (alist-get (intern internal-id) hcel-identifiers))
occurrence)))
(setq location-info (hcel-to-exact-location location-info))
(let ((line-beg (alist-get 'startLine location-info))