]> git.eshelyaron.com Git - dict.git/commitdiff
ENHANCED: consult with library index for finding predicate defs
authorEshel Yaron <me@eshelyaron.com>
Fri, 20 Jan 2023 18:45:14 +0000 (20:45 +0200)
committerEshel Yaron <me@eshelyaron.com>
Fri, 20 Jan 2023 19:13:46 +0000 (21:13 +0200)
* sweep.pl (sweep_predicate_location_/4): also check library_index/3.
* sweeprolog-tests.el: add test for finding the source location of a
predicate in the package clib.

sweep.pl
sweeprolog-tests.el

index 79c6ffc37c38ecdf746fbd54d74d44c4f90fbdbd..7cfb80bac8af89c6b0968be6297233ae976300fd 100644 (file)
--- a/sweep.pl
+++ b/sweep.pl
@@ -384,6 +384,14 @@ sweep_predicate_location_(M, H, Path, Line) :-
     xref_definition_line(How, Line),
     !,
     atom_string(Path0, Path).
+sweep_predicate_location_(M, H, P, L) :-
+    '$autoload':library_index(H, M, P0),
+    absolute_file_name(P0, P1, [extensions([pl])]),
+    xref_source(P1, [comments(store)]),
+    xref_defined(P1, H, How),
+    xref_definition_line(How, L),
+    !,
+    atom_string(P1, P).
 sweep_predicate_location_(M, H, Path, Line) :-
     predicate_property(M:H, file(Path0)),
     predicate_property(M:H, line_count(Line)),
index bb2c1a9b35e9990721f548041448e59b1c0613ca..3076cb99d47eca158755361b1b4cd0d62cae4bff 100644 (file)
@@ -124,6 +124,10 @@ recursive(Var) :-
     *-> Bar is foo
     )")))))
 
+(ert-deftest predicate-location ()
+  "Test `sweeprolog-predicate-location'."
+  (should (sweeprolog-predicate-location "memory_file:new_memory_file/1")))
+
 (ert-deftest term-search ()
   "Test `sweeprolog-term-search'."
   (let ((temp (make-temp-file "sweeprolog-test"