Software Engineering for Smart Data Analytics & Smart Data Analytics for Software Engineering

User Tools

Site Tools


This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
research:pdt:docs:search [2015/01/13 16:06] external edit
research:pdt:docs:search [2018/05/09 01:59] (current)
Line 1: Line 1:
 +====== The Prolog Search ======
 +The Prolog Search finds code loaded into the Prolog process that is currently selected in the [[console|Prolog Console]].
 +It will not find predicates in files that are not consulted! If you want a textual search, use the 
 +textual search dialog that is standard in Eclipse.
 +There are three ways to run a search:
 +  - via [[#the search dialog]] ​
 +  - from the context menu of a selection in [[editor]]
 +  - from the context menu of a selection in [[console]]
 +===== The Search Dialog =====
 +{{ :​research:​pdt:​docs:​prolog_search_page.png|Search dialog}}
 +The Prolog Search dialog is availabe via the menu "​Search"​ --> "​Search..."​ or the keyboard shortcut **<​CTRL>​ <​H>​**.
 +Two different types of searches are possible.
 +==== Element Search ====
 +The following options are supported:
 +  * **Exact matches only**: If selected only modules and predicates whose name is equal to the search string will be found. If not selected modules and predicates whose name contains the search string will be found.
 +  * **Search for **
 +    * //​Module/​Entity//:​ Enter the module name as search string. If ''​mod''​ is the searched module name the search will find 
 +      * all explicit references (of the form ''​mod:​pred''​) ​
 +      * all implicit references (of the form ''​pred''​ if pred is imported from ''​mod'',​ typically via a use_module directive)  ​
 +    * //​Predicates//:​ Enter the search string as PredicateSymbol/​Arity. If no arity is specified, all matching predicate symbols will be found, regardless of arity.
 +  * **Limit to**
 +    * //​Declarations & Definitions//:​ Search for all declarations and definitions of entities or predicates whose name (and arity in case of predicates) matches the search string.
 +    * //​References//:​ Search for all references to modules or predicates matching the search string. A reference to a module is either given by an import via [[http://​​pldoc/​doc_for?​object=section%282,​%275.3%27,​swi%28%27/​doc/​manual/​import.html%27%29%29|use_module/​1-2]] or [[http://​​pldoc/​doc_for?​object=section%282,​%275.7%27,​swi%28%27/​doc/​manual/​reexport.html%27%29%29|reexport/​1-2]] or by a call of a predicate declared in the found module.
 +==== Problem Search ====
 +Three different problem searches are possible:
 +  * **Undefined Call**: Search for undefined calls.
 +  * **Dead Predicate**:​ Search for dead predicates, i.e. search for predicates which are not called (directly or indirectly) from entry points. There has to be at least one entry point to be able run this search. Entry points are:
 +    * all exported predicates of [[navigator#​entry_points|Entry Point Files]],
 +    * all exported predicates of modules specified by the multifile predicate ''​pdt_call_analysis:​entry_point/​1''​ and
 +    * all predicates specified by the multifile predicate ''​pdt_call_analysis:​entry_point/​1''​ (the expected format is ''​Module:​PredicateSymbol/​Arity''​).
 +  * **Undeclared Meta Predicate**:​ Search for undeclared or wrongly declared meta predicates.
 +For each search it is possible to use the **Create Warnings** option. If enabled a persistent Eclipse marker will be created for each search result.
 +===== Search Results =====
 +The results of the Prolog Search are presented in the Search View. The following elements are shown in this view:
 +  - **Modules** and **Files**
 +  - **Modules** ​
 +    * {{:​research:​pdt:​docs:​package_obj.gif}} (in logtalk this symbol indicates an "​entity"​).
 +  - **Predicates** ​
 +    * {{:​research:​pdt:​docs:​public_co.gif}} = exported (in logtalk this symbol means "​public"​).
 +    * {{:​research:​pdt:​docs:​protected_co.gif}} = not exported (in logtalk this symbol means "​protected"​).
 +    * {{:​research:​pdt:​docs:​private_co.gif}} = logtalk only: "​private"​.
 +    * {{:​research:​pdt:​docs:​variable.gif}} = logtalk only: "​local"​. ​
 +  - **Files**
 +    * {{:​research:​pdt:​docs:​prolog_file_consulted.png}} = consulted file in project
 +  - **Matches**
 +    * {{:​research:​pdt:​docs:​searchm_obj.gif}} a match. the sample search results show the different kinds of matches.
 +==== Sample Search Results ====
 +This is how search results for different search options look like. 
 +The searches were performed on the [[getting_started#​create_an_example_prolog_project|PDT Tutorial Project]].
 +^ ^  Options ​ ^^^ ^^
 +^Search String^Search for...^Limit to...^Exact Match^ ​ Results ​ ^  Kind of match  ^
 +|  abc/1  |  Predicate ​ |  Definitions ​ |  Yes  |{{:​research:​pdt:​docs:​search_result_pred_def.png|}}| ​ Line number and clause head (definition) ​ ||
 +|  abc/1  |  Predicate ​ |  References ​ |  Yes  |{{:​research:​pdt:​docs:​search_result_pred_ref.png|}}| ​ Predicate call (reference) ​ |
 +|  search_demo ​ |  Module/​Entity ​ |  Definitions ​ |  No  |{{:​research:​pdt:​docs:​search_result_module_def.png|}}| ​ Module ​ |
 +|  search_demo ​ |  Module/​Entity ​ |  References ​ |  Yes  |{{:​research:​pdt:​docs:​search_result_module_ref.png|}}| ​ Predicate call (reference) and \\ import declaration (reference to a module) ​ |
 +===== Search from Editor =====
 +You can start the search for predicates directly from the editor. ​
 +==== Declaration and Definitions ====
 +|{{finddeclarations.png|}} | {{finddeclarations_result.png|}}|
 +The search for predicate declarations and definitions from the editor ​
 +will find the same results like the global search via the search dialog ​
 +but the results will contain information regarding the context (current file) of the search:
 +  * //super//: predicate is defined in a module that is imported by the module of the current file
 +  * //local//: predicate is defined in the current file
 +  * //sub//: predicate is defined in a module that imports the module of the current file
 +  * //​invisible//:​ predicate is defined in a module that has no import relation to the current file
 +The "​invisible"​ category is intended to make programmers aware of unrelated but homonymous ​
 +predicates that could lead to confusion.
 +If results on multiple categories are found the categories are ordered as shown above 
 +(supermodules,​ local module, submodules and invisible predicates). ​
 +==== References ====
 +|{{findreferences.png|}} | {{findreferences_result.png|}}|
 +The reference search in the editor will find exactly the same results ​
 +as the global reference search.
 +===== Search from Prolog Console =====
 +Sometimes you might want to search for a predicate mentioned in a console message. For example, ​
 +after a message about a call to an undefined predicate you might want to find all other references to it. 
 +For this, select the predicate name (or full predicate indicator name/arity) in the console and choose ​
 +"Open Search Dialog"​ from the context menu. The Prolog Search dialog will be opened with the current ​
 +text selection in the Prolog Console as input.
 +|  {{console_search_1.png|Open Search Dialog from Console}} ​          ​| ​    ​{{console_search_2.png?​400|Search Dialog}} ​        |
 +|  The highlighted text... ​ | the input for the search dialog. ​ |
research/pdt/docs/search.txt · Last modified: 2018/05/09 01:59 (external edit)

SEWiki, © 2021