From 8217e543eb4b119512b6842d83a05b6f8f3c7748 Mon Sep 17 00:00:00 2001 From: t-gergely Date: Fri, 26 Apr 2019 11:55:43 +0200 Subject: [PATCH] Update tree-matching.md Deleted redundant and misplaced sample code. --- doc/tree-matching.md | 9 --------- 1 file changed, 9 deletions(-) diff --git a/doc/tree-matching.md b/doc/tree-matching.md index f4c6d278c..b0ec83bb5 100644 --- a/doc/tree-matching.md +++ b/doc/tree-matching.md @@ -52,15 +52,6 @@ m.setDelimiters("<<", ">>", "$"); // $ is the escape character This would allow pattern `<> = <> ;$<< ick $>>` to be interpreted as elements: `ID`, ` = `, `expr`, and ` ;<< ick >>`. -```java -String xpath = "//blockStatement/*"; -String treePattern = "int = ;"; -ParseTreePattern p = -parser.compileParseTreePattern(treePattern, -JavaParser.RULE_localVariableDeclarationStatement); -List matches = p.findAll(tree, xpath); -``` - ### Pattern labels The tree pattern matcher tracks the nodes in the tree at matches against the tags in a tree pattern. That way we can use the `get()` and `getAll()` methods to retrieve components of the matched subtree. For example, for pattern ``, `get("ID")` returns the node matched for that `ID`. If more than one node matched the specified token or rule tag, only the first match is returned. If there is no node associated with the label, this returns null.