在Eclipse中打开php文件的问题

时间:2010-02-14 21:03:55

标签: php eclipse eclipse-pdt

我刚刚在eclipse(Galileo)中设置了PDT,但在打开任何.php文件时会收到以下错误。

有谁知道如何解决这个问题?

提前致谢

TAO。

PHP文件:

<?php
echo "test"
?>

ERROR:

Could not open the editor: Editor could not be initialized.

详细说明:

java.lang.AbstractMethodError: org.eclipse.php.internal.core.compiler.ast.parser.PHPSourceParserFactory.parse(Lorg/eclipse/dltk/compiler/env/IModuleSource;Lorg/eclipse/dltk/compiler/problem/IProblemReporter;)Lorg/eclipse/dltk/ast/parser/IModuleDeclaration;
    at org.eclipse.dltk.core.SourceParserUtil.parse(SourceParserUtil.java:137)
    at org.eclipse.dltk.core.SourceParserUtil.getModuleDeclaration(SourceParserUtil.java:197)
    at org.eclipse.dltk.core.SourceParserUtil.getModuleDeclaration(SourceParserUtil.java:183)
    at org.eclipse.dltk.core.SourceParserUtil.getModuleDeclaration(SourceParserUtil.java:174)
    at org.eclipse.dltk.core.AbstractSourceElementParser.parse(AbstractSourceElementParser.java:42)
    at org.eclipse.dltk.core.AbstractSourceElementParser.parseSourceModule(AbstractSourceElementParser.java:26)
    at org.eclipse.dltk.internal.core.AbstractSourceModule.buildStructure(AbstractSourceModule.java:507)
    at org.eclipse.dltk.internal.core.Openable.generateInfos(Openable.java:185)
    at org.eclipse.dltk.internal.core.ModelElement.openWhenClosed(ModelElement.java:182)
    at org.eclipse.dltk.internal.core.BecomeWorkingCopyOperation.executeOperation(BecomeWorkingCopyOperation.java:45)
    at org.eclipse.dltk.internal.core.ModelOperation.run(ModelOperation.java:698)
    at org.eclipse.dltk.internal.core.ModelOperation.runOperation(ModelOperation.java:764)
    at org.eclipse.dltk.internal.core.SourceModule.becomeWorkingCopy(SourceModule.java:68)
    at org.eclipse.dltk.internal.ui.editor.SourceModuleDocumentProvider.createFileInfo(SourceModuleDocumentProvider.java:1251)
    at org.eclipse.ui.editors.text.TextFileDocumentProvider.connect(TextFileDocumentProvider.java:478)
    at org.eclipse.dltk.internal.ui.editor.SourceModuleDocumentProvider.connect(SourceModuleDocumentProvider.java:1484)
    at org.eclipse.ui.texteditor.AbstractTextEditor.doSetInput(AbstractTextEditor.java:4134)
    at org.eclipse.ui.texteditor.StatusTextEditor.doSetInput(StatusTextEditor.java:203)
    at org.eclipse.ui.texteditor.AbstractDecoratedTextEditor.doSetInput(AbstractDecoratedTextEditor.java:1413)
    at org.eclipse.ui.editors.text.TextEditor.doSetInput(TextEditor.java:166)
    at org.eclipse.wst.sse.ui.StructuredTextEditor.doSetInput(StructuredTextEditor.java:1712)
    at org.eclipse.php.internal.ui.editor.PHPStructuredEditor.doSetInput(PHPStructuredEditor.java:2208)
    at org.eclipse.ui.texteditor.AbstractTextEditor$19.run(AbstractTextEditor.java:3115)
    at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:464)
    at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:372)
    at org.eclipse.jface.window.ApplicationWindow$1.run(ApplicationWindow.java:759)
    at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
    at org.eclipse.jface.window.ApplicationWindow.run(ApplicationWindow.java:756)
    at org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow.java:2579)
    at org.eclipse.ui.texteditor.AbstractTextEditor.internalInit(AbstractTextEditor.java:3133)
    at org.eclipse.ui.texteditor.AbstractTextEditor.init(AbstractTextEditor.java:3160)
    at org.eclipse.wst.sse.ui.StructuredTextEditor.init(StructuredTextEditor.java:2321)
    at org.eclipse.php.internal.ui.editor.PHPStructuredEditor.init(PHPStructuredEditor.java:1151)
    at org.eclipse.ui.internal.EditorManager.createSite(EditorManager.java:798)
    at org.eclipse.ui.internal.EditorReference.createPartHelper(EditorReference.java:644)
    at org.eclipse.ui.internal.EditorReference.createPart(EditorReference.java:462)
    at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:595)
    at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:313)
    at org.eclipse.ui.internal.presentations.PresentablePart.setVisible(PresentablePart.java:180)
    at org.eclipse.ui.internal.presentations.util.PresentablePartFolder.select(PresentablePartFolder.java:270)
    at org.eclipse.ui.internal.presentations.util.LeftToRightTabOrder.select(LeftToRightTabOrder.java:65)
    at org.eclipse.ui.internal.presentations.util.TabbedStackPresentation.selectPart(TabbedStackPresentation.java:473)
    at org.eclipse.ui.internal.PartStack.refreshPresentationSelection(PartStack.java:1256)
    at org.eclipse.ui.internal.PartStack.setSelection(PartStack.java:1209)
    at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:1608)
    at org.eclipse.ui.internal.PartStack.add(PartStack.java:499)
    at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:103)
    at org.eclipse.ui.internal.PartStack.add(PartStack.java:485)
    at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:112)
    at org.eclipse.ui.internal.EditorSashContainer.addEditor(EditorSashContainer.java:63)
    at org.eclipse.ui.internal.EditorAreaHelper.addToLayout(EditorAreaHelper.java:225)
    at org.eclipse.ui.internal.EditorAreaHelper.addEditor(EditorAreaHelper.java:213)
    at org.eclipse.ui.internal.EditorManager.createEditorTab(EditorManager.java:778)
    at org.eclipse.ui.internal.EditorManager.openEditorFromDescriptor(EditorManager.java:677)
    at org.eclipse.ui.internal.EditorManager.openEditor(EditorManager.java:638)
    at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched(WorkbenchPage.java:2854)
    at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:2762)
    at org.eclipse.ui.internal.WorkbenchPage.access$11(WorkbenchPage.java:2754)
    at org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.java:2705)
    at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
    at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2701)
    at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2685)
    at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2676)
    at org.eclipse.dltk.internal.ui.editor.EditorUtility.openInEditor(EditorUtility.java:405)
    at org.eclipse.dltk.internal.ui.editor.EditorUtility.openInEditor(EditorUtility.java:166)
    at org.eclipse.dltk.internal.ui.actions.OpenActionUtil.open(OpenActionUtil.java:45)
    at org.eclipse.dltk.ui.actions.OpenAction.run(OpenAction.java:259)
    at org.eclipse.dltk.ui.actions.OpenAction.run(OpenAction.java:240)
    at org.eclipse.dltk.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:259)
    at org.eclipse.dltk.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:235)
    at org.eclipse.dltk.internal.ui.scriptview.ScriptExplorerActionGroup.handleOpen(ScriptExplorerActionGroup.java:304)
    at org.eclipse.php.internal.ui.explorer.PHPExplorerActionGroup.handleOpen(PHPExplorerActionGroup.java:103)
    at org.eclipse.dltk.internal.ui.scriptview.ScriptExplorerPart$4.open(ScriptExplorerPart.java:667)
    at org.eclipse.jface.viewers.StructuredViewer$2.run(StructuredViewer.java:842)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.core.runtime.Platform.run(Platform.java:888)
    at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:48)
    at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
    at org.eclipse.jface.viewers.StructuredViewer.fireOpen(StructuredViewer.java:840)
    at org.eclipse.jface.viewers.StructuredViewer.handleOpen(StructuredViewer.java:1101)
    at org.eclipse.jface.viewers.StructuredViewer$6.handleOpen(StructuredViewer.java:1205)
    at org.eclipse.jface.util.OpenStrategy.fireOpenEvent(OpenStrategy.java:264)
    at org.eclipse.jface.util.OpenStrategy.access$2(OpenStrategy.java:258)
    at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:298)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3880)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3473)
    at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2405)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2369)
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2221)
    at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:493)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1311)

