1/*****************************************************************************
    2 * This file is part of the Prolog Development Tool (PDT)
    3 * 
    4 * WWW: http://sewiki.iai.uni-bonn.de/research/pdt/start
    5 * Mail: pdt@lists.iai.uni-bonn.de
    6 * Copyright (C): 2004-2012, CS Dept. III, University of Bonn
    7 * 
    8 * All rights reserved. This program is  made available under the terms
    9 * of the Eclipse Public License v1.0 which accompanies this distribution,
   10 * and is available at http://www.eclipse.org/legal/epl-v10.html
   11 * 
   12 ****************************************************************************/
   13
   14 :- module( properties, 
   15         [ properties_for_predicate/4   % (+Module, +Name, +Arity, ?PropertyList)
   16         , entity_property/3            % (+Entity, predicate|module, ?PropertyList)
   17         ]).
 properties_for_predicate(+Module, +Name, +Arity, ?PropertyList) is det
Gives a list of properties interest for the predicate that is referenced by Arg1:Arg2/Arg3 Selected properties of the predicate are elements of list arg4.
   23properties_for_predicate(Module,Name,Arity,PropertyList):-
   24    functor(Head,Name,Arity),
   25    entity_property(Module:Head, predicate, PropertyList).
   26    
   27entity_property(Head, predicate, PropertyList):-
   28    predicate_property(Head,_), %Add a Cut here? Maybe it could also be a module?
   29    get_property_list(Head, predicate, [dynamic, multifile, exported, transparent, imported_from(_), 
   30    	file(_), number_of_clauses(_)], PropertyList), !.
   31entity_property(Name, module, PropertyList):-
   32    module_property(Name,_), !,
   33    get_property_list(Name, module, [file(_)], PropertyList).
   34    
   35    
   36get_property_list(Head, Kind, Properties, List):-
   37	add_properties_to_list(Head, Kind, Properties,[],List).    
   38    
   39    
   40add_properties_to_list(_, _, [], List, List):-!.
   41add_properties_to_list(Head, Kind, [Property|Rest_Properties], Orig_List, New_List):-
   42    add_properties_to_list(Head, Kind, Rest_Properties,Orig_List,Rest_List),
   43    (	look_for_kind_and_property(Head, Kind, Property)
   44    ->	New_List = [Property|Rest_List]
   45    ;	New_List = Rest_List
   46    ).
   47    
   48look_for_kind_and_property(Head,predicate,Property):- predicate_property(Head,Property).
   49look_for_kind_and_property(Head,module,   Property):-    module_property(Head,Property)