gpt4 book ai didi

eclipse - company-emacs-eclim 使用错误的项目路径

转载 作者:行者123 更新时间:2023-12-02 01:22:06 26 4
gpt4 key购买 nike

我为大型 Java/Maven 项目安装了新的 Emacs(在 Windows 上)。

已安装 Eclipse 和 eclim(带 java 层的 spacemacs 更新到最新版本,company-emacs-eclim 作为额外包安装),但是当 company-emacs-eclim 尝试自动完成时,它使用错误的文件路径,插入项目文件夹两次,例如

X:/EclipseWorkspace/Project/Project/src/main/com/company/product/Klass.java

代替

X:/EclipseWorkspace/Project/src/main/com/company/product/Klass.java

错误信息是

Company: An error occurred in auto-begin
Company: backend company-emacs-eclim error "Could not read from "file:///X:/EclipseWorkspace/Project/Project/src/main/com/company/product/Klass.java" because it is a not a file." with args (candidates this)

在 eclimd 中,我得到一个异常并显示相同的消息:

ERROR [org.eclim.command.Main] Command failed
org.apache.commons.vfs.FileSystemException: Could not read from "file:///X:/EclipseWorkspace/Project/Project/src/main/com/company/product/Klass.java" because it is a not a file.
at org.apache.commons.vfs.provider.AbstractFileObject.getInputStream(AbstractFileObject.java:1109)
at org.apache.commons.vfs.provider.DefaultFileContent.getInputStream(DefaultFileContent.java:317)
at org.eclim.util.file.FileUtils.byteOffsetToCharOffset(FileUtils.java:75)
at org.eclim.plugin.core.command.AbstractCommand.getOffset(AbstractCommand.java:99)
at org.eclim.plugin.core.command.AbstractCommand.getOffset(AbstractCommand.java:71)
at org.eclim.plugin.core.command.complete.AbstractCodeCompleteCommand.execute(AbstractCodeCompleteCommand.java:60)
at org.eclim.command.Main$1.run(Main.java:100)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:182)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4203)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3819)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1121)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1022)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:150)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:687)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:604)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:138)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
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:673)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:610)
at org.eclipse.equinox.launcher.Main.run(Main.java:1519)

我试过关闭并重新打开工作区,在 Emacs 中重新打开项目,重新创建整个工作区,一切都得到相同的结果。

最佳答案

简短的回答似乎是 eclim 对多模块 maven 项目的支持不完整。参见例如https://github.com/ervandew/eclim/issues/499 .

问题与company无关,同样调用eclim-complete报错。似乎发生的情况是,在多模块项目中,eclim--project-current-file 被设置为相对于根而不是当前项目的路径。

您可以通过建议 eclim--current-project-file 返回正确的相对路径来解决这个问题。例如:

(defun my-eclim-fix-relative-path (path)
(replace-regexp-in-string "^.*src/" "src/" path))

(advice-add 'eclim--project-current-file :filter-return #'my-eclim-fix-relative-path)

这可能会影响其他 eclim 行为,但在我的快速测试中,当我处理 src/main 和 src/test 文件时,它对我有用。

关于eclipse - company-emacs-eclim 使用错误的项目路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39505506/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com