Skip to content

Commit

Permalink
业务入口层用红色突出显示
Browse files Browse the repository at this point in the history
  • Loading branch information
gaopeng71 committed Sep 4, 2023
1 parent 488aa7c commit ae714f2
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ void ignoreCaller() throws FileNotFoundException {
CallGraphEntry entry = new CallGraphEntry(config, "io.git.dddplus.jdbc.FooDao", "query", "io.git.dddplus.jdbc.impl.Bar", "bar");
assertTrue(config.ignoreCaller(m));
assertTrue(config.ignoreInvokeInstruction(m, null, entry));
assertTrue(config.isUseCaseLayerClass("org.git.dddplus.FooAppServiceImpl"));
assertFalse(config.isUseCaseLayerClass("FooListener"));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private CallGraphRenderer setupSkin() {
append(TAB).append(String.format("splines = %s;", splines)).append(NEWLINE);
}
append(TAB).append("node [shape=Mrecord];").append(NEWLINE);
append(TAB).append(String.format("nodesep=%.1f;", callGraphReport.getConfig().getNodesep())).appendEscape(NEWLINE);
append(TAB).append(String.format("nodesep=%.1f;", callGraphReport.getConfig().getNodesep())).append(NEWLINE);
append(TAB).append("edge [style = dashed, arrowsize=0.4, fontsize=6];").append(NEWLINE);
append(NEWLINE);
return this;
Expand Down Expand Up @@ -134,7 +134,11 @@ private CallGraphRenderer renderNodes() {
list.add(String.format("<%s> %s", method, method));
}
append(String.join("|", list));
append("\"];").append(NEWLINE);
append("\"").append(NEWLINE);
if (callGraphReport.getConfig().isUseCaseLayerClass(clazz)) {
append(" color=red");
}
append("];").append(NEWLINE);
}

return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,41 @@ public class CallGraphConfig implements Serializable {
private Ignore ignore;
private Accept accept;
private Boolean simpleClassName = false;
private Double nodesep = 1.5;
private Double nodesep = 0.25;

private List<String> useCaseLayerClasses = new ArrayList<>();
private transient List<PathMatcher> useCaseLayerClassPatterns;

public static CallGraphConfig fromFile(String filename) throws FileNotFoundException {
Gson gson = new Gson();
JsonReader reader = new JsonReader(new FileReader(filename));
CallGraphConfig config = gson.fromJson(reader, CallGraphConfig.class);
config.ignore.initialize();
config.initialize();
return config;
}

private void initialize() {
useCaseLayerClassPatterns = new ArrayList<>(useCaseLayerClasses.size());
for (String regex : useCaseLayerClasses) {
useCaseLayerClassPatterns.add(FileSystems.getDefault().getPathMatcher("glob:" + regex));
}

ignore.initialize();
}

public boolean useSimpleClassName() {
return simpleClassName;
}

public boolean isUseCaseLayerClass(String className) {
for (PathMatcher matcher : useCaseLayerClassPatterns) {
if (matcher.matches(Paths.get(className))) {
return true;
}
}
return false;
}

private boolean builtinIgnoreCaller(MethodVisitor m) {
// caller method
if (m.callerMethod.contains("$") || m.callerClass.contains("$")) {
Expand Down
3 changes: 3 additions & 0 deletions doc/callgraph.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"simpleClassName": true,
"useCaseLayerClasses": [
"*AppService*"
],
"nodesep": 1.5,
"ignore":{
"enumClazz":true,
Expand Down

0 comments on commit ae714f2

Please sign in to comment.