简体   繁体   中英

company-emacs-eclim uses wrong path for project

I have a new Emacs setup (on Windows) for a largeish Java/Maven project.

Installed Eclipse and eclim (spacemacs with java layer updated to latest version, company-emacs-eclim installed as extra package), but when company-emacs-eclim tries to autocomplete, it uses the wrong path to the file, inserting the project folder twice, eg

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

instead of

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

Error message is

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)

In eclimd, I get an exception with the same message:

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)

I've tried closing and reopening the workspace, reopening the project in Emacs, recreating the entire workspace, everything gives the same result.

have you checked the contents of the .classpath file at the root of your project? That may contain some errors somehow. If you edit it to point to the right directories, that may fix the autocompletion.

The short answer seems to be that eclim has incomplete support for multi-module maven projects. See eg https://github.com/ervandew/eclim/issues/499 .

The problem is not related to company , the error is the same calling eclim-complete . What seems to happen is that in a multi-module project eclim--project-current-file is set to a path relative to the root rather than the current project.

You could work around this by advising eclim--current-project-file to return the right relative path. For example:

(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)

This may affect other eclim behavior, but in my quick testing it works for me when I'm working on src/main and src/test files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM