Skip to content

overloaded record dot plugin intial version (closes #3350) #3560

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

Merged
merged 22 commits into from
May 26, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
6d8bc5a
overloaded record dot plugin intial version (closes #3350)
joyfulmantis Apr 14, 2023
fcd749b
Added support to GHC 9.2, and updated documentation
joyfulmantis Apr 16, 2023
5013c69
Apply suggestions from Lei Zhu (July541)
joyfulmantis Apr 18, 2023
00e71fe
Use GHC2021 and updated gif
joyfulmantis Apr 18, 2023
1b78ce7
Fix test.yml formatting problem
joyfulmantis Apr 18, 2023
c8e84c6
Merge branch 'master' into master
joyfulmantis Apr 21, 2023
bf764a1
use coerce instead of unExt (from michaelpj)
joyfulmantis May 2, 2023
239737b
Merge branch 'master' into master
joyfulmantis May 2, 2023
3270e7a
Implements michaelpj code review suggestions
joyfulmantis May 2, 2023
25be42a
Collect records on lists instead of maybe
joyfulmantis May 3, 2023
3746332
Added documentation
joyfulmantis May 3, 2023
0b9d120
Reworded comments for spelling and clarity
joyfulmantis May 3, 2023
1363325
use useWithStale for the TypeCheck rule
joyfulmantis May 9, 2023
1f61243
Merge branch 'master' into master
joyfulmantis May 9, 2023
7a3bc3c
Merge branch 'master' into master
joyfulmantis May 16, 2023
d5b272a
Merge branch 'master' into overloaded-record-dot
joyfulmantis May 19, 2023
fcc52a9
Update version to conform with changes on master
joyfulmantis May 19, 2023
961bcaa
No longer depend on specific hls package versions
joyfulmantis May 19, 2023
5f77748
Fixed comments and line length issues
joyfulmantis May 22, 2023
bab5a71
Added test for HsExpanded expressions
joyfulmantis May 22, 2023
c0137ca
Merge branch 'master' into overloaded-record-dot
joyfulmantis May 22, 2023
a81cde7
Merge branch 'master' into overloaded-record-dot
joyfulmantis May 25, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,12 @@ jobs:
name: Test hls-retrie-plugin test suite
run: cabal test hls-retrie-plugin --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-retrie-plugin --test-options="$TEST_OPTS"

- if: matrix.test && matrix.ghc != '8.10.7' && matrix.ghc != '9.0.2'
name: Test hls-overloaded-record-dot-plugin test suite
run: cabal test hls-overloaded-record-dot-plugin --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-retrie-plugin --test-options="$TEST_OPTS"



test_post_job:
if: always()
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ packages:
./plugins/hls-explicit-fixity-plugin
./plugins/hls-explicit-record-fields-plugin
./plugins/hls-refactor-plugin
./plugins/hls-overloaded-record-dot-plugin

-- Standard location for temporary packages needed for particular environments
-- For example it is used in the project gitlab mirror to help in the MAcOS M1 build script
Expand Down
9 changes: 9 additions & 0 deletions docs/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,15 @@ Known limitations:

- Cross-module renaming requires all components to be indexed, which sometimes causes [partial renames in multi-component projects](https://github.com/haskell/haskell-language-server/issues/2193).

### Rewrite to overloaded record syntax

Provided by: `hls-overloaded-record-dot-plugin`

Code action kind: `refactor.rewrite`

Rewrites record selectors to use overloaded dot syntax

![Explicit Wildcard Demo](../plugins/hls-overloaded-record-dot-plugin/example.gif)
## Missing features

The following features are supported by the LSP specification but not implemented in HLS.
Expand Down
1 change: 1 addition & 0 deletions docs/support/plugin-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ For example, a plugin to provide a formatter which has itself been abandoned has
| `hls-refine-imports-plugin` | 2 | |
| `hls-stylish-haskell-plugin` | 2 | 9.6 |
| `hls-tactics-plugin` | 2 | 9.2, 9.4, 9.6 |
| `hls-overloaded-recrod-dot-plugin` | 2 | 8.10, 9.0 |
| `hls-haddock-comments-plugin` | 3 | 9.2, 9.4, 9.6 |
| `hls-stan-plugin` | 3 | 8.6, 9.0, 9.2, 9.4, 9.6 |
| `hls-retrie-plugin` | 3 | |
Expand Down
13 changes: 12 additions & 1 deletion haskell-language-server.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@ flag explicitFields
default: True
manual: True

flag overloadedRecordDot
description: Enable overloadedRecordDot plugin
default: True
manual: True

-- formatters

flag floskell
Expand Down Expand Up @@ -326,10 +331,15 @@ common explicitFields
build-depends: hls-explicit-record-fields-plugin ^>= 1.0
cpp-options: -DexplicitFields

common overloadedRecordDot
if flag(overloadedRecordDot) && (impl(ghc >= 9.2.0) || flag(ignore-plugins-ghc-bounds))
build-depends: hls-overloaded-record-dot-plugin ^>= 1.0
cpp-options: -Dhls_overloaded_record_dot

-- formatters

common floskell
if flag(floskell) && impl(ghc < 9.5)
if flag(floskell) && impl(ghc < 9.5)
build-depends: hls-floskell-plugin ^>= 1.0
cpp-options: -Dhls_floskell

Expand Down Expand Up @@ -387,6 +397,7 @@ library
, ormolu
, stylishHaskell
, refactor
, overloadedRecordDot

exposed-modules:
Ide.Arguments
Expand Down
5 changes: 5 additions & 0 deletions plugins/hls-overloaded-record-dot-plugin/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Revision history for hls-overloaded-record-dot-plugin

## 1.0.0.0 -- 2023-04-16

* First version.
30 changes: 30 additions & 0 deletions plugins/hls-overloaded-record-dot-plugin/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Copyright (c) 2023, Nathan Maxson

All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.

* Neither the name of Nathan Maxson nor the names of other
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
18 changes: 18 additions & 0 deletions plugins/hls-overloaded-record-dot-plugin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Explicit Record Fields Plugin

`hls-overloaded-record-dot-plugin` is a plugin to convert record selectors to record dot syntax in GHC 9.2 and above.


## Demo

![Convert Record Selector Demo](example.gif)


## Known limitations

hls-overloaded-record-dot-plugin currently only converts record selectors to the record dot syntax, and will not help you convert your record updaters to overloaded record update syntax.


## Change log
### 1.0.0.0
- Release
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
cabal-version: 3.0
name: hls-overloaded-record-dot-plugin
version: 1.0.0.0
synopsis: Overloaded record dot plugin for Haskell Language Server
description:
Please see the README on GitHub at <https://github.com/haskell/haskell-language-server#readme>
license: BSD-3-Clause
license-file: LICENSE
author: Nathan Maxson
maintainer: joyfulmantis@gmail.com
category: Development
build-type: Simple
extra-doc-files: CHANGELOG.md
extra-source-files:
test/testdata/**/*.hs

source-repository head
type: git
location: https://github.com/haskell/haskell-language-server

common warnings
ghc-options: -Wall

library
if impl(ghc < 9.2)
buildable: False
else
buildable: True
import: warnings
exposed-modules: Ide.Plugin.OverloadedRecordDot
build-depends:
, base >=4.16 && <5
, ghcide ^>=1.10
, hls-plugin-api ^>=1.6
, lsp
, lens
, hls-graph
, text
, syb
, transformers
, ghc-boot-th
, unordered-containers
, containers
hs-source-dirs: src
default-language: GHC2021

test-suite tests
if impl(ghc < 9.2)
buildable: False
else
buildable: True
import: warnings
default-language: GHC2021
type: exitcode-stdio-1.0
hs-source-dirs: test
main-is: Main.hs
build-depends:
, base
, filepath
, text
, hls-overloaded-record-dot-plugin
, lsp-test
, hls-test-utils

Loading