Skip to content

Commit d012105

Browse files
committed
re
1 parent 78fbaac commit d012105

File tree

5 files changed

+38
-13
lines changed

5 files changed

+38
-13
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package cn.com.mirror.exceptions;
2+
3+
/**
4+
* @author piggy
5+
* @description
6+
* @date 18-8-24
7+
*/
8+
public class EdgeTouchException extends RuntimeException {
9+
private static final long serialVersionUID = 1L;
10+
11+
12+
public EdgeTouchException(String message) {
13+
super(message);
14+
}
15+
16+
public EdgeTouchException(String message, Throwable cause) {
17+
super(message, cause);
18+
}
19+
}

mirror-common/src/main/java/cn/com/mirror/exceptions/GenerateNodeException.java renamed to mirror-common/src/main/java/cn/com/mirror/exceptions/NodeGenerateException.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
* @description
66
* @date 18-8-23
77
*/
8-
public class GenerateNodeException extends RuntimeException {
8+
public class NodeGenerateException extends RuntimeException {
99
private static final long serialVersionUID = 1L;
1010

11-
public GenerateNodeException(String message) {
11+
public NodeGenerateException(String message) {
1212
super(message);
1313
}
1414

15-
public GenerateNodeException(String message, Throwable cause) {
15+
public NodeGenerateException(String message, Throwable cause) {
1616
super(message, cause);
1717
}
1818
}

mirror-common/src/main/java/cn/com/mirror/exceptions/GenerateVertexException.java renamed to mirror-common/src/main/java/cn/com/mirror/exceptions/VertexGenerateException.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
* @description
66
* @date 18-8-24
77
*/
8-
public class GenerateVertexException extends RuntimeException {
8+
public class VertexGenerateException extends RuntimeException {
99
private static final long serialVersionUID = 1L;
1010

11-
public GenerateVertexException(String message) {
11+
public VertexGenerateException(String message) {
1212
super(message);
1313
}
1414

15-
public GenerateVertexException(String message, Throwable cause) {
15+
public VertexGenerateException(String message, Throwable cause) {
1616
super(message, cause);
1717
}
1818
}

mirror-common/src/main/java/cn/com/mirror/project/pair/factory/VertexFactory.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package cn.com.mirror.project.pair.factory;
22

33
import cn.com.mirror.constant.VertexTypeEnum;
4-
import cn.com.mirror.exceptions.GenerateVertexException;
4+
import cn.com.mirror.exceptions.VertexGenerateException;
55
import cn.com.mirror.project.pair.Vertex;
66
import lombok.Data;
77
import org.eclipse.jdt.core.dom.ASTNode;
@@ -52,11 +52,11 @@ public Vertex genVertex(String targetPath, int curLine, ASTNode node) {
5252

5353
public Vertex genVertex(String targetPath, int curLine, ASTNode node, String ip, int port) {
5454
if (null != ip && -1 == port) {
55-
throw new GenerateVertexException("Port can not be -1.");
55+
throw new VertexGenerateException("Port can not be -1.");
5656
}
5757

5858
if (-1 != port && null == ip) {
59-
throw new GenerateVertexException("IP address can not be null");
59+
throw new VertexGenerateException("IP address can not be null");
6060
}
6161

6262
String hostKey = getHostKey(ip, port, targetPath, curLine);

mirror-common/src/main/java/cn/com/mirror/reflect/EdgeConstructor.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import cn.com.mirror.analyser.PairAnalyser;
44
import cn.com.mirror.analyser.UnitAnalyser;
5+
import cn.com.mirror.exceptions.EdgeTouchException;
56
import cn.com.mirror.exceptions.ReflectException;
67
import cn.com.mirror.project.pair.Pair;
78
import cn.com.mirror.project.pair.Vertex;
@@ -55,13 +56,18 @@ public void construct() {
5556

5657
// basic control edges in the target file
5758
ctrlEdge.forEach((ctrlKey, ctrlVal) -> {
58-
log.debug("TARGET: {}", targetPath);
59-
log.debug("FROM: {}:{} \t->\t TO: {}:{}", ctrlKey.getLineNum(),
60-
ctrlKey.getVertexType(), ctrlVal.getLineNum(), ctrlVal.getVertexType());
61-
6259
Base headB = getBaseElement(ctrlKey);
6360
Base tailB = getBaseElement(ctrlVal);
6461

62+
if (null == headB || null == tailB) {
63+
log.debug("TARGET: {}", targetPath);
64+
log.debug("HEAD: {}:{} \t->\t TAIL: {}:{}", ctrlKey.getLineNum(),
65+
ctrlKey.getVertexType(), ctrlVal.getLineNum(), ctrlVal.getVertexType());
66+
67+
throw new EdgeTouchException("Head statement or tail statement is null! \tHEAD: {"
68+
+ headB + "} -> TAIL: {" + tailB + "}");
69+
}
70+
6571
// TODO xyz generate start and end node for this target and write it into the graph db.
6672
BaseNode newGraphNodeTail = touch(headB, tailB);
6773
graphEngine.write(newGraphNodeTail);

0 commit comments

Comments
 (0)