Did you know ... Search Documentation:
Pack refactor -- prolog/fix_termpos.pl
PublicShow source
 term_innerpos(OFrom, OTo, InnerFrom, InnerTo)
Contains the inner positions of a term, that exclude comments and some extra parenthesis.
 fix_termpos(@TermPos, +Options) is det
Applies fix_subtermpos recursivelly and extends the boundaries of the first term position from the first comment up to just before the ending dot.

The subterm positions are adjusted recursively according to the Options as follows:

  • subterm_boundary(+Boundary) Specifies what are the boundaries of the term, which can be subterm, leftcomm, rightcomm or comment (default).

    Due to performance concerns, this predicate makes a destructive assignment in the TermPos argument, but preserve the extra positions in the term_innerpos/4 predicate.

    @see fix_subtermpos/1

 fix_subtermpos(@TermPos, Boundaries) is det
Takes a subterm position, as returned by the subterm_positions option of read_term/2 and increases its precision, avoiding some minor mistmatches with the text, that for a refactoring tool is instrumental. This method also ensures that the minimal required parenthesis enclosing a term are contained in its scope, widening the positions 1 and 2 of the given term position specifier. The current implementation is aware of comments and extra parenthesis, asserting such information in term_innerpos/4 facts.
To be done
- This implementation have performance issues, needs optimization.

Undocumented predicates

The following predicates are exported, but not or incorrectly documented.

 fix_termpos(Arg1)
 fix_subtermpos(Arg1)