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

leeonky / test-charm-java / 212

14 Apr 2025 05:15AM UTC coverage: 74.088% (-0.1%) from 74.209%
212

push

circleci

leeonky
Update version

7957 of 10740 relevant lines covered (74.09%)

0.74 hits per line

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

97.37
/DAL-java/src/main/java/com/github/leeonky/dal/ast/node/DALExpression.java
1
package com.github.leeonky.dal.ast.node;
2

3
import com.github.leeonky.dal.ast.node.table.RowHeader;
4
import com.github.leeonky.dal.ast.node.table.RowType;
5
import com.github.leeonky.dal.ast.opt.DALOperator;
6
import com.github.leeonky.dal.runtime.Data;
7
import com.github.leeonky.dal.runtime.ExpressionException;
8
import com.github.leeonky.dal.runtime.RuntimeContextBuilder.DALRuntimeContext;
9
import com.github.leeonky.interpreter.Expression;
10

11
import java.util.ArrayList;
12
import java.util.List;
13
import java.util.stream.Stream;
14

15
import static com.github.leeonky.dal.runtime.DalException.locateError;
16

17
public class DALExpression extends DALNode implements Expression<DALRuntimeContext, DALNode, DALExpression, DALOperator>,
18
        ExecutableNode {
19
    private final DALNode left;
20
    private final DALOperator operator;
21
    private final DALNode right;
22

23
    private DALExpression(DALNode left, DALOperator operator, DALNode right) {
1✔
24
        this.left = left;
1✔
25
        this.right = right;
1✔
26
        this.operator = operator;
1✔
27
        setPositionBegin(operator.getPosition());
1✔
28
    }
1✔
29

30
    public static DALNode expression(DALNode left, DALOperator operator, DALNode right) {
31
        if (left instanceof GroupExpression)
1✔
32
            return ((GroupExpression) left).append(operator, right);
1✔
33
        if (right instanceof GroupExpression)
1✔
34
            return ((GroupExpression) right).insert(left, operator);
1✔
35
        return new DALExpression(left, operator, right).applyPrecedence(DALExpression::new);
1✔
36
    }
37

38
    @Override
39
    public DALNode left() {
40
        return left;
1✔
41
    }
42

43
    @Override
44
    public DALNode right() {
45
        return right;
1✔
46
    }
47

48
    @Override
49
    public DALOperator operator() {
50
        return operator;
1✔
51
    }
52

53
    @Override
54
    public Data evaluateData(DALRuntimeContext context) {
55
        try {
56
            return operator.calculateData(this, context);
1✔
57
        } catch (ExpressionException e) {
1✔
58
            throw e.rethrow(this);
1✔
59
        } catch (Throwable e) {
1✔
60
            throw locateError(e, right().getPositionBegin());
1✔
61
        }
62
    }
63

64
    @Override
65
    public String inspect() {
66
        return operator.inspect(left == null ? null : left.inspect(), right.inspect());
1✔
67
    }
68

69
    @Override
70
    public Object getRootSymbolName() {
71
        return left instanceof InputNode || isRootPropertyThis() ? right.getRootSymbolName() : left.getRootSymbolName();
1✔
72
    }
73

74
    private boolean isRootPropertyThis() {
75
        return left instanceof DALExpression && ((DALExpression) left).right() instanceof PropertyThis;
1✔
76
    }
77

78
    @Override
79
    public int getOperandPosition() {
80
        return right.getPositionBegin();
1✔
81
    }
82

83
    @Override
84
    public List<Object> propertyChain() {
85
        return new ArrayList<Object>() {{
1✔
86
            addAll(left.propertyChain());
1✔
87
            addAll(right.propertyChain());
1✔
88
        }};
1✔
89
    }
90

91
    @Override
92
    public Stream<Object> collectFields(Data data) {
93
        if (((DALExpression) left()).right() instanceof PropertyThis)
1✔
94
            if (right() instanceof ObjectScopeNode)
1✔
95
                return right().collectFields(data);
1✔
96
        return super.collectFields(data);
1✔
97
    }
98

99
    @Override
100
    public Data getValue(Data data, DALRuntimeContext context) {
101
        return context.pushAndExecute(data, () -> evaluateData(context));
1✔
102
    }
103

104
    @Override
105
    public int getPositionBegin() {
106
        if (left == null || left instanceof InputNode) return super.getPositionBegin();
1✔
107
        return Math.min(super.getPositionBegin(), left.getPositionBegin());
1✔
108
    }
109

110
    @Override
111
    public RowType guessTableHeaderType() {
112
        if (left() instanceof InputNode && right() instanceof DataRemarkNode)
1✔
113
            return RowHeader.DEFAULT_INDEX;
×
114
        return RowHeader.SPECIFY_PROPERTY;
1✔
115
    }
116

117
    @Override
118
    public boolean needPostBlankWarningCheck() {
119
        return true;
1✔
120
    }
121
}
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