mirror of
https://gitee.com/BDWare/common
synced 2025-01-09 17:34:16 +00:00
refactor extract routerInfo and joinInfo
This commit is contained in:
parent
3fb7b5c7c2
commit
fdd5848989
@ -52,7 +52,7 @@ dependencies {
|
||||
}
|
||||
group = "org.bdware.sc"
|
||||
|
||||
version = "1.6.6"
|
||||
version = "1.6.7"
|
||||
|
||||
|
||||
tasks.processResources.setDuplicatesStrategy(DuplicatesStrategy.INCLUDE)
|
||||
|
@ -1,8 +1,12 @@
|
||||
package org.bdware.sc.node;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import org.antlr.v4.runtime.CommonTokenStream;
|
||||
import org.bdware.doip.codec.operations.BasicOperations;
|
||||
import org.bdware.sc.bean.DoipOperationInfo;
|
||||
import org.bdware.sc.bean.JoinInfo;
|
||||
import org.bdware.sc.bean.RouteInfo;
|
||||
import org.bdware.sc.event.REvent.REventSemantics;
|
||||
import org.bdware.sc.util.JsonUtil;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@ -182,6 +186,14 @@ public class ContractNode {
|
||||
return yjsType;
|
||||
}
|
||||
|
||||
public boolean hasDoipModule() {
|
||||
if (functions != null)
|
||||
for (FunctionNode node : functions) {
|
||||
if (node.getDoipOperationInfo() != null) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setYjsType(YjsType yjsType1) {
|
||||
this.yjsType = yjsType1;
|
||||
}
|
||||
@ -197,4 +209,36 @@ public class ContractNode {
|
||||
public void resetContractName(String name) {
|
||||
contractName = name;
|
||||
}
|
||||
|
||||
public void maintainRouteJoinInfo(JsonObject methodRouteInfoMap, JsonObject methodJoinInfoMap, JsonObject dependentFunctions) {
|
||||
// all functions存了ContractNode中,所有的FunctionNode
|
||||
List<FunctionNode> allFunctions = getFunctions();
|
||||
for (FunctionNode functionNode : allFunctions) {
|
||||
AnnotationNode doopAnnotation = functionNode.getAnnotation("DOOP");
|
||||
DoipOperationInfo doipOperationInfo = functionNode.getDoipOperationInfo();
|
||||
if (doopAnnotation != null && doipOperationInfo != null) {
|
||||
RouteInfo routeInfo = functionNode.getRouteInfo();
|
||||
JoinInfo joinInfo = functionNode.getJoinInfo();
|
||||
if (routeInfo != null) {
|
||||
packSourceFunctionAndDependentFunctions(getFunction(routeInfo.funcName), dependentFunctions);
|
||||
methodRouteInfoMap.add(doipOperationInfo.operationName, JsonUtil.parseObjectAsJsonObject(routeInfo));
|
||||
}
|
||||
if (joinInfo != null) {
|
||||
packSourceFunctionAndDependentFunctions(getFunction(joinInfo.joinCountFuncName), dependentFunctions);
|
||||
packSourceFunctionAndDependentFunctions(getFunction(joinInfo.joinFuncName), dependentFunctions);
|
||||
methodJoinInfoMap.add(doipOperationInfo.operationName, JsonUtil.parseObjectAsJsonObject(joinInfo));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void packSourceFunctionAndDependentFunctions(FunctionNode sourceFunctionNode, JsonObject functions) {
|
||||
if (sourceFunctionNode == null) return;
|
||||
functions.addProperty(sourceFunctionNode.functionName, sourceFunctionNode.plainText());
|
||||
// find all dependent functions to the "functions" struct
|
||||
for (String dependentFunctionName : sourceFunctionNode.getDependentFunctions()) {
|
||||
FunctionNode dependentFunctionNode = getFunction(dependentFunctionName);
|
||||
functions.addProperty(dependentFunctionName, dependentFunctionNode.plainText());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -295,4 +295,11 @@ public class FunctionNode extends Script {
|
||||
public void setFunctionName(String functionName) {
|
||||
this.functionName = functionName;
|
||||
}
|
||||
|
||||
public AnnotationNode getAnnotation(String annotationName) {
|
||||
for (AnnotationNode node : annotations)
|
||||
if (node.getType() != null && node.getType().equals(annotationName))
|
||||
return node;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user