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

pmd / pmd / 415

27 Feb 2026 12:39PM UTC coverage: 79.038% (+0.03%) from 79.004%
415

push

github

adangel
[release] Prepare next development version

18604 of 24437 branches covered (76.13%)

Branch coverage included in aggregate %.

40598 of 50466 relevant lines covered (80.45%)

0.81 hits per line

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

82.61
/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/internal/ast/SymbolResolutionPass.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.symbols.internal.ast;
6

7
import java.util.Objects;
8

9
import org.checkerframework.checker.nullness.qual.Nullable;
10
import org.pcollections.PSet;
11

12
import net.sourceforge.pmd.lang.ast.NodeStream;
13
import net.sourceforge.pmd.lang.java.ast.ASTAnnotation;
14
import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit;
15
import net.sourceforge.pmd.lang.java.ast.ASTTypeDeclaration;
16
import net.sourceforge.pmd.lang.java.ast.InternalApiBridge;
17
import net.sourceforge.pmd.lang.java.ast.SymbolDeclaratorNode;
18
import net.sourceforge.pmd.lang.java.internal.JavaAstProcessor;
19
import net.sourceforge.pmd.lang.java.symbols.JClassSymbol;
20
import net.sourceforge.pmd.lang.java.symbols.JTypeDeclSymbol;
21
import net.sourceforge.pmd.lang.java.symbols.SymbolResolver;
22
import net.sourceforge.pmd.lang.java.symbols.SymbolicValue.SymAnnot;
23
import net.sourceforge.pmd.util.CollectionUtil;
24

25

26
/**
27
 * Populates symbols on declaration nodes.
28
 */
29
public final class SymbolResolutionPass {
1✔
30

31
    private SymbolResolutionPass() {
32
        // façade
33
    }
34

35
    /**
36
     * Traverse the given compilation unit, creating symbols on all
37
     * {@link SymbolDeclaratorNode}s.
38
     *
39
     * @param processor Processor
40
     * @param root      Root node
41
     *
42
     * @return A symbol resolver for all encountered type declarations.
43
     *     This is used to avoid hitting the classloader for local declarations.
44
     */
45
    public static SymbolResolver traverse(JavaAstProcessor processor, ASTCompilationUnit root) {
46
        AstSymbolMakerVisitor visitor = new AstSymbolMakerVisitor(root);
1✔
47
        root.acceptVisitor(visitor, new AstSymFactory(processor));
1✔
48
        return visitor.makeKnownSymbolResolver();
1✔
49
    }
50

51
    public static void desugarLombokMembers(JavaAstProcessor processor, ASTTypeDeclaration type) {
52
        assert processor.hasFirstClassLombokSupport() : "This method should not be called if Lombok support is disabled";
1!
53

54
        JClassSymbol symbol = type.getSymbol();
1✔
55
        if (symbol instanceof AstClassSym) {
1!
56
            ((AstClassSym) symbol).processLombok(processor);
1✔
57
        }
58
    }
1✔
59

60
    /**
61
     * Converts between nodes to {@link SymAnnot}. Annotations that could not be converted,
62
     * eg because they are written with invalid code, are discarded.
63
     */
64
    public static PSet<SymAnnot> buildSymbolicAnnotations(NodeStream<ASTAnnotation> annotations) {
65
        return annotations.toStream()
1✔
66
                          .map(SymbolResolutionPass::toValidAnnotation)
1✔
67
                          .filter(Objects::nonNull)
1✔
68
                          .collect(CollectionUtil.toPersistentSet());
1✔
69
    }
70

71
    private static @Nullable SymAnnot toValidAnnotation(ASTAnnotation node) {
72
        JTypeDeclSymbol sym = InternalApiBridge.getReferencedSym(node.getTypeNode());
1✔
73
        if (sym instanceof JClassSymbol) {
1!
74
            return new AstSymbolicAnnot(node, (JClassSymbol) sym);
1✔
75
        }
76
        return null;
×
77
    }
78
}
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