Skip to content

Commit aa5bb16

Browse files
committed
Remove qualified keyword from sorting imports
Such keyword isn't a thing in Purescript, it has instead syntax `import Foo as Bar`. I also checked VSCode purescript highlight mode, it also doesn't have `qualified` in among its sources.
1 parent 433b277 commit aa5bb16

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

purescript-sort-imports.el

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@
3232

3333
(defvar purescript-sort-imports-regexp
3434
(concat "^import[ ]+"
35-
"\\(qualified \\)?"
36-
"[ ]*\\(\"[^\"]*\" \\)?"
35+
"\\(\"[^\"]*\" \\)?"
3736
"[ ]*\\([A-Za-z0-9_.']*.*\\)"))
3837

3938
;;;###autoload
@@ -68,9 +67,8 @@ within that region."
6867

6968
(defun purescript-sort-imports-normalize (i)
7069
"Normalize an import, if possible, so that it can be sorted."
71-
(if (string-match purescript-sort-imports-regexp
72-
i)
73-
(match-string 3 i)
70+
(if (string-match purescript-sort-imports-regexp i)
71+
(match-string 2 i)
7472
i))
7573

7674
(defun purescript-sort-imports-collect-imports ()

tests/purescript-sort-imports-tests.el

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,23 @@ import B
4545
import B
4646
")))
4747
(should (with-temp-buffer
48-
(insert "import qualified A
48+
(insert "import A (A, B, C)
4949
import B
5050
")
5151
(goto-char (point-min))
5252
(purescript-sort-imports)
5353
(string= (buffer-string)
54-
"import qualified A
54+
"import A (A, B, C)
5555
import B
5656
")))
5757
(should (with-temp-buffer
58-
(insert "import qualified \"mtl\" A
58+
(insert "import A (mtl)
5959
import B
6060
")
6161
(goto-char (point-min))
6262
(purescript-sort-imports)
6363
(string= (buffer-string)
64-
"import qualified \"mtl\" A
64+
"import A (mtl)
6565
import B
6666
"))))
6767

@@ -116,8 +116,8 @@ import Data.Aeson.Types
116116
import Data.Aeson.Parser.Internal (decodeWith, decodeStrictWith,
117117
eitherDecodeWith, eitherDecodeStrictWith,
118118
jsonEOF, json, jsonEOF', json')
119-
import qualified Data.ByteString as B
120-
import qualified Data.ByteString.Lazy as L
119+
import Data.ByteString as B
120+
import Data.ByteString.Lazy as L
121121
")
122122
(goto-char (point-min))
123123
(purescript-sort-imports)
@@ -127,8 +127,8 @@ import Data.Aeson.Parser.Internal (decodeWith, decodeStrictWith,
127127
eitherDecodeWith, eitherDecodeStrictWith,
128128
jsonEOF, json, jsonEOF', json')
129129
import Data.Aeson.Types
130-
import qualified Data.ByteString as B
131-
import qualified Data.ByteString.Lazy as L
130+
import Data.ByteString as B
131+
import Data.ByteString.Lazy as L
132132
"))))
133133

134134
(provide 'purescript-sort-imports-tests)

0 commit comments

Comments
 (0)