Merge branch 'xml-new-xpath-rule' into pmd7-merge-xml-rule

This commit is contained in:
Clément Fournier
2022-03-24 19:21:17 +01:00
14 changed files with 800 additions and 34 deletions
+3
View File
@@ -367,6 +367,9 @@ entries:
- title: Visualforce
url: /pmd_languages_visualforce.html
output: web, pdf
- title: XML and XML dialects
url: /pmd_languages_xml.html
output: web, pdf
- title: Developer Documentation
output: web, pdf
folderitems:
+76 -7
View File
@@ -7,24 +7,93 @@ aliases:
type: "xs:string"
description: "The qualified name of a Java class, possibly with pairs of brackets to indicate an array type.
Can also be a primitive type name."
- &node_param
name: element
type: "xs:element"
description: "Any element node"
- &needs_typenode "The context node must be a {% jdoc jast::TypeNode %}"
- &coord_fun_note |
The function is not context-dependent, but takes a node as its first parameter.
The function is only available in XPath 2.0.
- &needs_node_ctx "The requires the context node to be an element"
langs:
- name: "Any language"
- name: "All languages"
ns: "pmd"
header: "Functions available to all languages are in the namespace `pmd`."
funs:
- name: fileName
returnType: "xs:string"
shortDescription: "Returns the current filename"
description: "Returns the current simple filename without path but including the extension.
This can be used to write rules that check filename naming conventions.
<p>This function is available since PMD 6.38.0.</p>"
notes: "The function can be called on any node."
shortDescription: "Returns the simple name of the current file"
description: |
Returns the current simple file name, without path but including the extension.
This can be used to write rules that check file naming conventions.
since: 6.38.0
notes: *needs_node_ctx
examples:
- code: "//b[pmd:fileName() = 'Foo.xml']"
outcome: "Matches any `&lt;b&gt;` tags in files called `Foo.xml`."
- name: startLine
returnType: "xs:int"
parameters:
- *node_param
shortDescription: "Returns the start line of the given node"
description: |
Returns the line where the node starts in the source file.
Line numbers are 1-based.
since: 6.44.0
notes: *coord_fun_note
examples:
- code: "//b[pmd:startLine(.) > 5]"
outcome: "Matches any `&lt;b&gt;` node which starts after the fifth line."
- name: endLine
returnType: "xs:int"
parameters:
- *node_param
shortDescription: "Returns the end line of the given node"
description: |
Returns the line where the node ends in the source file.
Line numbers are 1-based.
since: 6.44.0
notes: *coord_fun_note
examples:
- code: "//b[pmd:endLine(.) == pmd:startLine(.)]"
outcome: "Matches any `&lt;b&gt;` node which doesn't span more than one line."
- name: startColumn
returnType: "xs:int"
parameters:
- *node_param
shortDescription: "Returns the start column of the given node (inclusive)"
description: |
Returns the column number where the node starts in the source file.
Column numbers are 1-based. The start column is inclusive.
since: 6.44.0
notes: *coord_fun_note
examples:
- code: "//b[pmd:startColumn(.) = 1]"
outcome: "Matches any `&lt;b&gt;` node which starts on the first column of a line"
- name: endColumn
returnType: "xs:int"
parameters:
- *node_param
shortDescription: "Returns the end column of the given node (exclusive)"
description: |
Returns the column number where the node ends in the source file.
Column numbers are 1-based. The end column is exclusive.
since: 6.44.0
notes: *coord_fun_note
examples:
- code: "//b[pmd:startLine(.) = pmd:endLine(.) and pmd:endColumn(.) - pmd:startColumn(.) = 1]"
outcome: "Matches any `&lt;b&gt;` node which spans exactly one character"
- name: "Java"
ns: "pmd-java"