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

pmd / pmd / #3722

pending completion
#3722

push

github actions

adangel
Suppress MissingOverride for Chars::isEmpty (#4291)

67270 of 127658 relevant lines covered (52.7%)

0.53 hits per line

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

80.95
/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/TypingContext.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.types;
6

7
import java.util.Collections;
8
import java.util.HashMap;
9
import java.util.List;
10
import java.util.Map;
11

12
import org.checkerframework.checker.nullness.qual.Nullable;
13

14
import net.sourceforge.pmd.internal.util.AssertionUtil;
15
import net.sourceforge.pmd.lang.java.symbols.JVariableSymbol;
16

17
/**
18
 * A mapping of variables to types.
19
 */
20
public final class TypingContext extends MapFunction<JVariableSymbol, @Nullable JTypeMirror> {
21

22
    /**
23
     * Empty context. Corresponds to defaulting all lambda param types
24
     * to their value in the AST.
25
     */
26
    public static final TypingContext DEFAULT = new TypingContext(null, Collections.emptyMap());
1✔
27

28
    private final @Nullable TypingContext parent;
29

30
    private TypingContext(@Nullable TypingContext parent, Map<JVariableSymbol, @Nullable JTypeMirror> map) {
31
        super(map);
1✔
32
        this.parent = parent;
1✔
33
    }
1✔
34

35
    @Override
36
    public @Nullable JTypeMirror apply(JVariableSymbol var) {
37
        JTypeMirror t = getMap().get(var);
1✔
38
        if (t == null && parent != null) {
1✔
39
            // try with parent
40
            return parent.apply(var);
×
41
        }
42
        return t;
1✔
43
    }
44

45
    /**
46
     * Return a new typing context which uses this one as a parent.
47
     */
48
    public TypingContext andThen(Map<JVariableSymbol, @Nullable JTypeMirror> map) {
49
        return new TypingContext(this, map);
1✔
50
    }
51

52
    public TypingContext andThenZip(List<JVariableSymbol> symbols, List<JTypeMirror> types) {
53
        AssertionUtil.requireParamNotNull("symbols", symbols);
1✔
54
        AssertionUtil.requireParamNotNull("types", types);
1✔
55
        if (symbols.size() != types.size()) {
1✔
56
            throw new IllegalArgumentException("Wrong size");
×
57
        } else if (symbols.isEmpty()) {
1✔
58
            return this;
×
59
        }
60

61
        Map<JVariableSymbol, JTypeMirror> newMap = new HashMap<>(symbols.size() + this.getMap().size());
1✔
62
        newMap.putAll(getMap());
1✔
63
        for (int i = 0; i < symbols.size(); i++) {
1✔
64
            newMap.put(symbols.get(i), types.get(i));
1✔
65
        }
66
        return this.andThen(newMap);
1✔
67
    }
68

69
    public static TypingContext zip(List<JVariableSymbol> symbols, List<JTypeMirror> types) {
70
        return DEFAULT.andThenZip(symbols, types);
×
71
    }
72

73
}
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