Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "tree/ast/astUtils"

Index

Type aliases

MatchTester

MatchTester: (n: LocatedTreeNode) => boolean

Tests matches within this file, using their tree node basis.

Type declaration

MatchTesterMaker

MatchTesterMaker: (f: File) => Promise<MatchTester>

Create a MatchTester to use against this file, caching any parsed or otherwise computed resources.

Type declaration

Functions

allPredicates

  • allPredicates(pe: PathExpression): Predicate[]

applyActionToMatches

doWithAllMatches

  • Integrate path expressions with project operations to find all matches of a path expression and perform a mutation on them them. Use with care!

    Type parameters

    Parameters

    Returns Promise<P>

    hit record for each matching file

fileHitIterator

fileMatches

fillInSourceLocations

findParser

findValues

  • Convenient method to find all values of matching nodes-- typically, terminals such as identifiers

    Parameters

    • p: ProjectAsync

      project

    • parserOrRegistry: FileParser | FileParserRegistry

      parser for files

    • globPatterns: GlobOptions

      file glob pattern

    • pathExpression: string | PathExpression

      path expression string or parsed

    • Optional functionRegistry: FunctionRegistry

      registry to look for path expression functions in

    Returns Promise<string[]>

    hit record for each matching file

gather

  • Integrate path expressions with project operations to gather mapped values from all matches. Choose the files with globPatterns; choose the portions of code to match with the pathExpression. Choose what to return based on each match with the mapper function. Returns all of the values returned by the mapper (except undefined).

    Type parameters

    • T

    Parameters

    Returns Promise<T[]>

    matches

gatherWithLocation

isAttributeEqualityPredicate

  • isAttributeEqualityPredicate(p: Predicate): p is AttributeEqualityPredicate

isNestedPredicate

  • isNestedPredicate(p: Predicate): p is NestedPathExpressionPredicate

literalValues

  • literalValues(pex: PathExpression): string[]
  • Return literal values that must be present in a file for this path expression to match. Return the empty array if there are no literal @values or if we cannot determine whether there may be for this path expression.

    Parameters

    • pex: PathExpression

    Returns string[]

matchIterator

matches

parseFile

pathExpressionFileMatches

zapAllMatches

  • Integrate path expressions with project operations to find all matches of a path expression and zap them. Use with care!

    Type parameters

    Parameters

    Returns Promise<P>

    hit record for each matching file

Generated using TypeDoc