14
14
import Control.Monad.IO.Class
15
15
import Data.Maybe
16
16
import Data.Text qualified as T
17
- import Data.Text.Encoding (decodeASCII , decodeLatin1 )
17
+ import Data.Text.Encoding (decodeUtf8 )
18
18
import Development.IDE.Core.Rules
19
19
import Development.IDE.Core.Shake (IdeState (shakeExtras ), runIdeAction , useWithStaleFast )
20
20
import Development.IDE.Types.Location (toNormalizedFilePath' )
@@ -27,7 +27,7 @@ import Distribution.Fields.Field
27
27
import Distribution.Parsec.Position (Position )
28
28
import Ide.Plugin.Cabal.Completion.Types (ParseCabalFields (.. ), cabalPositionToLSPPosition )
29
29
import Ide.Plugin.Cabal.Orphans ()
30
- import Ide.Types
30
+ import Ide.Types ( PluginMethodHandler )
31
31
import Language.LSP.Protocol.Message qualified as LSP
32
32
import Language.LSP.Protocol.Types qualified as LSP
33
33
@@ -47,16 +47,16 @@ documentSymbolForField :: Field Position -> Maybe LSP.DocumentSymbol
47
47
documentSymbolForField (Field (Name pos fieldName) fieldLines) =
48
48
Just
49
49
(defDocumentSymbol range)
50
- { LSP. _name = decodeASCII fieldName,
51
- LSP. _kind = LSP. SymbolKind_Object ,
50
+ { LSP. _name = decodeUtf8 fieldName,
51
+ LSP. _kind = LSP. SymbolKind_Field ,
52
52
LSP. _children = Just $ mapMaybe documentSymbolForFieldLine fieldLines
53
53
}
54
54
where
55
- range = cabalPositionToLSPRange pos `addNameLengthToLSPRange` decodeASCII fieldName
55
+ range = cabalPositionToLSPRange pos `addNameLengthToLSPRange` decodeUtf8 fieldName
56
56
documentSymbolForField (Section (Name pos fieldName) sectionArgs fields) =
57
57
Just
58
58
(defDocumentSymbol range)
59
- { LSP. _name = decodeASCII fieldName,
59
+ { LSP. _name = decodeUtf8 fieldName,
60
60
LSP. _kind = LSP. SymbolKind_Object ,
61
61
LSP. _children =
62
62
Just
@@ -65,48 +65,51 @@ documentSymbolForField (Section (Name pos fieldName) sectionArgs fields) =
65
65
)
66
66
}
67
67
where
68
- range = cabalPositionToLSPRange pos `addNameLengthToLSPRange` decodeASCII fieldName
68
+ range = cabalPositionToLSPRange pos `addNameLengthToLSPRange` decodeUtf8 fieldName
69
69
70
70
documentSymbolForSectionArgs :: SectionArg Position -> Maybe LSP. DocumentSymbol
71
71
documentSymbolForSectionArgs (SecArgName pos identifier) =
72
72
Just
73
73
(defDocumentSymbol range)
74
- { LSP. _name = decodeLatin1 identifier,
74
+ { LSP. _name = decodeUtf8 identifier,
75
75
LSP. _kind = LSP. SymbolKind_Variable ,
76
76
LSP. _children = Nothing
77
77
}
78
78
where
79
- range = cabalPositionToLSPRange pos `addNameLengthToLSPRange` decodeASCII identifier
79
+ range = cabalPositionToLSPRange pos `addNameLengthToLSPRange` decodeUtf8 identifier
80
80
documentSymbolForSectionArgs (SecArgStr pos quotedString) =
81
81
Just
82
82
(defDocumentSymbol range)
83
- { LSP. _name = decodeLatin1 quotedString,
83
+ { LSP. _name = decodeUtf8 quotedString,
84
84
LSP. _kind = LSP. SymbolKind_Constant ,
85
85
LSP. _children = Nothing
86
86
}
87
87
where
88
- range = cabalPositionToLSPRange pos `addNameLengthToLSPRange` decodeASCII quotedString
88
+ range = cabalPositionToLSPRange pos `addNameLengthToLSPRange` decodeUtf8 quotedString
89
89
documentSymbolForSectionArgs (SecArgOther pos string) =
90
90
Just
91
91
(defDocumentSymbol range)
92
- { LSP. _name = decodeLatin1 string,
92
+ { LSP. _name = decodeUtf8 string,
93
93
LSP. _kind = LSP. SymbolKind_String ,
94
94
LSP. _children = Nothing
95
95
}
96
96
where
97
- range = cabalPositionToLSPRange pos `addNameLengthToLSPRange` decodeASCII string
97
+ range = cabalPositionToLSPRange pos `addNameLengthToLSPRange` decodeUtf8 string
98
98
99
99
documentSymbolForFieldLine :: FieldLine Position -> Maybe LSP. DocumentSymbol
100
100
documentSymbolForFieldLine (FieldLine pos line) =
101
101
Just
102
102
(defDocumentSymbol range)
103
- { LSP. _name = decodeLatin1 line, -- since there is no ascii invariant (?)
103
+ { LSP. _name = decodeUtf8 line,
104
104
LSP. _kind = LSP. SymbolKind_Field ,
105
- LSP. _children = Nothing -- can't delete even though the base case covers this (?)
105
+ LSP. _children = Nothing
106
106
}
107
107
where
108
- range = cabalPositionToLSPRange pos `addNameLengthToLSPRange` decodeASCII line
108
+ range = cabalPositionToLSPRange pos `addNameLengthToLSPRange` decodeUtf8 line
109
+
109
110
111
+ -- | Creates a single point LSP range
112
+ -- using cabal position
110
113
cabalPositionToLSPRange :: Position -> LSP. Range
111
114
cabalPositionToLSPRange pos = LSP. Range lspPos lspPos
112
115
where
0 commit comments