pmd/docs/_data/xpath_funs.yml

56 lines
2.6 KiB
YAML
Raw Normal View History

2020-01-24 18:39:58 +01:00
# This file describes custom XPath functions per language
# This is rendered using _includes/custom/xpath_fun_doc.html
2019-04-05 14:13:39 +02:00
aliases:
- &qname_param
name: javaQualifiedName
type: "xs:string"
2019-04-07 18:00:02 +02:00
description: "The qualified name of a Java class, possibly with pairs of brackets to indicate an array type.
2019-04-05 14:13:39 +02:00
Can also be a primitive type name."
- &needs_typenode "The context node must be a {% jdoc jast::TypeNode %}"
2019-03-06 01:29:53 +01:00
langs:
- name: "Java"
ns: "pmd-java"
funs:
- name: typeIs
returnType: "xs:boolean"
2019-04-05 14:13:39 +02:00
shortDescription: "Tests a node's static type"
2019-04-07 18:00:02 +02:00
description: "Returns true if the context node's static Java type is a subtype of the given type.
This tests for the resolved type of the Java construct, not the type of the AST node.
For example, the AST node for a literal (e.g. `5d`) has type ASTLiteral, however this
function will compare the type of the literal (eg here, `double`) against the argument."
2019-04-05 14:13:39 +02:00
notes: *needs_typenode
2019-03-06 01:29:53 +01:00
parameters:
2019-04-05 14:13:39 +02:00
- *qname_param
2019-04-07 18:00:02 +02:00
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")]'
outcome: "Matches variable declarators of type `List` or any of its subtypes (including e.g. `ArrayList`)"
2019-03-06 01:29:53 +01:00
- name: typeIsExactly
returnType: "xs:boolean"
2019-04-05 14:13:39 +02:00
shortDescription: "Tests a node's static type, ignoring subtypes"
2019-03-06 01:29:53 +01:00
description: "Returns true if the context node's static type is exactly the given type.
In particular, returns false if the context node's type is
a subtype of the given type."
2019-04-05 14:13:39 +02:00
notes: *needs_typenode
parameters:
- *qname_param
2019-04-07 18:00:02 +02:00
examples:
- code: '//VariableDeclaratorId[pmd-java:typeIsExactly("java.lang.List")]'
outcome: "Matches variable declarators of type `List` (but not e.g. `ArrayList`)"
2019-03-06 01:29:53 +01:00
- name: metric
returnType: "xs:decimal?"
2019-04-05 14:13:39 +02:00
shortDescription: "Computes and returns the value of a metric"
2019-03-06 01:29:53 +01:00
description: "Returns the value of the metric as evaluated on the context node"
notes: "The context node must be a {% jdoc jast::ASTAnyTypeDeclaration %} or a {% jdoc jast::MethodLikeNode %}"
parameters:
- name: "metricKey"
2019-03-06 02:22:36 +01:00
type: "xs:string"
description: "The name of an enum constant in {% jdoc jmx::api.JavaOperationMetricKey %} or {% jdoc jmx::api.JavaClassMetricKey %}"