我有一个新的Emacs设置(在Windows上)用于大型Java / Maven项目。
已安装的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中重新打开项目,重新创建整个工作区,所有内容都会产生相同的结果。
答案 0 :(得分:1)
您是否检查了项目根目录下的.classpath文件的内容?这可能会以某种方式包含一些错误。如果您将其编辑为指向正确的目录,则可能会修复自动完成。
答案 1 :(得分:1)
简短的回答似乎是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文件时,它对我有用。