diff --git a/src/main/debugger/org/bdware/sc/debugger/DebugMain.java b/src/main/debugger/org/bdware/sc/debugger/DebugMain.java index 8ce15f1..4a22409 100644 --- a/src/main/debugger/org/bdware/sc/debugger/DebugMain.java +++ b/src/main/debugger/org/bdware/sc/debugger/DebugMain.java @@ -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); } }; diff --git a/src/main/java/org/bdware/sc/compiler/AnnotationProcessor.java b/src/main/java/org/bdware/sc/compiler/AnnotationProcessor.java index f356f71..816b12a 100644 --- a/src/main/java/org/bdware/sc/compiler/AnnotationProcessor.java +++ b/src/main/java/org/bdware/sc/compiler/AnnotationProcessor.java @@ -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; } } diff --git a/src/main/java/org/bdware/sc/compiler/YJSCompiler.java b/src/main/java/org/bdware/sc/compiler/YJSCompiler.java index 11cd2c6..beb2517 100644 --- a/src/main/java/org/bdware/sc/compiler/YJSCompiler.java +++ b/src/main/java/org/bdware/sc/compiler/YJSCompiler.java @@ -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) { diff --git a/src/main/java/org/bdware/sc/compiler/ap/DOOP.java b/src/main/java/org/bdware/sc/compiler/ap/DOOP.java index 4697fa6..0e254b5 100644 --- a/src/main/java/org/bdware/sc/compiler/ap/DOOP.java +++ b/src/main/java/org/bdware/sc/compiler/ap/DOOP.java @@ -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); diff --git a/src/main/java/org/bdware/sc/handler/DOOPRequestHandler.java b/src/main/java/org/bdware/sc/handler/DOOPRequestHandler.java index 7ab064e..0ed220f 100644 --- a/src/main/java/org/bdware/sc/handler/DOOPRequestHandler.java +++ b/src/main/java/org/bdware/sc/handler/DOOPRequestHandler.java @@ -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 diff --git a/src/test/java/org/bdware/sc/parser/YJSParserTest.java b/src/test/java/org/bdware/sc/parser/YJSParserTest.java index 1f7ac9c..9e62db9 100644 --- a/src/test/java/org/bdware/sc/parser/YJSParserTest.java +++ b/src/test/java/org/bdware/sc/parser/YJSParserTest.java @@ -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(); } }