4 个答案:

答案 0 :(得分:9)

将DLTK升级到2.0 M5时,我也遇到了同样的问题。

切换回M4似乎已经解决了我的问题:

  1. 下载DLTK 2.0 M4插件存档:
    http://download.eclipse.org/technology/dltk/downloads/drops/R2.0/S-2.0M4-200912141114/
    (核心框架线)
  2. 解压缩zip存档
  3. 找到你的eclipse插件目录(在我的Ubuntu上,在/.eclipse/org.eclipse.platform_3.5.0_155965261/plugins中)。
  4. 确保关闭eclipse。擦除或重命名有问题的jar文件:

    $ mv org.eclipse.dltk.core_2.0.0.v20100212-1450.jar org.eclipse.dltk.core_2.0.0.v20100212-1450.jar.bak

  5. 将org.eclipse.dltk.core_2.0.0.v20100201-1709.jar从存档版本复制到您的插件目录。
  6. 将复制的文件重命名为M5版本1:

    $ mv org.eclipse.dltk.core_2.0.0.v20100201-1709.jar org.eclipse.dltk.core_2.0.0.v20100212-1450.jar

  7. 希望它有所帮助。

答案 1 :(得分:4)

对于那些来到这篇旧帖子的人,我只是想让你知道还有另一个选项可以将VS Code的PHP智能带到Eclipse Neon及更高版本。它是一个名为CodeMix的插件,除了许多其他动态语言外,还通过许多可用扩展提供对PHP的支持。您可以在CodeMix page上找到有关它的更多信息,或将其安装到Eclipse directly from the Eclipse marketplace中。

