[英]Can anyone tell me why the use of pop() in my evaulateExpression is not working?
[英]Can Anyone tell me why my IFile always returns null?
我有一个插件。 在这个插件中,我有一个创建一些标记的视图,以便我可以打开文件并自动导航到选定的行。 但是,这种方法以前对我有用。 它现在停止了吗? 它只返回 null 作为我的 IFile。
这是我创建标记的方法注意:此方法不在 FXML 文件的控制 class 内。 它位于另一个外部文件中。
public static String openAbsoluteFileInEclipseEditor(String absoluteLocationP, int lineNumberP) {
File absolute = new File(absoluteLocationP);
if(absolute.isFile() && absolute.exists()) {
if(Globals.testing) {
try {
Desktop.getDesktop().open(absolute);
return null;
} catch (IOException e) {
ErrorHandling.reportErrors(e);
return "";
}
}else {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchPage page = window.getActivePage();
IWorkspace workspace = ResourcesPlugin.getWorkspace();
try {
if(lineNumberP != 0) {
IPath location = Path.fromOSString(absolute.getAbsolutePath());
System.out.println("location " + location);
IFile iFile = workspace.getRoot().getFileForLocation(location);
System.out.println("iFile " + iFile);
IMarker marker = iFile.createMarker(IMarker.TEXT);
marker.setAttribute(IMarker.LINE_NUMBER, lineNumberP);
IDE.openEditor(page, marker);
marker.delete();
}else {
IFileStore fileStore = EFS.getLocalFileSystem().getStore(absolute.toURI());
IDE.openEditorOnFileStore( page, fileStore );
}
return null;
} catch (PartInitException e) {
ErrorHandling.reportErrors(e);
return "";
} catch (CoreException e) {
ErrorHandling.reportErrors(e);
return "";
}
}
}else {
return "File not found";
}
}
这是您可以在方法中间看到的两个打印值。
位置 C:/SoftwareAG_Workspaces/workspace105/HOSPITAL/Natural-Libraries/HOSPITAL/Programs/XX021P01.NSP iFile null
谁能向我指出为什么它可能不再起作用以及为什么它只返回空值? 如果可能的话,您能否建议一种可行的替代方法? 该文件确实存在于我确定的那个位置。
提前致谢。
getFileForLocation
的 Javadoc 说:
当给定的文件系统位置不在工作区中任何现有项目的位置下时,此方法返回 null。
那么该位置是否在当前工作空间中以及在有效项目中?
Javadoc 还说:
结果还将省略根据现有资源过滤器从工作区中明确排除的资源。
所以检查任何资源过滤器。
最后,Javadoc 说:
警告:此方法忽略链接资源及其子资源。 由于链接资源可能与其他资源重叠,因此无法保证从文件系统位置到单个资源的唯一映射。 要查找给定位置的所有资源,包括链接资源,请使用方法
findFilesForLocation
。
所以检查链接资源
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.