Skip to content

Commit

Permalink
feat: Support for multiple-level interface inheritance in RPC.
Browse files Browse the repository at this point in the history
  • Loading branch information
shalousun committed Mar 26, 2024
1 parent 1ca056e commit aeb764e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
13 changes: 13 additions & 0 deletions src/main/java/com/ly/doc/template/IRpcDocTemplate.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,19 @@ default List<RpcJavaMethod> getParentsClassMethods(ApiConfig apiConfig, JavaClas
return docJavaMethods;
}

default List<RpcJavaMethod> getInterfaceMethods(ApiConfig apiConfig, JavaClass cls) {
List<RpcJavaMethod> docJavaMethods = new ArrayList<>();
for (JavaClass javaInterface : cls.getInterfaces()) {
Map<String, JavaType> actualTypesMap = JavaClassUtil.getActualTypesMap(javaInterface);
List<JavaMethod> interfaceMethodList = javaInterface.getMethods();
for (JavaMethod method : interfaceMethodList) {
docJavaMethods.add(convertToRpcJavaMethod(apiConfig, method, actualTypesMap));
}
docJavaMethods.addAll(getInterfaceMethods(apiConfig, javaInterface));
}
return docJavaMethods;
}

default String replaceTypeName(String type, Map<String, JavaType> actualTypesMap, boolean simple) {
if (Objects.isNull(actualTypesMap)) {
return type;
Expand Down
11 changes: 1 addition & 10 deletions src/main/java/com/ly/doc/template/RpcDocBuildTemplate.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,7 @@ private List<RpcJavaMethod> buildServiceMethod(final JavaClass cls, ApiConfig ap
// add parent class methods
methodDocList.addAll(getParentsClassMethods(apiConfig, cls));
if (cls.isInterface() || cls.isAbstract()) {
List<JavaType> implClasses = cls.getImplements();
for (JavaType type : implClasses) {
JavaClass javaClass = (JavaClass) type;
Map<String, JavaType> actualTypesMap = JavaClassUtil.getActualTypesMap(javaClass);
for (JavaMethod method : javaClass.getMethods()) {
if (!method.isDefault()) {
methodDocList.add(convertToRpcJavaMethod(apiConfig, method, actualTypesMap));
}
}
}
methodDocList.addAll(getInterfaceMethods(apiConfig,cls));
}

int methodOrder = 0;
Expand Down

0 comments on commit aeb764e

Please sign in to comment.