我目前正在为 Eclipse 开发一个插件,用于分析工作区中 Java 和插件项目的依赖关系和引用。
但是,我终其一生都无法找到一种方法来获取在 Classpath Entries 中找到的引用项目或库的名称。
这是我所拥有的(摘自更长的方法):
IJavaProject j= JavaCore.create(project); //project is an IProject
try {
IClasspathEntry[] classpath= j.getRawClasspath();
// Get required Libraries and Projects
for (IClasspathEntry entry : classpath) {
switch (entry.getEntryKind()) {
case IClasspathEntry.CPE_LIBRARY: {
//Retrieve name of the Library
break;
}
case IClasspathEntry.CPE_PROJECT: {
//Retrieve name of the Project
break;
}
}
} catch [...]
有谁知道如何在标记位置获取名称,或者有更好的方法来检索它们?