ruby / irb

interactive Ruby
BSD 2-Clause "Simplified" License
356 stars 114 forks source link

Support C-method source in `show_source` command #664

Open st0012 opened 11 months ago

st0012 commented 11 months ago

The main challenge of this support comes from acquiring the C-method source files:

So instead of relying on the installed CRuby source, downloading the source later may be a better approach (proposed by @k0kubun).

Questions:

st0012 commented 2 weeks ago

We may use rbs to get information for core classes/modules/methods like ruby-lsp does. However, rbs doesn't support JRuby so the implementation needs to be conditional.

headius commented 2 weeks ago

It should not require significant changes to JRuby to support rbs type information for core classes. The information is all available in the JRuby .class files and .jar file.

In addition, the currently-running JRuby's sources can always be fetched from Maven Central and used to extract the Java sources of those core methods.

st0012 commented 2 weeks ago

To make sure we're talking about the same thing: what I'm referring to is that the rbs gem won't compile with JRuby as described here. I thought it needs to be resolved from the rbs side?

headius commented 2 weeks ago

@st0012 The last few comments on that issue describe the path forward more clearly. You are correct that JRuby does not support the rbs native extension (JRuby does not support the CRuby extension API at all) but @soutaro mentioned in that issue that there's some work going on to make a pure-Ruby parser to eliminate this issue. When that is available, rbs should work fine on JRuby.