mirror of
https://gitee.com/BDWare/cp.git
synced 2025-01-09 17:34:08 +00:00
add DO operation and multiple functions mapping relations
This commit is contained in:
parent
d040028463
commit
18b01e3ab0
@ -63,7 +63,9 @@ public class DebugMain {
|
||||
= new ResultCallback() {
|
||||
@Override
|
||||
public void onResult(String str) {
|
||||
|
||||
if(str.contains("Error")) {
|
||||
LOGGER.error("Some error happens: " + str);
|
||||
}
|
||||
LOGGER.info("[PrintCB] " + str);
|
||||
}
|
||||
};
|
||||
|
@ -10,7 +10,7 @@ public abstract class AnnotationProcessor {
|
||||
}
|
||||
|
||||
public void processFunction(
|
||||
AnnotationNode anno, ContractNode contractNode, FunctionNode functionNode) {
|
||||
AnnotationNode anno, ContractNode contractNode, FunctionNode functionNode) throws Exception {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ public class YJSCompiler {
|
||||
return czb;
|
||||
}
|
||||
|
||||
public ContractNode compile(InputStream input, String fileName) throws IOException {
|
||||
public ContractNode compile(InputStream input, String fileName) throws Exception {
|
||||
// 词法分析
|
||||
JavaScriptLexer lexer = new JavaScriptLexer(new ANTLRInputStream(input));
|
||||
lexer.setUseStrictDefault(true);
|
||||
@ -208,7 +208,7 @@ public class YJSCompiler {
|
||||
return contract;
|
||||
}
|
||||
|
||||
private void handleAnnotation(ContractNode contractNode) {
|
||||
private void handleAnnotation(ContractNode contractNode) throws Exception {
|
||||
for (AnnotationNode node : contract.annotations) {
|
||||
AnnotationProcessor processor = findProcessor(node);
|
||||
if (processor != null) {
|
||||
|
@ -13,7 +13,7 @@ import org.bdware.sc.node.FunctionNode;
|
||||
// DOOP is designed for DoipModule which contains specific functions for RepositoryHandler
|
||||
public class DOOP extends AnnotationProcessor {
|
||||
@Override
|
||||
public void processFunction(AnnotationNode anno, ContractNode contractNode, FunctionNode functionNode) {
|
||||
public void processFunction(AnnotationNode anno, ContractNode contractNode, FunctionNode functionNode) throws Exception {
|
||||
// 通过DOOP注解,解析对应的值,并放进对应的FunctionNode中
|
||||
// 注解必须暴露出来昂!!!
|
||||
functionNode.setIsExport(true);
|
||||
|
@ -16,7 +16,6 @@ import org.bdware.sc.bean.ContractRequest;
|
||||
import org.bdware.sc.boundry.JavaScriptEntry;
|
||||
import org.bdware.sc.entity.DoipMessagePacker;
|
||||
import org.bdware.sc.node.FunctionNode;
|
||||
import org.bdware.sc.util.JsonUtil;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -41,8 +40,12 @@ public class DOOPRequestHandler implements DoipRequestHandler, RepositoryHandler
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void addDoipOperation(FunctionNode function) {
|
||||
doipFunctionNodeMap.put(function.getDoipOperationInfo().operationName, function);
|
||||
public void addDoipOperation(FunctionNode function) throws Exception {
|
||||
String operationName = function.getDoipOperationInfo().operationName;
|
||||
if (doipFunctionNodeMap.containsKey(operationName)) {
|
||||
throw new Exception("Contract is wrong: One DO operation maps multiple functions");
|
||||
}
|
||||
doipFunctionNodeMap.put(operationName, function);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -67,7 +67,7 @@ public class YJSParserTest {
|
||||
ContractNode cn = compiler.compile(resource, "rrr.yjs");
|
||||
new DesktopEngine();
|
||||
System.out.println(new Gson().toJson(cn));
|
||||
} catch (IOException e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user