emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/ada-mode bf6c004 1/2: Match change in xref 1.3.2


From: Stephen Leake
Subject: [elpa] externals/ada-mode bf6c004 1/2: Match change in xref 1.3.2
Date: Sun, 21 Nov 2021 11:03:43 -0500 (EST)

branch: externals/ada-mode
commit bf6c004f40b418c4f38cfef9c8ffe7202ec42108
Author: Stephen Leake <stephen_leake@stephe-leake.org>
Commit: Stephen Leake <stephen_leake@stephe-leake.org>

    Match change in xref 1.3.2
    
    * ada-gnat-xref.el (ada-gnat-xref-refs): Match change in xref 1.3.2.
    * gpr-query.el (gpr-query-tree-refs):
---
 ada-gnat-xref.el | 73 +++++++++++++++++++++++++++++++-------------------------
 gpr-query.el     | 19 ++++++++++-----
 2 files changed, 53 insertions(+), 39 deletions(-)

diff --git a/ada-gnat-xref.el b/ada-gnat-xref.el
index 8b3b340..2b16cff 100644
--- a/ada-gnat-xref.el
+++ b/ada-gnat-xref.el
@@ -5,7 +5,7 @@
 ;;
 ;; GNAT is provided by AdaCore; see http://libre.adacore.com/
 ;;
-;;; Copyright (C) 2012 - 2020  Free Software Foundation, Inc.
+;;; Copyright (C) 2012 - 2021  Free Software Foundation, Inc.
 ;;
 ;; Author: Stephen Leake <stephen_leake@member.fsf.org>
 ;; Maintainer: Stephen Leake <stephen_leake@member.fsf.org>
