我不知道如何获得正确的密钥?
IMethodBinding iMethodBinding = methodInvocation.resolveMethodBinding();
if (iMethodBinding != null) {
if (iMethodBinding.getDeclaringClass() != null) {
methodCallExpression
.setIncludeUnitSource(extractJavaFile(iMethodBinding
.getDeclaringClass()));
if (iMethodBinding.getKey() != null) {
org.eclipse.jdt.core.dom.CompilationUnit cu = null;
if (((CompilationUnit) methodInvocation.getRoot())
.findDeclaringNode(iMethodBinding) != null) {
cu = (CompilationUnit) methodInvocation.getRoot();
} else {
cu = resolveCompilationUnit(iMethodBinding);
}
ASTNode astNode = null;
if(iMethodBinding.getKey()
iMethodBinding.getKey()
: Ljava / util / Arrays; .asList([TT;)Ljava / util / List;%
操作系统: Windows 8
这是我的临时解决方案,但不适用于所有情况:
MethodBinding.getKey()
.indexOf("\\")!=-1){
astNode =(ASTNode) cu
.findDeclaringNode(iMethodBinding
.getKey()
.replace(
iMethodBinding.getKey().substring(
iMethodBinding.getKey()
.indexOf("\\") - 2,
iMethodBinding.getKey()
.indexOf("~")), "")
.replace("~", ""));