diff --git a/docs/_data/xpath_funs.yml b/docs/_data/xpath_funs.yml index 8f36e10ffa..42b2bf93c3 100644 --- a/docs/_data/xpath_funs.yml +++ b/docs/_data/xpath_funs.yml @@ -129,7 +129,7 @@ langs: examples: - code: '//FormalParameter[pmd-java:typeIs("java.lang.String[]")]' outcome: "Matches formal parameters of type `String[]` (including vararg parameters)" - - code: '//VariableDeclaratorId[pmd-java:typeIs("java.lang.List")]' + - code: '//VariableId[pmd-java:typeIs("java.lang.List")]' outcome: "Matches variable declarators of type `List` or any of its subtypes (including e.g. `ArrayList`)" - name: typeIsExactly @@ -142,7 +142,7 @@ langs: parameters: - *qname_param examples: - - code: '//VariableDeclaratorId[pmd-java:typeIsExactly("java.lang.List")]' + - code: '//VariableId[pmd-java:typeIsExactly("java.lang.List")]' outcome: "Matches variable declarators of type `List` (but not e.g. `ArrayList`)" diff --git a/docs/pages/pmd/devdocs/experimental/ast_dump.md b/docs/pages/pmd/devdocs/experimental/ast_dump.md index 769d036d71..c2c97cd7ed 100644 --- a/docs/pages/pmd/devdocs/experimental/ast_dump.md +++ b/docs/pages/pmd/devdocs/experimental/ast_dump.md @@ -76,7 +76,7 @@ $ cat Foo.xml - + @@ -85,8 +85,8 @@ $ cat Foo.xml -$ xmlstarlet select -t -c "//VariableDeclaratorId[@VariableName='a']" Foo.xml - +$ xmlstarlet select -t -c "//VariableId[@VariableName='a']" Foo.xml + ``` This example uses [xmlstarlet](http://xmlstar.sourceforge.net/) to query the xml document for any variables/fields diff --git a/docs/pages/pmd/userdocs/extending/defining_properties.md b/docs/pages/pmd/userdocs/extending/defining_properties.md index f47996fe5a..415ae2983d 100644 --- a/docs/pages/pmd/userdocs/extending/defining_properties.md +++ b/docs/pages/pmd/userdocs/extending/defining_properties.md @@ -158,7 +158,7 @@ with a backslash when needed. description="A StringMultiProperty." /> diff --git a/docs/pages/pmd/userdocs/extending/writing_java_rules.md b/docs/pages/pmd/userdocs/extending/writing_java_rules.md index 14619958b7..5648a94673 100644 --- a/docs/pages/pmd/userdocs/extending/writing_java_rules.md +++ b/docs/pages/pmd/userdocs/extending/writing_java_rules.md @@ -61,8 +61,8 @@ public class MyRule extends AbstractJavaRule { Generally, a rule wants to check for only some node types. In our XPath example in [Your First Rule](pmd_userdocs_extending_your_first_rule.html), -we wanted to check for some `VariableDeclaratorId` nodes. That's the XPath name, -but in Java, you'll get access to the {% jdoc jast::ASTVariableDeclaratorId %} +we wanted to check for some `VariableId` nodes. That's the XPath name, +but in Java, you'll get access to the {% jdoc jast::ASTVariableId %} full API. If you want to check for some specific node types, you can override the @@ -72,8 +72,8 @@ corresponding `visit` method: public class MyRule extends AbstractJavaRule { @Override - public Object visit(ASTVariableDeclaratorId node, Object data) { - // This method is called on each node of type ASTVariableDeclaratorId + public Object visit(ASTVariableId node, Object data) { + // This method is called on each node of type ASTVariableId // in the AST if (node.getType() == short.class) { diff --git a/docs/pages/pmd/userdocs/extending/your_first_rule.md b/docs/pages/pmd/userdocs/extending/your_first_rule.md index d9ff74802b..bcac8f4c8c 100644 --- a/docs/pages/pmd/userdocs/extending/your_first_rule.md +++ b/docs/pages/pmd/userdocs/extending/your_first_rule.md @@ -83,11 +83,11 @@ public class KeepingItSerious { ``` -Examining the AST, you find out that the LocalVariableDeclaration has a VariableDeclaratorId -descendant, whose `Image` XPath attribute is exactly `bill`. You thus write your first attempt +Examining the AST, you find out that the LocalVariableDeclaration has a VariableId +descendant, whose `Name` XPath attribute is exactly `bill`. You thus write your first attempt in the XPath editor: ```xpath -//VariableDeclaratorId[@Image = "bill"] +//VariableId[@Name = "bill"] ``` You can see the XPath result list is updated with the variable declarator. @@ -112,7 +112,7 @@ based on your examination of the Type node of the field and local variable declaration nodes. ```xpath -//VariableDeclaratorId[@Image = "bill" and ../../Type[@TypeImage = "short"]] +//VariableId[@Name = "bill" and ../../Type[@TypeImage = "short"]] ``` ### Exporting to XML @@ -135,7 +135,7 @@ TODO diff --git a/docs/pages/pmd/userdocs/migrating_to_pmd7.md b/docs/pages/pmd/userdocs/migrating_to_pmd7.md index 09593ed18a..c0eb849ccd 100644 --- a/docs/pages/pmd/userdocs/migrating_to_pmd7.md +++ b/docs/pages/pmd/userdocs/migrating_to_pmd7.md @@ -38,7 +38,7 @@ There are a couple of deprecated things in PMD 6, you might encounter: * If you have written custom XPath rule, look out for warnings about deprecated XPath attributes. These warnings might look like ``` - WARNING: Use of deprecated attribute 'VariableDeclaratorId/@Image' by XPath rule 'VariableNaming' (in ruleset 'VariableNamingRule'), please use @Name instead + WARNING: Use of deprecated attribute 'VariableId/@Image' by XPath rule 'VariableNaming' (in ruleset 'VariableNamingRule'), please use @Name instead ``` and often already suggest an alternative. @@ -101,7 +101,7 @@ override the method {% jdoc core::lang.rule.AbstractRule#buildTargetSelector %}: ```java protected RuleTargetSelector buildTargetSelector() { - return RuleTargetSelector.forTypes(ASTVariableDeclaratorId.class); + return RuleTargetSelector.forTypes(ASTVariableId.class); } ``` @@ -318,7 +318,7 @@ Example: ```java NodeStream.of(someNode) // the stream here is empty if the node is null - .filterIs(ASTVariableDeclaratorId.class)// the stream here is empty if the node was not a variable declarator id + .filterIs(ASTVariableId.class) // the stream here is empty if the node was not a variable id .followingSiblings() // the stream here contains only the siblings, not the original node .children(ASTNumericLiteral.class) .filter(ASTNumericLiteral::isIntLiteral) @@ -397,6 +397,7 @@ which can also display the AST. * ClassOrInterfaceDeclaration ➡️ ClassDeclaration ({% jdoc jast::ASTClassDeclaration %}) * AnyTypeDeclaration ➡️ TypeDeclaration ({% jdoc jast::ASTTypeDeclaration %}) * MethodOrConstructorDeclaration ➡️ ExecutableDeclaration ({% jdoc jast::ASTExecutableDeclaration %}) +* VariableDeclaratorId ➡️ VariableId ({% jdoc jast::ASTVariableId %}) #### Annotations @@ -786,7 +787,7 @@ Array type │ └─ Annotation "B" │ └─ ClassType "B" └─ VariableDeclarator - └─ VariableDeclaratorId "x" + └─ VariableId "x" {% endhighlight %} @@ -866,12 +867,12 @@ enum E { │ ├─ ModifierList │ │ └─ Annotation "A" │ │ └─ ClassType "A" - │ └─ VariableDeclaratorId "E1" + │ └─ VariableId "E1" └─ EnumConstant "E2" ├─ ModifierList │ └─ Annotation "B" │ └─ ClassType "B" - └─ VariableDeclaratorId "E2" + └─ VariableId "E2" {% endhighlight %}