pmd-lang-test / net.sourceforge.pmd.lang.ast.test / matchNode

matchNode

inline fun <reified N : Node> matchNode(ignoreChildren: Boolean = false, noinline nodeSpec: NodeSpec<N>): Assertions<Node?>

Returns an assertion function asserting that its parameter conforms to the given NodeSpec.

Use it with io.kotest.matchers.should, e.g. node should matchNode<ASTExpression> {}.

See also the samples on TreeNodeWrapper.

Parameters

N - Expected type of the node

ignoreChildren - If true, calls to TreeNodeWrapper.child in the nodeSpec are forbidden. The number of children of the child is not asserted.

nodeSpec - Sequence of assertions to carry out on the node, which can be referred to by TreeNodeWrapper.it. Assertions may consist of NWrapper.child calls, which perform the same type of node matching on a child of the tested node.

Return
A matcher for AST nodes, suitable for use by io.kotest.matchers.should.