Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Java class and method resolution to info middleware. #40

Merged
merged 1 commit into from
Apr 25, 2014

Conversation

jeffvalk
Copy link
Contributor

This gives Java classes/methods "info" middleware support. Like Clojure functions, the Java method's name, parent class, arglists (for overloads), source file, and line number are returned.

The accompanying PR for CIDER is 537.

@gtrak
Copy link
Contributor

gtrak commented Apr 24, 2014

This looks awesome. Can't wait to try it out.

@gtrak
Copy link
Contributor

gtrak commented Apr 24, 2014

Build is failing, this still doesn't solve the problem of adding the sources artifacts to the classpath. We'd need pomegranate for that, I think, and the lein plugin might have to do some magic coordination behind the scenes if this is to be made automatic.

@gtrak
Copy link
Contributor

gtrak commented Apr 24, 2014

I think we can grab maven artifact info from manifest of the jar using some classloader hacks on the class in question, then it would be trivial to add a "sources" classifier and download things on demand with pomegranate.

http://stackoverflow.com/questions/2712970/how-to-get-maven-artifact-version-at-runtime

@jeffvalk
Copy link
Contributor Author

Hmm. The code doesn't attempt to inject the Clojure sources artifacts to the classpath -- it leaves that to lein at launch time. No trickery should be necessary. Does the CI server respect the :repositories key in project.clj? In particular a dev dependency on the "1.5.2-SNAPSHOT" :sources jar from the "snapshots" repo is used as a workaround to CLJ-1161. The tests that are failing indicate that the "1.5.2-SNAPSHOT" sources jar isn't on the classpath.

@gtrak
Copy link
Contributor

gtrak commented Apr 24, 2014

Ah, if we can get the build to pass, automating sources could just be an added feature. Eclipse does it, I always found it cool :-).

@jeffvalk
Copy link
Contributor Author

Agreed! I like when my tools to the work for me. :-)

To use Pomegranate to grab source artifacts automagically, there are a few wrinkles though:

  1. If we do go that route, it would depend on CLJ-1161 getting fixed.
  2. I don't know if the JDK sources could be pulled this way, as they live outside of the lein/maven ecosystem, and may be managed by a distro's package manager, etc.

FWIW, the add-classpath! function currently uses dynapath in exactly the same way the Pomegranate does to address the second point. It just doesn't download the sources for you.

Clean up Java source file resolution.

Use ASM EmptyVisitor stubs for ClassVisitor/MethodVisitor.

Move line number distinctness check from class fn to method fn.

Also, add method return type to method info.

Use classpath to resolve JDK sources.

Update info middleware and add tests for Java info.

Add Java method info test for info middleware.

Use explicit ASM dependency instead of Clojure's.

Clojure 1.6 bundles ASM 4.0, which has breaking API changes from the
3.x releases bundled with previous versions of Clojure. To support both
multiple Clojure releases, we'll specify our dependency ASM version explicitly.

Resolve top-level .java file for nested classes.

Use snapshot builds for sources jar (workaround for CLJ-1161).

Update travis test script to use dev profile.
@jeffvalk jeffvalk closed this Apr 25, 2014
@@ -1,4 +1,5 @@
language: clojure
script: lein2 with-profile dev test
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests all pass. The :dev dependencies just weren't being added to the classpath for the Travis CI build.

@jeffvalk jeffvalk reopened this Apr 25, 2014
@bbatsov
Copy link
Member

bbatsov commented Apr 25, 2014

👍

bbatsov added a commit that referenced this pull request Apr 25, 2014
Add Java class and method resolution to info middleware.
@bbatsov bbatsov merged commit 66913e8 into clojure-emacs:master Apr 25, 2014
dpsutton pushed a commit to dpsutton/cider-nrepl that referenced this pull request Feb 14, 2019
I assumed it was derived from the `docs_dir`, it seems it's set
by default to `edit/master/docs/`.

More details - https://www.mkdocs.org/user-guide/configuration/#edit_uri
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants