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

leeonky / test-charm-java / 156

20 Mar 2025 01:53PM UTC coverage: 74.243% (-0.2%) from 74.475%
156

push

circleci

leeonky
Refactor

14 of 15 new or added lines in 12 files covered. (93.33%)

126 existing lines in 29 files now uncovered.

7947 of 10704 relevant lines covered (74.24%)

0.74 hits per line

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

97.3
/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
        return operator.calculateData(this, context).onError(e -> {
1✔
56
            if (e instanceof ExpressionException)
1✔
57
                return ((ExpressionException) e).rethrow(this);
1✔
58
            return locateError(e, right().getPositionBegin());
1✔
59
        });
60
    }
61

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

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

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

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

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

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

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

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

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

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