如果有人使用 SPOON API,你能给我一些线索如何创建调用图以及我需要做什么吗?
我认为我需要像这样创建一些处理器:
public class InvocationProcessor extends AbstractProcessor<CtInvocation> {
@Override
public void process(CtInvocation element) {
System.out.println(element.getActualTypeArguments());
}
}
然后使用 Launcher 进行运行分析
public void getCallers(){
final Launcher launcher = new Launcher();
launcher.setArgs("-i D:\\IntelliJ_projects\\ComprehensionTool\\ -p comprehensionTool.analyse.processor.InvocationProcessor".split(" "));
launcher.run();
}
但我不确定......我想问一下我是否需要一些特殊的依赖项才能使用 Launcher?
我认为我错了,因为当我执行它时会抛出这个错误:
Exception in thread "main" java.lang.NoSuchMethodError: org.eclipse.jdt.internal.compiler.batch.Main.<init>(Ljava/io/PrintWriter;Ljava/io/PrintWriter;ZLjava/util/Map;Lorg/eclipse/jdt/core/compiler/CompilationProgress;)V
at spoon.support.compiler.jdt.JDTBatchCompiler.<init>(JDTBatchCompiler.java:58)
at spoon.support.compiler.jdt.JDTBatchCompiler.<init>(JDTBatchCompiler.java:54)
at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.createBatchCompiler(JDTBasedSpoonCompiler.java:352)
at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.createBatchCompiler(JDTBasedSpoonCompiler.java:356)
at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.buildUnits(JDTBasedSpoonCompiler.java:388)
at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.buildUnitsAndModel(JDTBasedSpoonCompiler.java:372)
at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.buildSources(JDTBasedSpoonCompiler.java:348)
at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.build(JDTBasedSpoonCompiler.java:119)
at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.build(JDTBasedSpoonCompiler.java:102)
at spoon.Launcher.buildModel(Launcher.java:700)
at spoon.Launcher.run(Launcher.java:651)