tpope / vim-fireplace

fireplace.vim: Clojure REPL support
https://www.vim.org/scripts/script.php?script_id=4978
1.74k stars 139 forks source link

Provide jar handling for java source jumping #365

Closed mikepjb closed 5 years ago

mikepjb commented 5 years ago

This change passes through ns when making the call to info and handles the case when referenced code is included on the classpath as a zip file (typical for java source e.g /usr/lib/jvm/java-10-openjdk/src.zip)

This should mean that you can jump to java source code using FireplaceDJump (I've tested this on Vim 8.1 with patches 1-1776 and Neovim v0.3.8)

Special thanks to @SevereOverfl0w for helping put this together with me :1st_place_medal:

tpope commented 5 years ago

How can I test this? I checked fireplace#info('System/getProperty') and it has no file or resource attribute. What's a Java method that does?

mikepjb commented 5 years ago

I've been using echo fireplace#info('Runtime/getRuntime')

mikepjb commented 5 years ago

I am getting both file and resource for System/getProperty and Runtime/getRuntime

What system are you using?

tpope commented 5 years ago

Tried on Ubuntu:

openjdk version "11.0.4" 2019-07-16
OpenJDK Runtime Environment (build 11.0.4+11-post-Ubuntu-1ubuntu219.04)
OpenJDK 64-Bit Server VM (build 11.0.4+11-post-Ubuntu-1ubuntu219.04, mixed mode, sharing)

And on macOS:

java version "1.8.0_211"
Java(TM) SE Runtime Environment (build 1.8.0_211-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)
mikepjb commented 5 years ago

Do you have openjdk-11-source installed on Ubuntu?

I just uninstalled the source package from my machine and found that Runtime/getRuntime no longer returns file or resource when the source package is removed.

tpope commented 5 years ago

:+1:. This is good to go. Just wanted to get the context so I can investigate the #findresource() side of things in the future.

mikepjb commented 5 years ago

No problem, glad I could help :+1:

SevereOverfl0w commented 5 years ago

As an aside, without these changes the cider-nrepl info op was never returning any useful information as the 'ns' wasn't set for it to lookup details about the symbol.

mikepjb commented 5 years ago

@SevereOverfl0w I believe 'ns' is set inside fireplace#message on L1064 of the autoload/fireplace.vim file

function! fireplace#message(payload, ...) abort
  let client = fireplace#client()
  let payload = copy(a:payload)
  if !has_key(payload, 'ns')
    let payload.ns = v:true
  endif
  return call(client.message, [payload] + a:000, client)
endfunction