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

clean-ns removes imported inner classes #332

Closed
mtnygard opened this issue Apr 26, 2016 · 5 comments
Closed

clean-ns removes imported inner classes #332

mtnygard opened this issue Apr 26, 2016 · 5 comments
Labels
Milestone

Comments

@mtnygard
Copy link

mtnygard commented Apr 26, 2016

Expected behavior

When an (:import) form refers to several inner classes that are used in my namespace
and I run a cljr-clean-ns, I expect clean-ns to leave the import alone.

Actual behavior

In the following ns form, the classes were generated from protocol buffer definitions. These are static inner classes.

(ns editor.gui.visual-node
  (:import
       [com.dynamo.gui.proto Gui$NodeDesc$AdjustMode Gui$NodeDesc$XAnchor Gui$NodeDesc$BlendMode Gui$NodeDesc$Pivot Gui$NodeDesc$YAnchor]))

After clean-ns, I am left with the following:

(ns editor.gui.visual-node
  (:import com.dynamo.gui.proto.Gui))

This is not correct, because an import of the enclosing class does not make aliases for all the inner classes.

Steps to reproduce the problem

Start with an empty namespace. Add imports of inner classes. Run cljr-clean-ns.

Environment & Version information

clj-refactor.el version information

2.2.0

CIDER version information

CIDER 0.12.0
Clojure 1.8.0
nREPL 0.2.12

Leiningen or Boot version

Leiningen 2.6.1 on Java 1.8.0_45 Java HotSpot(TM) 64-Bit Server VM

Emacs version

GNU Emacs 24.5.1 (x86_64-apple-darwin14.3.0, NS apple-appkit-1347.57) of 2015-05-28 on coil.local

Operating system

OS X 10.11 "El Capitan"

@expez expez added the bug label Apr 27, 2016
@expez
Copy link
Member

expez commented Apr 27, 2016

Thanks for the excellent bug report!

@aiba
Copy link
Contributor

aiba commented Jan 15, 2017

Is it possible we had a regression on this? I'm noticing the same behavior, cljr-clean-ns is removing imports of inner classes.

My test case:

(ns playground.test
  (:import [java.awt.geom Line2D$Double]))

(defn foo []
  (Line2D$Double. 0 0 5 5))

Running cljr-clean-ns on the above file changes it to:

(ns playground.test
  (:import java.awt.geom.Line2D))

(defn foo []
  (Line2D$Double. 0 0 5 5))

Which does not compile because the reference to the inner class was removed.

clj-refactor 2.3.0-SNAPSHOT (package: 20161223.1457), refactor-nrepl 2.3.0-SNAPSHOT
CIDER 0.15.0snapshot (package: 20170104.1330)
Clojure 1.8.0
GNU Emacs 25.1.1 (x86_64-apple-darwin13.4.0, Carbon Version 157 AppKit 1265.21) of 2016-11-05

@expez
Copy link
Member

expez commented Jan 16, 2017

The tests are still passing, and the code hasn't been touched since, ut I guess it's possible.

I'll have a look later.

@benedekfazekas
Copy link
Member

fix deployed to clojars

@csdrane
Copy link

csdrane commented Jul 24, 2017

I'm running the latest version, 2.3.1, and still seem to be experiencing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants