You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Provide all format suggestions in AlternatFormat Code Action (#2790)
* Insert Language Extensions when required
- Add new function that converts a NextPragmaInfo (identifies the
location to insert a new Pragma) into an Insertion that will insert
the new Extension
- Provide all format choices instead of only currently active extensions
* Update Test Suite
* Update Documentation
* Miscellaneous Cleanup
* Push extraneous functions into where bindings
* Remove unneeded logging
* Add Haskell2010 pragma to fix 9.2 tests
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Copy file name to clipboardExpand all lines: plugins/hls-alternate-number-format-plugin/README.md
+7-11
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
The alternate number format plugin provides alternative formatting for Numeric Literals in source code.
4
4
These can be any numeric literal such as `123`, `0x45` or any of the other numeric formats.
5
-
The plugin is context aware and will provide suggestions based on currently active GHC extensions.
5
+
The Code Action will provide all possible formatting suggestions (and when required insert the associated Language Extension)
6
6
7
7
## Setup
8
8
@@ -22,18 +22,10 @@ The plugin requires no extra setup to work. Simply place your cursor on top of a
22
22
The plugin is relatively simple, it traverses a files source contents using the GHC API. As it encounters Literals (of the type `HsExpr` with the constructor of either `HsLit` or `HsOverLit`), it will construct an internal `Literal` datatype that has additional information for use to generate suggestions.
23
23
Currently, the traversal is done in the file, `Literal.hs`, using the package [SYB](https://hackage.haskell.org/package/syb) for most of the heavy lifting.
24
24
25
-
The plugin extends on top of SYB as the traversal done by basic combinators is not perfect. For whatever reason, when starting at the root `ParsedModule` the SYB traversal ignores Pattern Binds (`LPat GhcPs`). As a result, a combinator was created to match on TWO separate underlying types to dispatch on.
26
-
27
-
To generate suggestions, the plugin leverages the `Numeric` package which provides a multitude of conversion functions to and from strings/numerics. The only slight change is the addition of extra work when using `NumDecimals` extension. The plugin will attempt to generate 3 choices for the user (this choice is not given for `Fractional` numerics).
25
+
To generate suggestions, the plugin leverages the `Numeric` package which provides a multitude of conversion functions to and from strings/numerics.
28
26
29
27
### Known Quirks
30
-
- Currently (and probably inefficiently), a Set is used as general accumulator for all Literals being captured. This is because again, through the intricacies of using SYB, we somehow will traverse Source Text multiple times and collect duplicate literals.
31
-
32
-
- In the Test Suite, we are required to be explicit in where our `codeActions` will occur. Otherwise, a simple call to `getAllCodeActions` will not work, for whatever reason, there is not enough time to generate the code actions.
33
-
34
-
-`PrimLiterals` are currently ignored. GHC API does not attach Source Text to Primitive Literal Nodes. As such these are ignored in the plugin.
35
-
36
-
- Similarly, anything that produces a bad Source Span (i.e. can't be easily replaced by an edit) is ignored as well.
28
+
- Anything that produces a bad Source Span (i.e. can't be easily replaced by an edit) is ignored as well.
37
29
38
30
## Changelog
39
31
### 1.0.0.0
@@ -48,3 +40,7 @@ To generate suggestions, the plugin leverages the `Numeric` package which provid
0 commit comments