@@ -8,11 +8,11 @@ import Data.List.NonEmpty (NonEmpty)
8
8
import qualified Data.List.NonEmpty as NE
9
9
import qualified Data.Map as Map
10
10
import qualified Data.Text as T
11
- import qualified Data.Text.Encoding as T
12
11
import Development.IDE as D
13
12
import qualified Development.IDE.Plugin.Completions.Types as Ghcide
14
13
import qualified Distribution.Fields as Syntax
15
14
import qualified Distribution.Parsec.Position as Syntax
15
+ import Ide.Plugin.Cabal.Completion.CabalFields
16
16
import Ide.Plugin.Cabal.Completion.Completer.Simple
17
17
import Ide.Plugin.Cabal.Completion.Completer.Snippet
18
18
import Ide.Plugin.Cabal.Completion.Completer.Types (Completer )
@@ -177,57 +177,3 @@ classifyFieldContext ctx cursor field
177
177
178
178
cursorColumn = Syntax. positionCol cursor
179
179
fieldColumn = Syntax. positionCol (getAnnotation field)
180
-
181
- -- ----------------------------------------------------------------
182
- -- Cabal-syntax utilities I don't really want to write myself
183
- -- ----------------------------------------------------------------
184
-
185
- -- | Determine the context of a cursor position within a stack of stanza contexts
186
- --
187
- -- If the cursor is indented more than one of the stanzas in the stack
188
- -- the respective stanza is returned if this is never the case, the toplevel stanza
189
- -- in the stack is returned.
190
- findStanzaForColumn :: Int -> NonEmpty (Int , StanzaContext ) -> (StanzaContext , FieldContext )
191
- findStanzaForColumn col ctx = case NE. uncons ctx of
192
- ((_, stanza), Nothing ) -> (stanza, None )
193
- ((indentation, stanza), Just res)
194
- | col < indentation -> findStanzaForColumn col res
195
- | otherwise -> (stanza, None )
196
-
197
- -- | Determine the field the cursor is currently a part of.
198
- --
199
- -- The result is said field and its starting position
200
- -- or Nothing if the passed list of fields is empty.
201
-
202
- -- This only looks at the row of the cursor and not at the cursor's
203
- -- position within the row.
204
- --
205
- -- TODO: we do not handle braces correctly. Add more tests!
206
- findFieldSection :: Syntax. Position -> [Syntax. Field Syntax. Position ] -> Maybe (Syntax. Field Syntax. Position )
207
- findFieldSection _cursor [] = Nothing
208
- findFieldSection _cursor [x] =
209
- -- Last field. We decide later, whether we are starting
210
- -- a new section.
211
- Just x
212
- findFieldSection cursor (x: y: ys)
213
- | Syntax. positionRow (getAnnotation x) <= cursorLine && cursorLine < Syntax. positionRow (getAnnotation y)
214
- = Just x
215
- | otherwise = findFieldSection cursor (y: ys)
216
- where
217
- cursorLine = Syntax. positionRow cursor
218
-
219
- type FieldName = T. Text
220
-
221
- getAnnotation :: Syntax. Field ann -> ann
222
- getAnnotation (Syntax. Field (Syntax. Name ann _) _) = ann
223
- getAnnotation (Syntax. Section (Syntax. Name ann _) _ _) = ann
224
-
225
- getFieldName :: Syntax. Field ann -> FieldName
226
- getFieldName (Syntax. Field (Syntax. Name _ fn) _) = T. decodeUtf8 fn
227
- getFieldName (Syntax. Section (Syntax. Name _ fn) _ _) = T. decodeUtf8 fn
228
-
229
- getOptionalSectionName :: [Syntax. SectionArg ann ] -> Maybe T. Text
230
- getOptionalSectionName [] = Nothing
231
- getOptionalSectionName (x: xs) = case x of
232
- Syntax. SecArgName _ name -> Just (T. decodeUtf8 name)
233
- _ -> getOptionalSectionName xs
0 commit comments