xpath_funs.yml (pmd-src-6.43.0) | : | xpath_funs.yml (pmd-src-6.44.0) | ||
---|---|---|---|---|
# This file describes custom XPath functions per language | # This file describes custom XPath functions per language | |||
# This is rendered using _includes/custom/xpath_fun_doc.html | # This is rendered using _includes/custom/xpath_fun_doc.html | |||
aliases: | aliases: | |||
- &qname_param | - &qname_param | |||
name: javaQualifiedName | name: javaQualifiedName | |||
type: "xs:string" | type: "xs:string" | |||
description: "The qualified name of a Java class, possibly with pairs of bra ckets to indicate an array type. | description: "The qualified name of a Java class, possibly with pairs of bra ckets to indicate an array type. | |||
Can also be a primitive type name." | 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 %}" | - &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 param | ||||
eter. | ||||
The function is only available in XPath 2.0. | ||||
- &needs_node_ctx "The requires the context node to be an element" | ||||
langs: | langs: | |||
- name: "Any language" | - name: "All languages" | |||
ns: "pmd" | ns: "pmd" | |||
header: "Functions available to all languages are in the namespace `pmd`." | ||||
funs: | funs: | |||
- name: fileName | - name: fileName | |||
returnType: "xs:string" | returnType: "xs:string" | |||
shortDescription: "Returns the current filename" | shortDescription: "Returns the simple name of the current file" | |||
description: "Returns the current simple filename without path but inclu | description: | | |||
ding the extension. | Returns the current simple file name, without path but including the e | |||
This can be used to write rules that check filename naming | xtension. | |||
conventions. | This can be used to write rules that check file naming conventions. | |||
<p>This function is available since PMD 6.38.0.</p>" | since: 6.38.0 | |||
notes: "The function can be called on any node." | notes: *needs_node_ctx | |||
examples: | examples: | |||
- code: "//b[pmd:fileName() = 'Foo.xml']" | - code: "//b[pmd:fileName() = 'Foo.xml']" | |||
outcome: "Matches any `<b>` tags in files called `Foo.xml`." | outcome: "Matches any `<b>` 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 `<b>` 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 `<b>` 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 `<b>` node which starts on the first col | ||||
umn 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 `<b>` node which spans exactly one chara | ||||
cter" | ||||
- name: "Java" | - name: "Java" | |||
ns: "pmd-java" | ns: "pmd-java" | |||
funs: | funs: | |||
- name: typeIs | - name: typeIs | |||
returnType: "xs:boolean" | returnType: "xs:boolean" | |||
shortDescription: "Tests a node's static type" | shortDescription: "Tests a node's static type" | |||
description: "Returns true if the context node's static Java type is a s ubtype of the given type. | description: "Returns true if the context node's static Java type is a s ubtype of the given type. | |||
This tests for the resolved type of the Java construct, no t the type of the AST node. | This tests for the resolved type of the Java construct, no t the type of the AST node. | |||
For example, the AST node for a literal (e.g. `5d`) has ty pe ASTLiteral, however this | For example, the AST node for a literal (e.g. `5d`) has ty pe ASTLiteral, however this | |||
function will compare the type of the literal (eg here, `d ouble`) against the argument." | function will compare the type of the literal (eg here, `d ouble`) against the argument." | |||
End of changes. 7 change blocks. | ||||
8 lines changed or deleted | 84 lines changed or added |