bug #I6TRT2 EL表达式里的//被过滤掉了

This commit is contained in:
everywhere.z
2023-04-09 19:11:42 +08:00
parent bee7e09362
commit d4bc6e261a
4 changed files with 11 additions and 3 deletions

View File

@@ -253,7 +253,7 @@ public class ParserHelper {
private static class RegexUtil {
// java 注释的正则表达式
private static final String REGEX_COMMENT = "/\\*((?!\\*/).|[\\r\\n])*?\\*/|[ \\t]*//.*";
private static final String REGEX_COMMENT = "(?<!:)\\/\\/.*|\\/\\*(\\s|.)*?\\*\\/";
/**
* 移除 el 表达式中的注释,支持 java 的注释,包括单行注释、多行注释, 会压缩字符串,移除空格和换行符

View File

@@ -3,6 +3,7 @@ package com.yomahub.liteflow.test.comments;
import cn.hutool.core.collection.ListUtil;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.slot.DefaultContext;
import com.yomahub.liteflow.test.BaseTest;
import org.junit.Assert;
import org.junit.Test;
@@ -27,10 +28,13 @@ public class LiteflowNodeELSpringbootTest extends BaseTest {
// 测试注释
@Test
public void testAsyncFlow1() {
public void testComments1() {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a base request");
DefaultContext context = response.getFirstContextBean();
String str = context.getData("str");
Assert.assertTrue(response.isSuccess());
Assert.assertTrue(ListUtil.toList("a==>b==>c==>b", "a==>b==>b==>c").contains(response.getExecuteStepStr()));
Assert.assertEquals("https://liteflow.yomahub.com", str);
}
}

View File

@@ -10,6 +10,7 @@ package com.yomahub.liteflow.test.comments.cmp;
import com.yomahub.liteflow.annotation.LiteflowMethod;
import com.yomahub.liteflow.core.NodeComponent;
import com.yomahub.liteflow.enums.LiteFlowMethodEnum;
import com.yomahub.liteflow.slot.DefaultContext;
import org.springframework.stereotype.Component;
@Component("a")
@@ -17,6 +18,8 @@ public class ACmp {
@LiteflowMethod(LiteFlowMethodEnum.PROCESS)
public void process(NodeComponent bindCmp) {
DefaultContext context = bindCmp.getFirstContextBean();
context.setData("str", bindCmp.getCmpData(String.class));
System.out.println("ACmp executed!");
}

View File

@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<flow>
<chain name="chain1">
str = "https://liteflow.yomahub.com";
// 单行注释
THEN(
// 单行注释
a,
a.data(str),
b,
WHEN(
/**