aboutsummaryrefslogtreecommitdiff
path: root/hcel-client.el
diff options
context:
space:
mode:
Diffstat (limited to 'hcel-client.el')
-rw-r--r--hcel-client.el38
1 files changed, 38 insertions, 0 deletions
diff --git a/hcel-client.el b/hcel-client.el
index d5f7abd..fef8bf6 100644
--- a/hcel-client.el
+++ b/hcel-client.el
@@ -159,6 +159,44 @@ Example of approximate location:
(hcel-format-pagination-query page per-page))
nil with-header))
+(defun hcel-api-global-identifier-a (package-id component-id module-name entity
+ name)
+ (hcel-url-fetch-json
+ (concat hcel-host "/api/globalIdentifierA/"
+ (hcel-format-package-id package-id "-") "/" component-id "/"
+ module-name "/" entity "/" name)))
+
+(defun hcel-api-global-identifier-e (package-id module-path start-line start-column
+ end-line end-column name)
+ (hcel-url-fetch-json
+ (concat hcel-host "/api/globalIdentifierE/"
+ (hcel-format-package-id package-id "-") "/"
+ (replace-regexp-in-string "/" "%2F" module-path) "/"
+ (number-to-string start-line) "/"
+ (number-to-string start-column) "/"
+ (number-to-string end-line) "/"
+ (number-to-string end-column) "/" name)))
+
+(defun hcel-global-identifier (location-info &optional name)
+ (let ((tag (hcel-location-tag location-info)))
+ (cond ((equal tag "ApproximateLocation")
+ (hcel-api-global-identifier-a
+ (alist-get 'packageId location-info)
+ (alist-get 'componentId location-info)
+ (alist-get 'moduleName location-info)
+ (alist-get 'entity location-info)
+ (alist-get 'name location-info)))
+ ((equal tag "ExactLocation")
+ (hcel-api-global-identifier-e
+ (alist-get 'packageId location-info)
+ (alist-get 'modulePath location-info)
+ (alist-get 'startLine location-info)
+ (alist-get 'startColumn location-info)
+ (alist-get 'endLine location-info)
+ (alist-get 'endColumn location-info)
+ name))
+ (t (error "Location info %S not supported." location-info)))))
+
(defun hcel-api-global-references (name)
(hcel-url-fetch-json (concat hcel-host "/api/globalReferences/" name)))