假设我能够访问c文件中的所有函数调用表达式,那么我需要获取该函数调用的函数定义节点,该函数定义可能在另一个C文件中,我尝试了下面的代码
@Override
protected int visit(IASTFunctionCallExpression functionCall) {
IASTExpression functionNameExp = functionCallExp.getFunctionNameExpression();
IASTName fn = ((IASTIdExpression) functionNameExp).getName() ;
IBinding binding = fn.resolveBinding(); //binding is retrieved successfully
IName[] defs = ast.getDefinitions(binding);
for(IName def : definitions) {
//I want to get the function definition node in the other file
}
}
但是当我尝试在调试模式下评估“ defs”时,会提示错误
org.eclipse.debug.core.DebugException: com.sun.jdi.ClassNotLoadedException: Type has not been loaded occurred while retrieving component type of array.
有什么建议吗?
更新
我能够通过重建项目索引来克服此异常。
该函数返回的方法中的方法CHT#findNames中发生了问题: 返回result.toArray(new IIndexName [result.size()]); 虽然结果的大小为零,但通过该异常,我注意到这种返回样式在CIndex类中使用率很高