From c4403522df754627d698f0806d3920764e3d1291 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 5 Oct 2022 11:28:34 +1100 Subject: Adding ability to navigate within help buffer --- hcel-client.el | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'hcel-client.el') 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))) -- cgit v1.2.3