@@ -90,7 +90,7 @@
   (cond
    ((null col)
     col)
-   
+
    ((eq ?\" (aref identifier 0))
     ;; There are two cases here:
     ;;
@@ -140,38 +140,45 @@ elements of the result may be nil."
                 (or (ada-gnat-xref-adj-col identifier col) ""))))
 
 (defun ada-gnat-xref-refs (project item all)
-  (with-slots (summary location) item
-    (with-slots (file line column) location
-      (let* ((wisi-xref-full-path t)
-            (args (cons "-r" (ada-gnat-xref-common-args project summary file 
line column)))
-            (result nil))
-       (with-current-buffer (gnat-run-buffer project 
(gnat-compiler-run-buffer-name (wisi-prj-xref project)))
-         (gnat-run project (ada-gnat-xref-common-cmd project) args)
-
-         (goto-char (point-min))
-         (when ada-gnat-debug-run (forward-line 2)); skip ADA_PROJECT_PATH, 
'gnat find'
-
-         (while (not (eobp))
-           (cond
-            ((looking-at ada-gnat-file-line-col-type-regexp)
-             ;; process line
-             (let ((found-file (match-string 1))
-                   (found-line (string-to-number (match-string 2)))
-                   (found-col  (string-to-number (match-string 3)))
-                   (found-type (match-string 4)))
-               (when (or all found-type)
-                 (push (xref-make (if found-type
-                                      (concat summary " " found-type)
-                                    summary)
-                                  (xref-make-file-location found-file 
found-line found-col))
-                       result))
+  ;; WORKAROUND: xref 1.3.2 xref-location changed from defclass to cl-defstruct
+  (with-suppressed-warnings (nil) ;; "unknown slot"
+    (let ((summary (if (functionp 'xref-item-summary) (xref-item-summary item) 
(oref item :summary)))
+         (location (if (functionp 'xref-item-location) (xref-item-location 
item) (oref item :location))))
+      (let ((file (if (functionp 'xref-location-file) (xref-location-file 
location) (oref location :file)))
+           (line (if (functionp 'xref-location-line) (xref-location-line 
location) (oref location :line)))
+           (column (if (functionp 'xref-location-column)
+                       (xref-location-column location)
+                     (oref location :column))))
+       (let* ((wisi-xref-full-path t)
+              (args (cons "-r" (ada-gnat-xref-common-args project summary file 
line column)))
+              (result nil))
+         (with-current-buffer (gnat-run-buffer project 
(gnat-compiler-run-buffer-name (wisi-prj-xref project)))
+           (gnat-run project (ada-gnat-xref-common-cmd project) args)
+
+           (goto-char (point-min))
+           (when ada-gnat-debug-run (forward-line 2)); skip ADA_PROJECT_PATH, 
'gnat find'
+
+           (while (not (eobp))
+             (cond
+              ((looking-at ada-gnat-file-line-col-type-regexp)
+               ;; process line
+               (let ((found-file (match-string 1))
+                     (found-line (string-to-number (match-string 2)))
+                     (found-col  (string-to-number (match-string 3)))
+                     (found-type (match-string 4)))
+                 (when (or all found-type)
+                   (push (xref-make (if found-type
+                                        (concat summary " " found-type)
+                                      summary)
+                                    (xref-make-file-location found-file 
found-line found-col))
+                         result))
+                 ))
+              (t
+               ;; ignore line
                ))
-            (t
-             ;; ignore line
-             ))
-           (forward-line 1)))
-       (nreverse result) ;; specs first.
-       ))))
+             (forward-line 1)))
+         (nreverse result) ;; specs first.
+         )))))
 
 (cl-defmethod wisi-xref-definitions (_xref project item)
   (ada-gnat-xref-refs project item nil))
diff --git a/gpr-query.el b/gpr-query.el
index 4c2570f..246cd14 100644
--- a/gpr-query.el
+++ b/gpr-query.el
@@ -3,7 +3,7 @@
 ;; gpr-query supports Ada and any gcc language that supports the
 ;; AdaCore -fdump-xref switch (which includes C, C++).
 ;;
-;; Copyright (C) 2013 - 2020  Free Software Foundation, Inc.
+;; Copyright (C) 2013 - 2021  Free Software Foundation, Inc.
 
 ;; Author: Stephen Leake <stephen_leake@member.fsf.org>
 ;; Maintainer: Stephen Leake <stephen_leake@member.fsf.org>
@@ -302,7 +302,7 @@ Must match gpr_query.adb Version.")
     ))
 
 (defun gpr-query-session-wait (session command-type)
-  "Wait for the current COMMAND-TYPE (one of 'xref or 'symbols) command to 
complete."
+  "Wait for the current COMMAND-TYPE (one of 'xref or 'symbols) to complete."
   (when (and
         (eq command-type 'symbols)
         (null (gpr-query--session-symbols-process session)))
@@ -720,10 +720,17 @@ FILE is from gpr-query."
 
 (defun gpr-query-tree-refs (project item op)
   "Run gpr_query tree command OP on ITEM (an xref-item), return list of 
xref-items."
-  (with-slots (summary location) item
-    ;; 'location' may have line, column nil
-    (let ((eieio-skip-typecheck t))
-      (with-slots (file line column) location
+  ;; WORKAROUND: xref 1.3.2 xref-location changed from defclass to cl-defstruct
+  (with-suppressed-warnings (nil) ;; "unknown slot"
+    (let ((summary (if (functionp 'xref-item-summary) (xref-item-summary item) 
(oref item :summary)))
+         (location (if (functionp 'xref-item-location) (xref-item-location 
item) (oref item :location)))
+         (eieio-skip-typecheck t)) ;; 'location' may have line, column nil
+      (let ((file (if (functionp 'xref-location-file) (xref-location-file 
location) (oref location :file)))
+           (line (if (functionp 'xref-location-line) (xref-location-line 
location) (oref location :line)))
+           (column (if (functionp 'xref-location-column)
+                       (xref-location-column location)
+                     (oref location :column))))
+
        (when (eq ?\" (aref summary 0))
          ;; gpr_query wants the quotes stripped
          (when column (setq column (+ 1 column)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]