ccw-ide / ccw

Counterclockwise is an Eclipse plugin helping developers write Clojure code
https://github.com/laurentpetit/ccw/wiki/GoogleCodeHome
Eclipse Public License 1.0
220 stars 50 forks source link

Double-click on name in namespace browser results in NPE #800

Closed asampal closed 9 years ago

asampal commented 9 years ago

I was just looking around and double-clicked on a name in the user namespace in the browser. Got this NPE:

eclipse.buildId=4.5.0.I20150603-2000 java.version=1.8.0_45 java.vendor=Oracle Corporation BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US Command-line arguments: -os win32 -ws win32 -arch x86_64 -data D:\dev\eclipse-workspace

org.eclipse.jface Error Wed Jul 01 01:50:00 EDT 2015 Problems occurred when invoking code from plug-in: "org.eclipse.jface".

java.lang.NullPointerException at ccw.ClojureCore.openInEditor(ClojureCore.java:231) at ccw.repl.NamespaceBrowser$3.doubleClick(NamespaceBrowser.java:240) at org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredViewer.java:832) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:50) at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:173) at org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(StructuredViewer.java:829) at org.eclipse.jface.viewers.AbstractTreeViewer.handleDoubleSelect(AbstractTreeViewer.java:1470) at org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSelected(StructuredViewer.java:1263) at org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEvent(OpenStrategy.java:252) at org.eclipse.jface.util.OpenStrategy.access$0(OpenStrategy.java:249) at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:311) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4362) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1113) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4180) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3769) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1127) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1018) at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:156) at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:654) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:598) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:139) 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:380) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235) 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:669) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:608) at org.eclipse.equinox.launcher.Main.run(Main.java:1515)

laurentpetit commented 9 years ago

good catch, thanks!

asampal commented 9 years ago

After an update to CCW last night when I reported this, I now don't get anything visible in the browser when I "load file in REPL" from the context menu. The REPL is started as expected, though.

laurentpetit commented 9 years ago

Can you please file a separate issue for this second problem?

laurentpetit commented 9 years ago

Concerning the first issue: how is the user namespace loaded? I think it may be loaded from a place that is not defined in eclipse class path?

asampal commented 9 years ago

Hmm, I see now that I get the same exception when I double click any name in any namespace in the embedded Eclipse REPL. Now I'm starting to question if the original NPE I reported was in a REPL that I had opened on a file in my own project or whether it was also in the embedded REPL that opens automatically when you import user plugins. At the moment, as I mentioned, I don't see any contents in the browser for my own projects.

laurentpetit commented 9 years ago

Hmmm, this is real annoying indeed. Can you see in the .log file if there is an output related to the lack of content in the namespace browser? Could it be that the namespace browser still tries to related to the embedded repl ?

2015-07-02 17:54 GMT+02:00 Adrian Sampaleanu notifications@github.com:

Hmm, I see now that I get the same exception when I double click any name in any namespace in the embedded Eclipse REPL. Now I'm starting to question if the original NPE I reported was in a REPL that I had opened on a file in my own project or whether it was also in the embedded REPL that opens automatically when you import user plugins. At the moment, as I mentioned, I don't see any contents in the browser for my own projects.

— Reply to this email directly or view it on GitHub https://github.com/laurentpetit/ccw/issues/800#issuecomment-118076269.

Laurent Petit

asampal commented 9 years ago

Nothing in the log that I can see. Here are the last few entries after the REPL is started:

!ENTRY ccw.core 1 0 2015-07-02 12:52:32.045
!MESSAGE nRepl port will be automatically selected

!ENTRY ccw.core 1 0 2015-07-02 12:52:32.054
!MESSAGE Started ccw nREPL server: nrepl://127.0.0.1:54371

!ENTRY ccw.core 1 0 2015-07-02 12:52:32.148
!MESSAGE putting in launchNameREPLURLPromiseAndWithREPLView the key: zorba Leiningen VM (5) #1

!ENTRY ccw.core 1 0 2015-07-02 12:52:32.594
!MESSAGE reading in launchNameREPLURLPromiseAndWithREPLView the key: zorba Leiningen VM (5) #1

!ENTRY org.eclipse.equinox.p2.repository 2 0 2015-07-02 12:52:52.062
!MESSAGE Server returned lastModified <= 0 for https://raw.github.com/satyagraha/gfm_viewer/master/p2-composite/compositeContent.xml

!ENTRY ccw.core 1 0 2015-07-02 12:53:09.839
!MESSAGE reading in launchNameREPLURLPromiseAndWithREPLView the key: zorba Leiningen VM (5) #1 for getting the promise to set the port to nrepl://127.0.0.1:54450

Right now I just restarted Eclipse and didn't open a REPL for the embedded server so that shouldn't come into the picture.

Maybe you can add some additional logging to help with this issue.

laurentpetit commented 9 years ago

Ok I'm on it. I've been able to reproduce the problem in a very specific combination of the preferences (start with lein / use cider-nrepl) which happens to be the default one ... I don't use the namespace browser that much those days.

I think I will add some smoke tests related to repl start and namespace browser content, while I'm at it.

laurentpetit commented 9 years ago

Ok, so indeed, when opening a namespace browser, and some namespaces have been loaded from file (with file/line information), there is an NullPointerException when trying to open the file, since it's not referenced anywhere in the Eclipse project. Will need to open the file not as a workspace resource, but as a filesystem path

arichiardi commented 9 years ago

:+1: