"Fossies" - the Fresh Open Source Software Archive 
Member "pmd-src-6.47.0/docs/_data/xpath_funs.yml" (25 Jun 2022, 5859 Bytes) of package /linux/misc/pmd-src-6.47.0.zip:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Ansible YAML source code syntax highlighting (style:
standard) with prefixed line numbers.
Alternatively you can here
view or
download the uninterpreted source code file.
See also the last
Fossies "Diffs" side-by-side code changes report for "xpath_funs.yml":
6.43.0_vs_6.44.0.
1 # This file describes custom XPath functions per language
2 # This is rendered using _includes/custom/xpath_fun_doc.html
3
4 aliases:
5 - &qname_param
6 name: javaQualifiedName
7 type: "xs:string"
8 description: "The qualified name of a Java class, possibly with pairs of brackets to indicate an array type.
9 Can also be a primitive type name."
10 - &node_param
11 name: element
12 type: "xs:element"
13 description: "Any element node"
14 - &needs_typenode "The context node must be a {% jdoc jast::TypeNode %}"
15 - &coord_fun_note |
16 The function is not context-dependent, but takes a node as its first parameter.
17 The function is only available in XPath 2.0.
18 - &needs_node_ctx "The requires the context node to be an element"
19
20 langs:
21 - name: "All languages"
22 ns: "pmd"
23 header: "Functions available to all languages are in the namespace `pmd`."
24 funs:
25 - name: fileName
26 returnType: "xs:string"
27 shortDescription: "Returns the simple name of the current file"
28 description: |
29 Returns the current simple file name, without path but including the extension.
30 This can be used to write rules that check file naming conventions.
31
32 since: 6.38.0
33 notes: *needs_node_ctx
34 examples:
35 - code: "//b[pmd:fileName() = 'Foo.xml']"
36 outcome: "Matches any `<b>` tags in files called `Foo.xml`."
37
38 - name: startLine
39 returnType: "xs:int"
40 parameters:
41 - *node_param
42 shortDescription: "Returns the start line of the given node"
43 description: |
44 Returns the line where the node starts in the source file.
45 Line numbers are 1-based.
46
47 since: 6.44.0
48 notes: *coord_fun_note
49 examples:
50 - code: "//b[pmd:startLine(.) > 5]"
51 outcome: "Matches any `<b>` node which starts after the fifth line."
52
53 - name: endLine
54 returnType: "xs:int"
55 parameters:
56 - *node_param
57 shortDescription: "Returns the end line of the given node"
58 description: |
59 Returns the line where the node ends in the source file.
60 Line numbers are 1-based.
61
62 since: 6.44.0
63 notes: *coord_fun_note
64 examples:
65 - code: "//b[pmd:endLine(.) == pmd:startLine(.)]"
66 outcome: "Matches any `<b>` node which doesn't span more than one line."
67
68 - name: startColumn
69 returnType: "xs:int"
70 parameters:
71 - *node_param
72 shortDescription: "Returns the start column of the given node (inclusive)"
73 description: |
74 Returns the column number where the node starts in the source file.
75 Column numbers are 1-based. The start column is inclusive.
76
77 since: 6.44.0
78 notes: *coord_fun_note
79 examples:
80 - code: "//b[pmd:startColumn(.) = 1]"
81 outcome: "Matches any `<b>` node which starts on the first column of a line"
82
83 - name: endColumn
84 returnType: "xs:int"
85 parameters:
86 - *node_param
87 shortDescription: "Returns the end column of the given node (exclusive)"
88 description: |
89 Returns the column number where the node ends in the source file.
90 Column numbers are 1-based. The end column is exclusive.
91
92 since: 6.44.0
93 notes: *coord_fun_note
94 examples:
95 - code: "//b[pmd:startLine(.) = pmd:endLine(.) and pmd:endColumn(.) - pmd:startColumn(.) = 1]"
96 outcome: "Matches any `<b>` node which spans exactly one character"
97
98 - name: "Java"
99 ns: "pmd-java"
100 funs:
101 - name: typeIs
102 returnType: "xs:boolean"
103 shortDescription: "Tests a node's static type"
104 description: "Returns true if the context node's static Java type is a subtype of the given type.
105 This tests for the resolved type of the Java construct, not the type of the AST node.
106 For example, the AST node for a literal (e.g. `5d`) has type ASTLiteral, however this
107 function will compare the type of the literal (eg here, `double`) against the argument."
108 notes: *needs_typenode
109 parameters:
110 - *qname_param
111 examples:
112 - code: '//FormalParameter[pmd-java:typeIs("java.lang.String[]")]'
113 outcome: "Matches formal parameters of type `String[]` (including vararg parameters)"
114 - code: '//VariableDeclaratorId[pmd-java:typeIs("java.lang.List")]'
115 outcome: "Matches variable declarators of type `List` or any of its subtypes (including e.g. `ArrayList`)"
116
117
118 - name: typeIsExactly
119 returnType: "xs:boolean"
120 shortDescription: "Tests a node's static type, ignoring subtypes"
121 description: "Returns true if the context node's static type is exactly the given type.
122 In particular, returns false if the context node's type is
123 a subtype of the given type."
124 notes: *needs_typenode
125 parameters:
126 - *qname_param
127 examples:
128 - code: '//VariableDeclaratorId[pmd-java:typeIsExactly("java.lang.List")]'
129 outcome: "Matches variable declarators of type `List` (but not e.g. `ArrayList`)"
130
131
132 - name: metric
133 returnType: "xs:decimal?"
134 shortDescription: "Computes and returns the value of a metric"
135 description: "Returns the value of the metric as evaluated on the context node"
136 notes: "The context node must be a {% jdoc jast::ASTAnyTypeDeclaration %} or a {% jdoc jast::MethodLikeNode %}"
137 parameters:
138 - name: "metricKey"
139 type: "xs:string"
140 description: "The name of an enum constant in {% jdoc jmx::api.JavaOperationMetricKey %} or {% jdoc jmx::api.JavaClassMetricKey %}"