答案 2 :(得分:3)

可悲的是,根据DLTK的最新更新,Benoit的配方不再适用于我。然而,下载PDT的每晚构建确实如此。这是你做的:

下载每晚PDP版本:N201003021518 / pdt-Update-N201003021518.zip

(当你按照这个方法时,最新的稳定版本可能已经开始了,所以请在https://build.eclipse.org/hudson/view/Athena%20CBI/job/cbi-pdt-2.2-helios/lastStableBuild/下查看 - 展开“Build Artifacts”链接,直到找到zip文件。)

创建本地更新站点: mkdir / tmp / eclipse cd / tmp / eclipse_pdt unzip~ / Downloads / pdt-Update-N201003021518.zip

在Eclipse中,选择“帮助” - >&gt;安装新软件 - &gt;使用方法:添加 - &gt;本地...... - &gt;的/ tmp / eclipse_pdt (单击“确定”并为其命名,例如“PDT Nightly Build”) 在主窗口中,选择要安装的功能(我选择了除PDT Mylyn功能之外的所有功能) 下一个 完 当被问及是否接受“未签名”内容时,请说好。出现提示时重新启动Eclipse。

答案 3 :(得分:0)

我遇到了同样的问题。我开始下载“Eclipse Classic 3.5.2”,决定是时候告别3.3了。我安装的第一个插件是PDT 2.1,这让我误入了一系列错误,包括:

  • “编辑器无法初始化”
  • “语义突出工作”
  • “处理脏区”

Benoit的jar修正案解决了editer initilisation问题,但我仍然在寻找其他错误的修复程序。最后我决定通过简单地删除3.5.2文件夹来退出升级(感谢Eclipse开发人员没有用垃圾填充我的注册表),并下载了“Eclipse for PHP Developers”包,因为它包含了PDT。到目前为止,一切似乎都在起作用。