hallvard / plantuml

Embed UML diagrams in files and view them in Eclipse
http://plantuml.sourceforge.net/
209 stars 57 forks source link

java.net.URISyntaxException: Relative path in absolute URI: ws:C:/Users/MICHAE~1/AppData/Local/Temp/PrintStream.class1095749574442564857.class Error message when Link with Editor is on. #164

Open m-metz opened 1 year ago

m-metz commented 1 year ago

I get a terrible pop up message error every time I click into standard Java Libraries with the PlantUML plugin Having "Link with editor" on. If I click on the open standard library file afterwards, the same error message pops up.

Screenshot 2022-10-22 024102

java.lang.RuntimeException: java.net.URISyntaxException: Relative path in absolute URI: ws:C:/Users/MICHAE~1/AppData/Local/Temp/PrintStream.class1095749574442564857.class
    at net.sourceforge.plantuml.eclipse.utils.LocationDiagramIntentProviderContext.setLocation(LocationDiagramIntentProviderContext.java:35)
    at net.sourceforge.plantuml.eclipse.utils.LocationDiagramIntentProviderContext.setFileLocation(LocationDiagramIntentProviderContext.java:28)
    at net.sourceforge.plantuml.eclipse.utils.WorkbenchPartDiagramIntentProviderContext.<init>(WorkbenchPartDiagramIntentProviderContext.java:30)
    at net.sourceforge.plantuml.eclipse.views.AbstractDiagramSourceView.updateDiagramText(AbstractDiagramSourceView.java:503)
    at net.sourceforge.plantuml.eclipse.views.AbstractDiagramSourceView.updateDiagramText(AbstractDiagramSourceView.java:445)
    at net.sourceforge.plantuml.eclipse.views.AbstractDiagramSourceView$DiagramTextChangedListener.diagramChanged(AbstractDiagramSourceView.java:352)
    at net.sourceforge.plantuml.eclipse.views.AbstractDiagramSourceView$DiagramTextChangedListener.selectionChanged(AbstractDiagramSourceView.java:347)
    at org.eclipse.ui.internal.e4.compatibility.SelectionService.notifyListeners(SelectionService.java:266)
    at org.eclipse.ui.internal.e4.compatibility.SelectionService.notifyListeners(SelectionService.java:180)
    at org.eclipse.ui.internal.WorkbenchPage$E4PartListener.partActivated(WorkbenchPage.java:214)
    at org.eclipse.e4.ui.internal.workbench.PartServiceImpl$2.run(PartServiceImpl.java:250)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
    at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.firePartActivated(PartServiceImpl.java:247)
    at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:771)
    at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:680)
    at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:675)
    at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.hidePart(PartServiceImpl.java:1396)
    at org.eclipse.ui.internal.WorkbenchPage.hidePart(WorkbenchPage.java:1542)
    at org.eclipse.ui.internal.WorkbenchPage.hidePart(WorkbenchPage.java:1494)
    at org.eclipse.ui.internal.WorkbenchPage.closeEditors(WorkbenchPage.java:1464)
    at org.eclipse.ui.internal.WorkbenchPage.closeEditor(WorkbenchPage.java:1588)
    at org.eclipse.ui.internal.CloseEditorHandler.execute(CloseEditorHandler.java:50)
    at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:283)
    at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:97)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58)
    at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:317)
    at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:251)
    at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:173)
    at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:156)
    at org.eclipse.core.commands.Command.executeWithChecks(Command.java:488)
    at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:487)
    at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:213)
    at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.executeCommand(KeyBindingDispatcher.java:308)
    at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.press(KeyBindingDispatcher.java:580)
    at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.processKeyEvent(KeyBindingDispatcher.java:647)
    at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.filterKeySequenceBindings(KeyBindingDispatcher.java:439)
    at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher$KeyDownFilter.handleEvent(KeyBindingDispatcher.java:96)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
    at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1280)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1062)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1087)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1072)
    at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1114)
    at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1110)
    at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1539)
    at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:4868)
    at org.eclipse.swt.widgets.Canvas.WM_CHAR(Canvas.java:345)
    at org.eclipse.swt.widgets.Control.windowProc(Control.java:4746)
    at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:340)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:5015)
    at org.eclipse.swt.internal.win32.OS.DispatchMessage(Native Method)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3630)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1155)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1046)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
    at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:644)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:551)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:156)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:401)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1467)
Caused by: java.net.URISyntaxException: Relative path in absolute URI: ws:C:/Users/MICHAE~1/AppData/Local/Temp/PrintStream.class1095749574442564857.class
    at java.base/java.net.URI.checkPath(URI.java:1998)
    at java.base/java.net.URI.<init>(URI.java:707)
    at java.base/java.net.URI.<init>(URI.java:809)
    at net.sourceforge.plantuml.eclipse.utils.LocationDiagramIntentProviderContext.setLocation(LocationDiagramIntentProviderContext.java:33)
    ... 76 more

As a workaround I turn of "Link with Editor" but I spent way too long figuring out it was a PlantUML bug.

Looking through your code it looks like your setFileLocation(((IPathEditorInput) editorInput).getPath()); in WorkbenchPartDiagramIntentProviderContext.java

    public WorkbenchPartDiagramIntentProviderContext(final IWorkbenchPart workbenchPart, final ISelection selection) {
        this.workbenchPart = workbenchPart;
        this.selection = (selection == StructuredSelection.EMPTY ? null : selection);
        if (workbenchPart instanceof IEditorPart) {
            final IEditorInput editorInput = ((IEditorPart) workbenchPart).getEditorInput();
            if (editorInput instanceof IStorageEditorInput) {
                try {
                    setWorkspaceLocation(((IStorageEditorInput) editorInput).getStorage().getFullPath());
                } catch (final CoreException e) {
                    throw new RuntimeException(e);
                }
            } else if (editorInput instanceof IPathEditorInput) {
                setFileLocation(((IPathEditorInput) editorInput).getPath());
            } else if (editorInput instanceof IURIEditorInput) {
                setLocation(((IURIEditorInput) editorInput).getURI());
            }
        }
    }

is calling setFileLocation(final IPath path) in LocationDiagramIntentProviderContext.java

    public void setLocation(final URI location) {
        this.location = location;
    }

    public void setWorkspaceLocation(final IPath path) {
        setLocation(path, "ws");
    }

    public void setFileLocation(final IPath path) {
        setLocation(path, "file");
    }

    private void setLocation(final IPath path, final String scheme) {
        try {
            setLocation(new URI("ws", null, path.toString(), null));
        } catch (final URISyntaxException e) {
            throw new RuntimeException(e);
        }
    }

Which has a "file" schema parameter, but then that is never used in setLocation(new URI("ws", null, path.toString(), null)); Should the "ws" be "file" here?

Anyway, if there is some way to stop the pop up error message when viewing Java System Library files in Eclipse (while Link with Editor is turned on), it is much appreciated.

The error message does not happen when I load outside java files that aren't in my workspace, just when viewing system libraries.

Another strange thing is the FilePath of the library has a file path to a class file, but it somehow shows source code, not sure if that is related. ws:C:/Users/MICHAE~1/AppData/Local/Temp/PrintStream.class1095749574442564857.class

I know you are busy and I appreciate the time you are taking to look into this issue.

hallvard commented 1 year ago

Thanks for reporting, it indeed looks like a bug, since the scheme argument isn't used for the file case. I'm still not sure it will work for this particular kind of file, though, but I will take a look!

I don't think there's any way of turning the error message of, without turning off the coupling/link between the editor and the plantuml view.