forked from Adrninistrator/java-callgraph2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Adrninistrator
authored and
Adrninistrator
committed
Aug 28, 2022
1 parent
1c3184c
commit dc6ac48
Showing
28 changed files
with
348 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/main/java/com/adrninistrator/javacg/common/ClassNameConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.adrninistrator.javacg.common; | ||
|
||
import java.util.concurrent.Callable; | ||
|
||
/** | ||
* @author adrninistrator | ||
* @date 2022/5/14 | ||
* @description: | ||
*/ | ||
public class ClassNameConstants { | ||
|
||
public static final String CLASS_NAME_RUNNABLE = Runnable.class.getName(); | ||
public static final String CLASS_NAME_CALLABLE = Callable.class.getName(); | ||
public static final String CLASS_NAME_THREAD = Thread.class.getName(); | ||
public static final String CLASS_NAME_OBJECT = Object.class.getName(); | ||
public static final String CLASS_NAME_STRING = String.class.getName(); | ||
public static final String CLASS_NAME_CLASS = Class.class.getName(); | ||
public static final String CLASS_NAME_NULL_POINTER_EXCEPTION = NullPointerException.class.getName(); | ||
|
||
private ClassNameConstants() { | ||
throw new IllegalStateException("illegal"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 0 additions & 32 deletions
32
src/main/java/com/adrninistrator/javacg/dto/ChildrenClassInfo.java
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
.../javacg/dto/ClassInterfaceMethodInfo.java → ...dto/classes/ClassInterfaceMethodInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.adrninistrator.javacg.dto; | ||
package com.adrninistrator.javacg.dto.classes; | ||
|
||
import java.util.List; | ||
|
||
|
4 changes: 3 additions & 1 deletion
4
...or/javacg/dto/ExtendsClassMethodInfo.java → ...g/dto/classes/ExtendsClassMethodInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ninistrator/javacg/dto/CallIdCounter.java → ...tor/javacg/dto/counter/CallIdCounter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...om/adrninistrator/javacg/dto/JarInfo.java → ...drninistrator/javacg/dto/jar/JarInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.adrninistrator.javacg.dto; | ||
package com.adrninistrator.javacg.dto.jar; | ||
|
||
/** | ||
* @author adrninistrator | ||
|
2 changes: 1 addition & 1 deletion
2
...nistrator/javacg/dto/MethodAttribute.java → ...or/javacg/dto/method/MethodAttribute.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ninistrator/javacg/dto/MethodCallDto.java → ...ator/javacg/dto/method/MethodCallDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...adrninistrator/javacg/dto/MethodInfo.java → ...strator/javacg/dto/method/MethodInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ator/javacg/dto/MethodLineNumberInfo.java → ...vacg/dto/method/MethodLineNumberInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...avacg/dto/TmpNode4ExtendsClassMethod.java → .../dto/node/TmpNode4ExtendsClassMethod.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.adrninistrator.javacg.dto; | ||
package com.adrninistrator.javacg.dto.node; | ||
|
||
/** | ||
* @author adrninistrator | ||
|
13 changes: 13 additions & 0 deletions
13
...trator/javacg/extensions/annotation_attributes/AnnotationAttributesFormatorInterface.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.adrninistrator.javacg.extensions.annotation_attributes; | ||
|
||
import org.apache.bcel.classfile.ElementValuePair; | ||
|
||
/** | ||
* @author adrninistrator | ||
* @date 2022/8/28 | ||
* @description: 对注解属性的元素值进行格式化的接口 | ||
*/ | ||
public interface AnnotationAttributesFormatorInterface { | ||
|
||
String format(ElementValuePair elementValuePair); | ||
} |
64 changes: 64 additions & 0 deletions
64
...m/adrninistrator/javacg/extensions/annotation_attributes/AnnotationAttributesHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.adrninistrator.javacg.extensions.annotation_attributes; | ||
|
||
import com.adrninistrator.javacg.common.JavaCGConstants; | ||
import org.apache.bcel.classfile.AnnotationEntry; | ||
import org.apache.bcel.classfile.ElementValuePair; | ||
import org.apache.bcel.classfile.Utility; | ||
|
||
import java.io.Writer; | ||
|
||
/** | ||
* @author adrninistrator | ||
* @date 2022/8/28 | ||
* @description: 对注解属性值进行处理的类 | ||
*/ | ||
public class AnnotationAttributesHandler { | ||
|
||
/** | ||
* 将注解信息写入文件 | ||
* | ||
* @param type 当前注解对应的元素类型,类还是方法 | ||
* @param classOrMethod 类名或方法 | ||
* @param annotationEntries | ||
* @param writer | ||
*/ | ||
public static void writeAnnotationInfo(String type, | ||
String classOrMethod, | ||
AnnotationEntry[] annotationEntries, | ||
AnnotationAttributesFormatorInterface annotationAttributesFormator, | ||
Writer writer) { | ||
if (annotationEntries == null || annotationEntries.length == 0) { | ||
return; | ||
} | ||
|
||
try { | ||
StringBuilder stringBuilder = new StringBuilder(); | ||
for (AnnotationEntry annotationEntry : annotationEntries) { | ||
String annotationClassName = Utility.typeSignatureToString(annotationEntry.getAnnotationType(), false); | ||
// TODO 后面把空格改成\t | ||
String data = type + " " + classOrMethod + " " + annotationClassName; | ||
|
||
if (annotationEntry.getElementValuePairs() == null || annotationEntry.getElementValuePairs().length == 0) { | ||
// 注解属性为空 | ||
stringBuilder.append(data).append(JavaCGConstants.NEW_LINE); | ||
continue; | ||
} | ||
|
||
// 注解属性非空 | ||
for (ElementValuePair elementValuePair : annotationEntry.getElementValuePairs()) { | ||
String formattedValue = annotationAttributesFormator.format(elementValuePair); | ||
|
||
stringBuilder.append(data).append(" ").append(formattedValue).append(JavaCGConstants.NEW_LINE); | ||
} | ||
} | ||
|
||
writer.write(stringBuilder.toString()); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
private AnnotationAttributesHandler() { | ||
throw new IllegalStateException("illegal"); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...istrator/javacg/extensions/annotation_attributes/DefaultAnnotationAttributesFormator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.adrninistrator.javacg.extensions.annotation_attributes; | ||
|
||
import com.adrninistrator.javacg.common.JavaCGConstants; | ||
import org.apache.bcel.classfile.ElementValuePair; | ||
|
||
/** | ||
* @author adrninistrator | ||
* @date 2022/8/28 | ||
* @description: | ||
*/ | ||
public class DefaultAnnotationAttributesFormator implements AnnotationAttributesFormatorInterface { | ||
|
||
@Override | ||
public String format(ElementValuePair elementValuePair) { | ||
String key = elementValuePair.getNameString(); | ||
String value = elementValuePair.getValue().toString(); | ||
|
||
return encodeAnnotationValue(key + JavaCGConstants.FILE_COLUMN_SEPARATOR + value); | ||
} | ||
|
||
public static String encodeAnnotationValue(String value) { | ||
return value.replace('\r', JavaCGConstants.ANNOTATION_ATTRIBUTE_VALUE_REPLACE_CARRIAGE_RETURN) | ||
.replace('\n', JavaCGConstants.ANNOTATION_ATTRIBUTE_VALUE_REPLACE_LINE_FEED); | ||
} | ||
|
||
public static String decodeAnnotationValue(String value) { | ||
return value.replace(JavaCGConstants.ANNOTATION_ATTRIBUTE_VALUE_REPLACE_CARRIAGE_RETURN, '\r') | ||
.replace(JavaCGConstants.ANNOTATION_ATTRIBUTE_VALUE_REPLACE_LINE_FEED, '\n'); | ||
} | ||
} |
8 changes: 4 additions & 4 deletions
8
...main/java/com/adrninistrator/javacg/extensions/code_parser/CustomCodeParserInterface.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.