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

leeonky / test-charm-java / 114

09 Feb 2025 05:45PM UTC coverage: 73.251% (-0.1%) from 73.358%
114

push

circleci

leeonky
Refactor

0 of 70 new or added lines in 3 files covered. (0.0%)

15 existing lines in 7 files now uncovered.

7665 of 10464 relevant lines covered (73.25%)

0.73 hits per line

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

90.7
/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.AssertionFailure;
7
import com.github.leeonky.dal.runtime.Data;
8
import com.github.leeonky.dal.runtime.ExpressionException;
9
import com.github.leeonky.dal.runtime.RuntimeContextBuilder.DALRuntimeContext;
10
import com.github.leeonky.dal.runtime.RuntimeException;
11
import com.github.leeonky.interpreter.Expression;
12
import com.github.leeonky.interpreter.InterpreterException;
13
import com.github.leeonky.util.InvocationException;
14

15
import java.util.ArrayList;
16
import java.util.List;
17
import java.util.stream.Stream;
18

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

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

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

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

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

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

55
    @Override
56
    public Data evaluateData(DALRuntimeContext context) {
57
        try {
58
            return operator.calculateData(this, context);
1✔
59
        } catch (InterpreterException e) {
1✔
60
            throw e;
1✔
61
        } catch (ExpressionException ex) {
1✔
62
            throw ex.rethrow(this);
1✔
63
        } catch (AssertionError error) {
1✔
64
            throw new AssertionFailure(error.getMessage(), right().getPositionBegin());
1✔
65
        } catch (Exception e) {
×
66
            throw new RuntimeException(e.getMessage(), operator().getPosition(), new InvocationException(e));
×
67
        }
68
    }
69

70
    @Override
71
    public String inspect() {
72
        return operator.inspect(left == null ? null : left.inspect(), right.inspect());
1✔
73
    }
74

75
    @Override
76
    public Object getRootSymbolName() {
77
        return left instanceof InputNode || isRootPropertyThis() ? right.getRootSymbolName() : left.getRootSymbolName();
1✔
78
    }
79

80
    private boolean isRootPropertyThis() {
81
        return left instanceof DALExpression && ((DALExpression) left).right() instanceof PropertyThis;
1✔
82
    }
83

84
    @Override
85
    public int getOperandPosition() {
86
        return right.getPositionBegin();
1✔
87
    }
88

89
    @Override
90
    public List<Object> propertyChain() {
91
        return new ArrayList<Object>() {{
1✔
92
            addAll(left.propertyChain());
1✔
93
            addAll(right.propertyChain());
1✔
94
        }};
1✔
95
    }
96

97
    @Override
98
    public Stream<Object> collectFields(Data data) {
99
        if (((DALExpression) left()).right() instanceof PropertyThis)
1✔
100
            if (right() instanceof ObjectScopeNode)
1✔
101
                return right().collectFields(data);
1✔
102
        return super.collectFields(data);
1✔
103
    }
104

105
    @Override
106
    public Data getValue(Data data, DALRuntimeContext context) {
107
        return context.pushAndExecute(data, () -> evaluateData(context));
1✔
108
    }
109

110
    @Override
111
    public int getPositionBegin() {
112
        if (left == null || left instanceof InputNode) return super.getPositionBegin();
1✔
113
        return Math.min(super.getPositionBegin(), left.getPositionBegin());
1✔
114
    }
115

116
    @Override
117
    public RowType guessTableHeaderType() {
118
        if (left() instanceof InputNode && right() instanceof DataRemarkNode)
1✔
119
            return RowHeader.DEFAULT_INDEX;
×
120
        return RowHeader.SPECIFY_PROPERTY;
1✔
121
    }
122

123
    @Override
124
    public boolean needPostBlankWarningCheck() {
125
        return true;
1✔
126
    }
127

128
    @Override
129
    public boolean isVerification() {
UNCOV
130
        return operator.isVerification();
×
131
    }
132
}
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