Skip to content

Commit f4d57a5

Browse files
committed
outline tests changes
1 parent d201493 commit f4d57a5

File tree

4 files changed

+56
-46
lines changed

4 files changed

+56
-46
lines changed

Diff for: plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/Outline.hs

+17-18
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
{-# LANGUAGE DuplicateRecordFields #-}
44
{-# LANGUAGE GADTs #-}
55
{-# LANGUAGE OverloadedStrings #-}
6-
{-# LANGUAGE RecordWildCards #-}
76
{-# LANGUAGE ViewPatterns #-}
87

98
module Ide.Plugin.Cabal.Outline where
@@ -26,8 +25,8 @@ import Ide.Plugin.Cabal.Completion.Types (ParseCabalFields (..),
2625
import Ide.Plugin.Cabal.Orphans ()
2726
import Ide.Types (PluginMethodHandler)
2827
import Language.LSP.Protocol.Message (Method (..))
29-
import qualified Language.LSP.Protocol.Types as LSP
3028
import Language.LSP.Protocol.Types (DocumentSymbol (..))
29+
import qualified Language.LSP.Protocol.Types as LSP
3130

3231

3332
moduleOutline :: PluginMethodHandler IdeState Method_TextDocumentDocumentSymbol
@@ -49,18 +48,18 @@ documentSymbolForField :: Field Position -> Maybe DocumentSymbol
4948
documentSymbolForField (Field (Name pos fieldName) _) =
5049
Just
5150
(defDocumentSymbol range)
52-
{ LSP._name = decodeUtf8 fieldName,
53-
LSP._kind = LSP.SymbolKind_Field,
54-
LSP._children = Nothing
51+
{ _name = decodeUtf8 fieldName,
52+
_kind = LSP.SymbolKind_Field,
53+
_children = Nothing
5554
}
5655
where
5756
range = cabalPositionToLSPRange pos `addNameLengthToLSPRange` decodeUtf8 fieldName
5857
documentSymbolForField (Section (Name pos fieldName) sectionArgs fields) =
5958
Just
6059
(defDocumentSymbol range)
61-
{ LSP._name = joinedName,
62-
LSP._kind = LSP.SymbolKind_Object,
63-
LSP._children =
60+
{ _name = joinedName,
61+
_kind = LSP.SymbolKind_Object,
62+
_children =
6463
Just
6564
(mapMaybe documentSymbolForField fields)
6665
}
@@ -92,13 +91,13 @@ addNameLengthToLSPRange (LSP.Range pos1 (LSP.Position line char)) name =
9291
(LSP.Position line (char + fromIntegral (T.length name)))
9392

9493
defDocumentSymbol :: LSP.Range -> DocumentSymbol
95-
defDocumentSymbol range = DocumentSymbol {..}
96-
where
97-
_detail = Nothing
98-
_deprecated = Nothing
99-
_name = ""
100-
_kind = LSP.SymbolKind_File
101-
_range = range
102-
_selectionRange = range
103-
_children = Nothing
104-
_tags = Nothing
94+
defDocumentSymbol range = DocumentSymbol
95+
{ _detail = Nothing
96+
, _deprecated = Nothing
97+
, _name = ""
98+
, _kind = LSP.SymbolKind_File
99+
, _range = range
100+
, _selectionRange = range
101+
, _children = Nothing
102+
, _tags = Nothing
103+
}

Diff for: plugins/hls-cabal-plugin/test/Outline.hs

+31-27
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ module Outline (
55
outlineTests
66
) where
77

8-
import qualified Ide.Plugin.Cabal.Outline as Outline
9-
import qualified Language.LSP.Protocol.Types as LSP
8+
import Ide.Plugin.Cabal.Outline (defDocumentSymbol)
109
import Test.Hls
1110
import Utils
1211

@@ -39,32 +38,37 @@ outlineTests =
3938
[sectionArgDocumentSymbol]
4039
]
4140
where
42-
fieldDocumentSymbol = (Outline.defDocumentSymbol (LSP.Range {_start = LSP.Position {_line = 0, _character = 0},
43-
_end = LSP.Position {_line = 0, _character = 8}}))
44-
{ LSP._name = "homepage",
45-
LSP._kind = LSP.SymbolKind_Field,
46-
LSP._children = Nothing
41+
fieldDocumentSymbol :: DocumentSymbol
42+
fieldDocumentSymbol = (defDocumentSymbol (Range {_start = Position {_line = 0, _character = 0},
43+
_end = Position {_line = 0, _character = 8}}))
44+
{ _name = "homepage",
45+
_kind = SymbolKind_Field,
46+
_children = Nothing
4747
}
48-
fieldLineDocumentSymbol = (Outline.defDocumentSymbol (LSP.Range {_start = LSP.Position {_line = 0, _character = 0},
49-
_end = LSP.Position {_line = 0, _character = 13}}))
50-
{ LSP._name = "cabal-version",
51-
LSP._kind = LSP.SymbolKind_Field,
52-
LSP._children = Nothing -- the values of fieldLine are removed from the outline
48+
fieldLineDocumentSymbol :: DocumentSymbol
49+
fieldLineDocumentSymbol = (defDocumentSymbol (Range {_start = Position {_line = 0, _character = 0},
50+
_end = Position {_line = 0, _character = 13}}))
51+
{ _name = "cabal-version",
52+
_kind = SymbolKind_Field,
53+
_children = Nothing -- the values of fieldLine are removed from the outline
5354
}
54-
sectionDocumentSymbol = (Outline.defDocumentSymbol (LSP.Range {_start = LSP.Position {_line = 0, _character = 2},
55-
_end = LSP.Position {_line = 0, _character = 15}}))
56-
{ LSP._name = "build-depends",
57-
LSP._kind = LSP.SymbolKind_Field,
58-
LSP._children = Nothing -- the values of fieldLine are removed from the outline
55+
sectionDocumentSymbol :: DocumentSymbol
56+
sectionDocumentSymbol = (defDocumentSymbol (Range {_start = Position {_line = 0, _character = 2},
57+
_end = Position {_line = 0, _character = 15}}))
58+
{ _name = "build-depends",
59+
_kind = SymbolKind_Field,
60+
_children = Nothing -- the values of fieldLine are removed from the outline
5961
}
60-
sectionArgDocumentSymbol = (Outline.defDocumentSymbol (LSP.Range {_start = LSP.Position {_line = 0, _character = 2},
61-
_end = LSP.Position {_line = 0, _character = 19}}))
62-
{ LSP._name = "if os ( windows )",
63-
LSP._kind = LSP.SymbolKind_Object,
64-
LSP._children = Just $ [sectionArgChildrenDocumentSymbol] }
65-
sectionArgChildrenDocumentSymbol = (Outline.defDocumentSymbol (LSP.Range {_start = LSP.Position {_line = 1, _character = 4},
66-
_end = LSP.Position {_line = 1, _character = 17}}))
67-
{ LSP._name = "build-depends",
68-
LSP._kind = LSP.SymbolKind_Field,
69-
LSP._children = Nothing
62+
sectionArgDocumentSymbol :: DocumentSymbol
63+
sectionArgDocumentSymbol = (defDocumentSymbol (Range {_start = Position {_line = 0, _character = 2},
64+
_end = Position {_line = 0, _character = 19}}))
65+
{ _name = "if os ( windows )",
66+
_kind = SymbolKind_Object,
67+
_children = Just $ [sectionArgChildrenDocumentSymbol] }
68+
sectionArgChildrenDocumentSymbol :: DocumentSymbol
69+
sectionArgChildrenDocumentSymbol = (defDocumentSymbol (Range {_start = Position {_line = 1, _character = 4},
70+
_end = Position {_line = 1, _character = 17}}))
71+
{ _name = "build-depends",
72+
_kind = SymbolKind_Field,
73+
_children = Nothing
7074
}

Diff for: test/testdata/schema/ghc98/default-config.golden.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"cabal": {
1212
"codeActionsOn": true,
1313
"completionOn": true,
14-
"diagnosticsOn": true
14+
"diagnosticsOn": true,
15+
"symbolsOn": true
1516
},
1617
"cabal-fmt": {
1718
"config": {

Diff for: test/testdata/schema/ghc98/vscode-extension-schema.golden.json

+6
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@
3535
"scope": "resource",
3636
"type": "boolean"
3737
},
38+
"haskell.plugin.cabal.symbolsOn": {
39+
"default": true,
40+
"description": "Enables cabal symbols",
41+
"scope": "resource",
42+
"type": "boolean"
43+
},
3844
"haskell.plugin.callHierarchy.globalOn": {
3945
"default": true,
4046
"description": "Enables callHierarchy plugin",

0 commit comments

Comments
 (0)