PyDev抛出异常"资源不存在"重新开放项目时

时间:2016-12-06 21:48:08

标签: python eclipse eclipse-rcp pydev

在我关闭并重新打开PyDev项目的RCP应用程序中,PyDev在控制台上抛出异常,抱怨项目资源不存在。一切似乎都在后续工作,但我当然希望避免向用户显示虚假的异常。

从导航堆栈跟踪中我可以看出,PyDev的内容提供商期望项目资源存在,但事实并非如此。当我检测到一个项目关闭时,我可能应该在PyDev中调用一些API吗?或者这是一个错误?我注意到版本5.1.2上的问题,但升级到最新版本(5.4.0)并没有解决它。

编辑:

我发现通过right-click on project -> Open Project打开项目不会抛出异常。仅在通过双击打开项目时。双击打开的项目不会导致问题,只需双击已关闭的项目。在框架有机会实际打开项目之前,似乎正在调用PyDev重新定位的操作(PyOpenPythonFileAction)。

EDIT2:

实际上它比那更奇怪。抛出异常的重定向操作是PyOpenResourceAction(但它是失败的超类run()中的PyOpenPythonFileAction实现)。在if (viewer.isExpandable(container)) {的第110行抛出异常。那里的eclipse资源代码是根据一些标志位检查资源类型,我不知道为什么它返回false。我把一个警卫只检查Project类型的资源,项目存在并且是打开的,但它仍然失败。

EDIT3:

PyOpenPythonFileAction,环绕

if (viewer.isExpandable(container)) {
    viewer.setExpandedState(container, !viewer.getExpandedState(container));
}

UIJob并给它一个500毫秒的延迟似乎解决了它。

这是带有堆栈跟踪的控制台输出。已关闭并重新打开的项目名为" site"。

  

!ENTRY org.python.pydev.shared_core 1 1 2016-12-06 16:31:28.037   !MESSAGE资源' / site'不存在。   !堆栈1   org.eclipse.core.internal.resources.ResourceException:资源' / site'不存在。       在org.eclipse.core.internal.resources.Resource.checkExists(Resource.java:335)       在org.eclipse.core.internal.resources.Resource.checkAccessible(Resource.java:209)       在org.eclipse.core.internal.resources.Project.checkAccessible(Project.java:141)       在org.eclipse.core.internal.resources.Project.hasNature(Project.java:521)       在org.eclipse.core.internal.resources.Project.getNature(Project.java:405)       at org.python.pydev.plugin.nature.PythonNature.getPythonNature(PythonNature.java:809)       在org.python.pydev.navigator.PythonBaseModelProvider.getChildrenForIResourceOrWorkingSet(PythonBaseModelProvider.java:611)       在org.python.pydev.navigator.PythonBaseModelProvider.getChildren(PythonBaseModelProvider.java:535)       在org.python.pydev.navigator.PythonModelProvider.getChildren(PythonModelProvider.java:63)       在org.python.pydev.navigator.PythonBaseModelProvider.hasChildren(PythonBaseModelProvider.java:510)       在org.eclipse.ui.internal.navigator.extensions.SafeDelegateTreeContentProvider.hasChildren(SafeDelegateTreeContentProvider.java:112)       在org.eclipse.ui.internal.navigator.NavigatorContentServiceContentProvider.callNormalHasChildren(NavigatorContentServiceContentProvider.java:444)       在org.eclipse.ui.internal.navigator.NavigatorContentServiceContentProvider.pipelineHasChildren(NavigatorContentServiceContentProvider.java:463)       at org.eclipse.ui.internal.navigator.NavigatorContentServiceContentProvider.access $ 5(NavigatorContentServiceContentProvider.java:447)       at org.eclipse.ui.internal.navigator.NavigatorContentServiceContentProvider $ 3.run(NavigatorContentServiceContentProvider.java:413)       在org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)       在org.eclipse.ui.internal.navigator.NavigatorContentServiceContentProvider.hasChildren(NavigatorContentServiceContentProvider.java:392)       在org.eclipse.ui.internal.navigator.NavigatorContentServiceContentProvider.hasChildren(NavigatorContentServiceContentProvider.java:436)       在org.eclipse.jface.viewers.AbstractTreeViewer.isExpandable(AbstractTreeViewer.java:2128)       在org.eclipse.jface.viewers.TreeViewer.isExpandable(TreeViewer.java:538)       在org.python.pydev.navigator.actions.PyOpenPythonFileAction.run(PyOpenPythonFileAction.java:110)       在org.eclipse.ui.actions.RetargetAction.run(RetargetAction.java:225)       在org.eclipse.ui.navigator.CommonNavigatorManager $ 2.open(CommonNavigatorManager.java:191)       at org.eclipse.ui.OpenAndLinkWithEditorHelper $ InternalListener.open(OpenAndLinkWithEditorHelper.java:46)       在org.eclipse.jface.viewers.StructuredViewer $ 2.run(StructuredViewer.java:855)       在org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)       在org.eclipse.ui.internal.JFaceUtil $ 1.run(JFaceUtil.java:50)       在org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:173)       在org.eclipse.jface.viewers.StructuredViewer.fireOpen(StructuredViewer.java:852)       在org.eclipse.jface.viewers.StructuredViewer.handleOpen(StructuredViewer.java:1169)       在org.eclipse.ui.navigator.CommonViewer.handleOpen(CommonViewer.java:451)       在org.eclipse.jface.util.OpenStrategy.fireOpenEvent(OpenStrategy.java:278)       在org.eclipse.jface.util.OpenStrategy.access $ 2(OpenStrategy.java:272)       在org.eclipse.jface.util.OpenStrategy $ 1.handleEvent(OpenStrategy.java:313)       在org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)       在org.eclipse.swt.widgets.Display.sendEvent(Display.java:5219)       在org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1340)       在org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4553)       在org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4143)       at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine $ 4.run(PartRenderingEngine.java:1121)       在org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)       在org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1022)       在org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:150)       在org.eclipse.ui.internal.Workbench $ 5.run(Workbench.java:687)       在org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)       在org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:604)       在org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)       at my.package.MyApplication.start(MyApplication.java:137)       在org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)       在org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)       在org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)       在org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)       在org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)       at java.lang.reflect.Method.invoke(Method.java:498)       在org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:673)       在org.eclipse.equinox.launcher.Main.basicRun(Main.java:610)       在org.eclipse.equinox.launcher.Main.run(Main.java:1519)       在org.eclipse.equinox.launcher.Main.main(Main.java:1492)   !SUBENTRY 1 org.eclipse.core.resources 4 368 2016-12-06 16:31:28.095   !MESSAGE资源' / site'不存在。

1 个答案:

答案 0 :(得分:0)

您可能在项目配置中的某个位置引用了一个不存在的site项目(因此,请检查工作区中的.project.pydevproject文件以获取此类项目)