clojure-lsp / clojure-lsp

Clojure & ClojureScript Language Server (LSP) implementation

Home Page:https://clojure-lsp.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Java imports code action breaks namespace form

armed opened this issue · comments

Describe the bug
In some cases import java package code action breaks :import section of a ns form. I believe it happens when a new package's path matches to one which already imported. E.g. java.awt.event and java.awt.<something>.

To Reproduce
Steps to reproduce the behavior:

  1. assume following ns declaration:
(ns my.namespace
  (:import [java.awt.event ActionEvent]))
  
;; ActionEvent is used somewhere in the code
  1. Add a new java class usage Robot.
(def robot (Robot.))
  1. Execute code action which suggests to add java.awt.Robot to imports declaration
  2. Form becomes broken:
(ns my.namespace
  (:import [[java.awt Robot event] ActionEvent]))

Expected behavior
A form should look like this:

(ns my.namespace
  (:import [java.awt.event ActionEvent]
           [java.awt Robot]))