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

User Tools

Site Tools

The Prolog Search

The Prolog Search finds code loaded into the Prolog process that is currently selected in the 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:

  1. from the context menu of a selection in The Prolog Editor
  2. from the context menu of a selection in The Prolog Console

The Search Dialog

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.

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 use_module/1-2 or reexport/1-2 or by a call of a predicate declared in the found module.

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 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:

  1. Modules
    • (in logtalk this symbol indicates an “entity”).
  2. Predicates
    • = exported (in logtalk this symbol means “public”).
    • = not exported (in logtalk this symbol means “protected”).
    • = logtalk only: “private”.
    • = logtalk only: “local”.
  3. Files
    • = consulted file in project
  4. Matches
    • 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 PDT Tutorial Project.

Search StringSearch for…Limit to…Exact Match Results Kind of match
abc/1 Predicate Definitions Yes Line number and clause head (definition)
abc/1 Predicate References Yes Predicate call (reference)
search_demo Module/Entity Definitions No Module
search_demo Module/Entity References Yes 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

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).


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.

Open Search Dialog from Console Search Dialog
The highlighted text… …is the input for the search dialog.
research/pdt/docs/search.txt · Last modified: 2018/05/09 01:59 (external edit)

SEWiki, © 2024