diff options
author | Yuchen Pei <hi@ypei.me> | 2022-10-05 11:28:34 +1100 |
---|---|---|
committer | Yuchen Pei <hi@ypei.me> | 2022-10-05 11:28:34 +1100 |
commit | c4403522df754627d698f0806d3920764e3d1291 (patch) | |
tree | 11e8eedc5a361e003ec38af6a0a0600e107b0f7e /hcel-client.el | |
parent | 7f67167d097b6f5123946568fde14c7d43bbfd1e (diff) |
Adding ability to navigate within help buffer
Diffstat (limited to 'hcel-client.el')
-rw-r--r-- | hcel-client.el | 38 |
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))) |