• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pmd / pmd / 317

19 Dec 2025 11:16AM UTC coverage: 78.975% (+0.01%) from 78.963%
317

push

github

adangel
[core] Fix #6330: Cannot access Chars attribute from XPath (#6342)

18510 of 24316 branches covered (76.12%)

Branch coverage included in aggregate %.

11 of 11 new or added lines in 2 files covered. (100.0%)

5 existing lines in 3 files now uncovered.

40302 of 50153 relevant lines covered (80.36%)

0.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

68.29
/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/InternalInterfaces.java
1
/*
2
 * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3
 */
4

5
package net.sourceforge.pmd.lang.java.ast;
6

7

8
import java.util.Iterator;
9

10
import org.checkerframework.checker.nullness.qual.NonNull;
11
import org.checkerframework.checker.nullness.qual.Nullable;
12

13
import net.sourceforge.pmd.lang.ast.NodeStream;
14

15
/**
16
 * Those are some interfaces that are not published, but are used to keep
17
 * uniform names on related concepts. Maybe it makes sense to publish some of
18
 * them at some point.
19
 */
20
// Suppressing MissingStaticMethodInNonInstantiatableClass: This class is used here as a namespace
21
// for related interfaces. The outer class indeed cannot be instantiated and doesn't have any static
22
// methods. This is similar like #1652.
23
@SuppressWarnings("PMD.MissingStaticMethodInNonInstantiatableClass")
24
final class InternalInterfaces {
25

26
    private InternalInterfaces() {
27
        // just a namespace for related interfaces
28
    }
29

30
    interface OperatorLike {
31

32

33
        /**
34
         * Returns the token used to represent the type in source
35
         * code, e.g. {@code "+"} or {@code "*"}.
36
         */
37
        String getToken();
38

39
    }
40

41
    /** Just to share the method names. */
42
    interface BinaryExpressionLike extends ASTExpression {
43

44
        /** Returns the left-hand-side operand. */
45
        default @NonNull ASTExpression getLeftOperand() {
46
            return (ASTExpression) getChild(0);
1✔
47
        }
48

49

50
        /** Returns the right-hand side operand. */
51
        default @NonNull ASTExpression getRightOperand() {
52
            return (ASTExpression) getChild(1);
1✔
53
        }
54

55

56
        /** Returns the operator. */
57
        @NonNull OperatorLike getOperator();
58
    }
59

60
    /**
61
     * Tags a node that has at least one child, then some methods never
62
     * return null.
63
     */
64
    interface AtLeastOneChild extends JavaNode {
1!
65

66

67
        /** Returns the first child of this node, never null. */
68
        @Override
69
        default @NonNull JavaNode getFirstChild() {
70
            assert getNumChildren() > 0;
1!
71
            return getChild(0);
1✔
72
        }
73

74

75
        /** Returns the last child of this node, never null. */
76
        @Override
77
        default @NonNull JavaNode getLastChild() {
UNCOV
78
            assert getNumChildren() > 0;
×
UNCOV
79
            return getChild(getNumChildren() - 1);
×
80
        }
81
    }
82

83
    interface AllChildrenAreOfType<T extends JavaNode> extends JavaNode {
84

85
        @Override
86
        default @Nullable T getFirstChild() {
87
            if (getNumChildren() == 0) {
1✔
88
                return null;
1✔
89
            }
90
            return (T) getChild(0);
1✔
91
        }
92

93

94
        @Override
95
        default @Nullable T getLastChild() {
96
            if (getNumChildren() == 0) {
1✔
97
                return null;
1✔
98
            }
99
            return (T) getChild(getNumChildren() - 1);
1✔
100
        }
101
    }
102

103
    /**
104
     * Tags a node that has at least one child, then some methods never
105
     * return null.
106
     */
107
    interface AtLeastOneChildOfType<T extends JavaNode> extends AllChildrenAreOfType<T> {
108

109
        /** Returns the first child of this node, never null. */
110
        @Override
111
        default @NonNull T getFirstChild() {
112
            assert getNumChildren() > 0 : "No children for node implementing AtLeastOneChild " + this;
1!
113
            return (T) getChild(0);
1✔
114
        }
115

116

117
        /** Returns the last child of this node, never null. */
118
        @Override
119
        default @NonNull T getLastChild() {
120
            assert getNumChildren() > 0 : "No children for node implementing AtLeastOneChild " + this;
1!
121
            return (T) getChild(getNumChildren() - 1);
1✔
122
        }
123
    }
124

125
    interface VariableIdOwner extends JavaNode {
126

127
        /** Returns the id of the declared variable. */
128
        ASTVariableId getVarId();
129
    }
130

131
    interface MultiVariableIdOwner extends Iterable<ASTVariableId>, ModifierOwner {
132

133
        /**
134
         * Returns a stream of the variable ids declared
135
         * by this node.
136
         */
137
        default NodeStream<ASTVariableId> getVarIds() {
138
            return children(ASTVariableDeclarator.class).children(ASTVariableId.class);
1✔
139
        }
140

141

142
        @Override
143
        default Iterator<ASTVariableId> iterator() {
144
            return getVarIds().iterator();
1✔
145
        }
146

147
        ASTType getTypeNode();
148
    }
149

150
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc