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

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

[nongnu] elpa/sweeprolog 0b054bac88 072/166: ENHANCED: better detection


From: ELPA Syncer
Subject: [nongnu] elpa/sweeprolog 0b054bac88 072/166: ENHANCED: better detection of the identifier at point
Date: Fri, 30 Sep 2022 04:59:27 -0400 (EDT)

branch: elpa/sweeprolog
commit 0b054bac88ea5a4ebf9f94862b64d892214c1e86
Author: Eshel Yaron <me@eshelyaron.com>
Commit: Eshel Yaron <me@eshelyaron.com>

    ENHANCED: better detection of the identifier at point
---
 sweep.pl | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 83 insertions(+), 2 deletions(-)

diff --git a/sweep.pl b/sweep.pl
index 61583c6284..179d5be528 100644
--- a/sweep.pl
+++ b/sweep.pl
@@ -37,6 +37,7 @@
             sweep_identifier_at_point/2,
             sweep_expand_file_name/2,
             sweep_path_module/2,
+            sweep_colourise_query/2,
             sweep_predicate_location/2,
             sweep_predicates_collection/2,
             sweep_modules_collection/2,
@@ -142,8 +143,83 @@ sweep_handle_identifier_at_point(Path, M, Point, Col, Beg, 
Len) :-
     sweep_handle_identifier_at_point_(Path, M, Col).
 sweep_handle_identifier_at_point(_, _, _, _, _, _).
 
-sweep_handle_identifier_at_point_(Path, M0, goal_term(_Kind, Goal)) :-
+sweep_handle_identifier_at_point_(Path, M0, goal_term(Kind, Goal)) :-
     !,
+    sweep_handle_identifier_at_point_goal(Path, M0, Kind, Goal).
+sweep_handle_identifier_at_point_(Path, M0, goal(Kind, Goal)) :-
+    !,
+    sweep_handle_identifier_at_point_goal(Path, M0, Kind, Goal).
+sweep_handle_identifier_at_point_(_Path, M0, head_term(_Kind, Goal)) :-
+    !,
+    sweep_handle_identifier_at_point_head(M0, Goal).
+sweep_handle_identifier_at_point_(_, _, _).
+
+
+sweep_handle_identifier_at_point_head(_, M:Goal) :-
+    !,
+    pi_head(PI, Goal),
+    asserta(sweep_current_identifier_at_point(M:PI)).
+sweep_handle_identifier_at_point_head(M, Goal) :-
+    !,
+    pi_head(PI, Goal),
+    asserta(sweep_current_identifier_at_point(M:PI)).
+
+sweep_handle_identifier_at_point_goal(_Path, M, local(_), Goal) :-
+    !,
+    pi_head(PI, Goal),
+    asserta(sweep_current_identifier_at_point(M:PI)).
+sweep_handle_identifier_at_point_goal(_Path, _M, recursion, M:Goal) :-
+    !,
+    pi_head(PI, Goal),
+    asserta(sweep_current_identifier_at_point(M:PI)).
+sweep_handle_identifier_at_point_goal(_Path, M, recursion, Goal) :-
+    !,
+    pi_head(PI, Goal),
+    asserta(sweep_current_identifier_at_point(M:PI)).
+sweep_handle_identifier_at_point_goal(_Path, _M0, built_in, Goal) :-
+    !,
+    pi_head(PI, Goal),
+    asserta(sweep_current_identifier_at_point(PI)).
+sweep_handle_identifier_at_point_goal(_Path, _M0, imported(Path), Goal) :-
+    !,
+    pi_head(PI, Goal),
+    xref_module(Path, M),
+    asserta(sweep_current_identifier_at_point(M:PI)).
+sweep_handle_identifier_at_point_goal(_Path, _M0, Extern, Goal) :-
+    sweep_is_extern(Extern, M),
+    !,
+    pi_head(PI, Goal),
+    asserta(sweep_current_identifier_at_point(M:PI)).
+sweep_handle_identifier_at_point_goal(_Path, _M0, autoload(Path), Goal) :-
+    !,
+    pi_head(PI, Goal),
+    (   '$autoload':library_index(Goal, M, Path)
+    ->  true
+    ;   file_name_extension(Base, _, Path), '$autoload':library_index(Goal, M, 
Base)
+    ),
+    asserta(sweep_current_identifier_at_point(M:PI)).
+sweep_handle_identifier_at_point_goal(_Path, _M0, Global, Goal) :-
+    sweep_is_global(Global),
+    !,
+    pi_head(PI, Goal),
+    asserta(sweep_current_identifier_at_point(user:PI)).
+sweep_handle_identifier_at_point_goal(_Path, _M0, undefined, M:Goal) :-
+    !,
+    pi_head(PI, Goal),
+    asserta(sweep_current_identifier_at_point(M:PI)).
+sweep_handle_identifier_at_point_goal(_Path, _M0, undefined, Goal) :-
+    !,
+    pi_head(PI, Goal),
+    asserta(sweep_current_identifier_at_point(undefined:PI)).
+sweep_handle_identifier_at_point_goal(_Path, _M0, meta, _:Goal) :-
+    !,
+    pi_head(PI, Goal),
+    asserta(sweep_current_identifier_at_point(meta:PI)).
+sweep_handle_identifier_at_point_goal(_Path, _M0, meta, Goal) :-
+    !,
+    pi_head(PI, Goal),
+    asserta(sweep_current_identifier_at_point(meta:PI)).
+sweep_handle_identifier_at_point_goal(Path, M0, _Kind, Goal) :-
     pi_head(PI0, Goal),
     (   PI0 = M:PI
     ->  true
@@ -156,7 +232,12 @@ sweep_handle_identifier_at_point_(Path, M0, 
goal_term(_Kind, Goal)) :-
     ;   M = M0, PI = PI0
     ),
     asserta(sweep_current_identifier_at_point(M:PI)).
-sweep_handle_identifier_at_point_(_, _, _).
+
+sweep_is_global(global).
+sweep_is_global(global(_,_)).
+
+sweep_is_extern(extern(M),   M).
+sweep_is_extern(extern(M,_), M).
 
 sweep_colourise_some_terms([String,Path,Offset], Colors) :-
     setup_call_cleanup(( new_memory_file(H),



reply via email to

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