Pārlūkot izejas kodu

enhancement #IB1YLX 简化规则中的注释,化繁为简

everywhere.z 7 mēneši atpakaļ
vecāks
revīzija
38ed6fec0e

+ 0 - 2
liteflow-core/src/main/java/com/yomahub/liteflow/builder/el/LiteFlowChainELBuilder.java

@@ -263,8 +263,6 @@ public class LiteFlowChainELBuilder {
     public static ValidationResp validateWithEx(String elStr) {
         ValidationResp resp = new ValidationResp();
         try {
-            // 移除注释
-            elStr = ElRegexUtil.removeComments(elStr);
             LiteFlowChainELBuilder.createChain().setEL(elStr);
             resp.setSuccess(true);
         } catch (Exception e) {

+ 4 - 4
liteflow-core/src/main/java/com/yomahub/liteflow/parser/helper/ParserHelper.java

@@ -352,21 +352,21 @@ public class ParserHelper {
         // 如果有route这个标签,说明是决策表chain
         // 决策表链路必须有route和body这两个标签
         if (routeElement != null){
-            builder.setRoute(ElRegexUtil.removeComments(routeElement.getText()));
+            builder.setRoute(routeElement.getText());
 
             Element bodyElement = e.element(BODY);
             if (bodyElement == null){
                 String errMsg = StrUtil.format("If you have defined the tag <route>, then you must define the tag <body> in chain[{}]", chainId);
                 throw new FlowSystemException(errMsg);
             }
-            builder.setEL(ElRegexUtil.removeComments(bodyElement.getText()));
+            builder.setEL(bodyElement.getText());
         }else{
             // 即使没有route这个标签,body标签单独写也是被允许的
             Element bodyElement = e.element(BODY);
             if (bodyElement != null){
-                builder.setEL(ElRegexUtil.removeComments(bodyElement.getText()));
+                builder.setEL(bodyElement.getText());
             }else{
-                builder.setEL(ElRegexUtil.removeComments(e.getText()));
+                builder.setEL(e.getText());
             }
         }
 

+ 0 - 17
liteflow-core/src/main/java/com/yomahub/liteflow/util/ElRegexUtil.java

@@ -21,23 +21,6 @@ public class ElRegexUtil {
     // abstractChain 占位符正则表达式
     private static final String REGEX_ABSTRACT_HOLDER = "\\{\\{\\s*([a-zA-Z_][a-zA-Z_\\d]*|\\d+)\\s*\\}\\}(?![\\s]*=)";
 
-    /**
-     * 移除 el 表达式中的注释,支持 java 的注释,包括单行注释、多行注释, 会压缩字符串,移除空格和换行符
-     *
-     * @param elStr el 表达式
-     * @return 移除注释后的 el 表达式
-     */
-    public static String removeComments(String elStr) {
-        if (StrUtil.isBlank(elStr)) {
-            return elStr;
-        }
-
-        return Pattern.compile(REGEX_COMMENT)
-                .matcher(elStr)
-                // 移除注释
-                .replaceAll(CharSequenceUtil.EMPTY);
-    }
-
     /**
      * 根据抽象EL和实现EL,替换抽象EL中的占位符
      *

+ 1 - 1
pom.xml

@@ -39,7 +39,7 @@
 	</scm>
 
 	<properties>
-		<revision>2.12.4.1</revision>
+		<revision>2.12.4.2</revision>
 		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
 		<maven.compiler.source>8</maven.compiler.source>