alibaba / alibaba/QLExpress

QLExpress4支持返回运行时覆盖情况

Open
#384 0 comments 0 reactions 0 assignees View on GitHub
help wanted
Dominant language
Java
Stars
5.6k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

# 需求描述

在一段脚本执行后,给应用返回语法树节点是否被执行的信息。相比 #373,支持面的更加广(比如可以支持循环),但是不会包含具体的计算结果 value

# 实现思路

因为分支覆盖信息统计会产生性能损耗,所以默认不进行统计。需要用户主动打开 `traceEvaluated` 选项后才会在 `QLResult` 中返回覆盖信息。

覆盖信息以 `EvaluatedTrace` 对象的形式返回,一个 `EvaluatedTrace` 对象代表一个计算节点:

```java
public class EvaluatedTrace {
private TraceType type;
private String token;
private Object value;
private boolean evaluated;
private List children;
}
```

案例1,无短路运算场景:

```java
if (a>3) {
sum = 0
for (i:[1,2,3]) {
sum += i
}
sum
} else {
100
}
```

则返回的 `EvaluatedTrace` 对象如下(假设上下文传入的a为4):

![](https://github.com/user-attachments/assets/58d88c4e-c63f-4bd8-9e3a-d5d0ff616faa)

即下钻每一个 Block(代码块) 的结构,每一行作为 children 中的一个元素,并且整体标记该 block 是否执行过。

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the QLResult execution path and the traceEvaluated option, then inspect how syntax-tree nodes and TraceType are represented. Use the EvaluatedTrace structure in the issue as the reference for nested children and evaluated state. Done means enabled execution returns coverage traces without concrete value results, while the default path avoids collecting them.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.