mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-15 04:22:09 +08:00
加入格式化代码插件,并提交格式化后的代码
This commit is contained in:
@@ -11,30 +11,33 @@ import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Lua脚本语言的执行器实现
|
||||
*
|
||||
* @author Bryan.Zhang
|
||||
* @since 2.9.5
|
||||
*/
|
||||
public class LuaScriptExecutor extends JSR223ScriptExecutor {
|
||||
@Override
|
||||
public ScriptTypeEnum scriptType() {
|
||||
return ScriptTypeEnum.LUA;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String convertScript(String script) {
|
||||
String[] lineArray = script.split("\\n");
|
||||
List<String> noBlankLineList = Arrays.stream(lineArray).filter(
|
||||
s -> !StrUtil.isBlank(s)
|
||||
).collect(Collectors.toList());
|
||||
@Override
|
||||
public ScriptTypeEnum scriptType() {
|
||||
return ScriptTypeEnum.LUA;
|
||||
}
|
||||
|
||||
//用第一行的缩进的空格数作为整个代码的缩进量
|
||||
String blankStr = ReUtil.getGroup0("^[ ]*", noBlankLineList.get(0));
|
||||
@Override
|
||||
protected String convertScript(String script) {
|
||||
String[] lineArray = script.split("\\n");
|
||||
List<String> noBlankLineList = Arrays.stream(lineArray)
|
||||
.filter(s -> !StrUtil.isBlank(s))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 用第一行的缩进的空格数作为整个代码的缩进量
|
||||
String blankStr = ReUtil.getGroup0("^[ ]*", noBlankLineList.get(0));
|
||||
|
||||
// 重新构建脚本
|
||||
StringBuilder scriptSB = new StringBuilder();
|
||||
noBlankLineList.forEach(s -> scriptSB.append(StrUtil.format("{}\n", s.replaceFirst(blankStr, StrUtil.EMPTY))));
|
||||
return scriptSB.toString();
|
||||
// return StrUtil.format("function
|
||||
// process()\n{}\nend\nprocess()\n",scriptSB.toString());
|
||||
}
|
||||
|
||||
//重新构建脚本
|
||||
StringBuilder scriptSB = new StringBuilder();
|
||||
noBlankLineList.forEach(s
|
||||
-> scriptSB.append(StrUtil.format("{}\n", s.replaceFirst(blankStr, StrUtil.EMPTY))));
|
||||
return scriptSB.toString();
|
||||
//return StrUtil.format("function process()\n{}\nend\nprocess()\n",scriptSB.toString());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user