Skip to content

Commit

Permalink
Sort imported element lists on Organize imports (#89)
Browse files Browse the repository at this point in the history
- Changed:
  - `Organize imports` can now also sort imported element lists (closes: #86):
    When sorting import declaration if new configuration options `"haskutil.sortImportedElementLists"` is set to `true` (default value)
  - An option to place operators at the end of imported element lists (closes: #88):
    When inserting new elements via `Add import` or sorting imported elements when via `Organize imports` operators can now be optionally placed after other type of elements, i.e. after functions, constructors or types.  
    This behavior is controlled via new configuration setting `"haskutil.placeOperatorsAfterFunctions"` which is set to `false` by
default
  - Switch to [c8](https://github.com/bcoe/c8) for code coverage (fixes: #87)
  • Loading branch information
EduardSergeev committed Jun 23, 2024
2 parents 3479e69 + 42bd3df commit b8e60d2
Show file tree
Hide file tree
Showing 13 changed files with 566 additions and 1,387 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:

metrics:
runs-on: ubuntu-latest
env: { CODE_VERSION: 1.48.0, DISPLAY: ':99.0', GHC: 9.4.5 }
env: { CODE_VERSION: 'stable', DISPLAY: ':99.0', GHC: 9.4.5 }
steps:
- uses: actions/checkout@v4

Expand Down
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
# Change Log
All notable changes to the "Haskutil" extension will be documented in this file.


## [0.14.0] - 2024-06-23
### Added
* `Organize imports` now also sorts imported element lists ([#86](https://github.com/EduardSergeev/vscode-haskutil/issues/86)):
When sorting import declaration if `"haskutil.sortImportedElementLists"` is set to `true` (default value)
* An option to place operators at the end of imported element lists [#88](https://github.com/EduardSergeev/vscode-haskutil/issues/88):
When inserting new elements via `Add import` or sorting imported elements via `Organize imports` operators can now be placed after other type of elements, i.e. after functions, constructors or types.
This behavior is controlled via new configuration setting `"haskutil.placeOperatorsAfterFunctions"` which is set to `false` by default
### Changed
* Switch to [c8](https://github.com/bcoe/c8) for code coverage (fix [#87](https://github.com/EduardSergeev/vscode-haskutil/issues/87))


## [0.13.3] - 2024-06-19
### Fixed:
### Fixed
* `Add import` action's handling of operators containing `.` (dot)([#80](https://github.com/EduardSergeev/vscode-haskutil/issues/80)):
Previously no quick fix action was emitted for such operators (e.g. `(.&.)` or `(.=)`)
* `Add import` action's handling of names containing `'` (single quote) ([#81](https://github.com/EduardSergeev/vscode-haskutil/issues/81)):
Expand Down
5 changes: 5 additions & 0 deletions input/after/ImportProvider.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Control.Arrow ((>>>))
import Data.Bits ((.&.))
import Data.Char ( isDigit )
import Data.List (foldl', sort, tails)
import Data.Maybe

Expand All @@ -18,3 +19,7 @@ escaped =
dot :: Int
dot =
42 .&. 1

existing :: Char -> Bool
existing =
isDigit
4 changes: 2 additions & 2 deletions input/after/OrganizeImportProvider.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import Control.Monad
import qualified Data.ByteString.Lazy as M
import Data.List
import Data.Maybe (
Maybe,
Maybe,
listToMaybe
)
import Prelude (Ord, ($), (.))
import Prelude (($), (.), Ord)
import System.IO


Expand Down
5 changes: 5 additions & 0 deletions input/before/ImportProvider.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Data.Char ( )

foo :: Ord a => [a] -> Maybe [a]
foo xs =
Expand All @@ -14,3 +15,7 @@ escaped =
dot :: Int
dot =
42 .&. 1

existing :: Char -> Bool
existing =
isDigit
6 changes: 3 additions & 3 deletions input/before/OrganizeImportProvider.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ module Main where
-- Some comment
import System.IO
import Data.Maybe (
Maybe,
listToMaybe
listToMaybe,
Maybe
)
import Data.List
import qualified Data.ByteString.Lazy as M
import Prelude (Ord, ($), (.))
import Prelude ((.), Ord, ($))
import Control.Monad


Expand Down
2 changes: 1 addition & 1 deletion input/before/UnusedImportProvider.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Data.List (sort, tails)
import Data.Maybe
import Data.Monoid (All(..), Any(getAny), Product(getProduct), Sum(..))
import Data.Monoid (All (..), Any(getAny), Product(getProduct), Sum(..), Any(..), First(..))

foo :: Ord a => [a] -> [a]
foo xs =
Expand Down
Loading

0 comments on commit b8e60d2

Please sign in to comment.