eclipselabs/eclipse-language-service

Use IProcessFactory to get OutputStream from RuntimeProcess

Closed this issue · 5 comments

LaunchConfigurationStreamProvider#getOutputStream redefine class accessible to call getSystemProcess:

// TODO: Ugly hack, find something better to retrieve stream!
Method systemProcessGetter = RuntimeProcess.class.getDeclaredMethod("getSystemProcess"); //$NON-NLS-1$
systemProcessGetter.setAccessible(true);
Process systemProcess = (Process)systemProcessGetter.invoke(process);
this.outputStream = systemProcess.getOutputStream();

A clean solution is to do define a org.eclipse.debug.core.processFactories and do like https://github.com/JPMoresmau/eclipsefp/search?utf8=%E2%9C%93&q=REPLProcessFactory to extends RuntimeProcess and set as public the getSystemProcess like https://github.com/JPMoresmau/eclipsefp/blob/master/net.sf.eclipsefp.haskell.debug.core/src/net/sf/eclipsefp/haskell/debug/core/internal/launch/REPLProcessFactory.java#L45

That seems nice, but wouldn't it require a specific Launch Configuration and force us to use it? I'd really like to keep some flexibility about the kind of Launch Configuration that are usable as language servers, as some may be in the same VM, some other have debug, some other be fully external...

Actually, it seems like this is just an attribute to pass to the LaunchConfiguration, without requesting a specific LaunchConfigurationType, so that seems like the right way to do things!

@mickaelistria never done that, I have just discovered this solution with internet.

This is currently a nice-to-have, however if in some future we want to support other transports than stdin/stdout, we'll need to create a bunch of process factories (one per transport) and associate them to the launch configurations to retrieve the right streams.