Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Baimetov authored and Greg Baimetov committed Oct 11, 2024
1 parent fbe4814 commit 784c4dd
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/StaticLS/IDE/Completion.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE MultiWayIf #-}

module StaticLS.IDE.Completion (
Expand Down Expand Up @@ -136,12 +135,12 @@ getUnqualifiedImportCompletions cx = do
completions <- getCompletionsForMods $ (.mod.text) <$> unqualifiedImports
pure $ fmap textCompletion completions

-- Why don't we need the text for this?
getLangextCompletions :: Text -> StaticLsM [Completion]
getLangextCompletions txt = do
getLangextCompletions _ = do
pure $ (textCompletion <$> (allExtensions <> ["LANGUAGE"]))

Check warning on line 141 in src/StaticLS/IDE/Completion.hs

View workflow job for this annotation

GitHub Actions / hlint

Suggestion in getLangextCompletions in module StaticLS.IDE.Completion: Redundant $ ▫︎ Found: "pure $ (textCompletion <$> (allExtensions <> [\"LANGUAGE\"]))" ▫︎ Perhaps: "pure (textCompletion <$> (allExtensions <> [\"LANGUAGE\"]))"


-- TODO add LanguageExtensionMode
data CompletionMode
= ImportMode !(Maybe Text)
| HeaderMode !Text
Expand Down Expand Up @@ -177,7 +176,7 @@ getImportPrefix cx sourceRope hs = do
Just $ fst <$> modPrefix
_ -> Nothing


-- TODO: recognize headers properly
getLangextPrefix :: Context -> Rope -> H.Haskell -> Maybe Text
getLangextPrefix cx sourceRope hs = do
let lineCol = cx.lineCol
Expand All @@ -187,15 +186,11 @@ getLangextPrefix cx sourceRope hs = do
let (_rest, extPrefix) = Maybe.fromMaybe ("", "") $ TextUtils.splitOnceEnd " " line
let dyn = AST.getDynNode hs
let pragma = AST.getDeepestContaining @Haskell.Pragma posRange dyn
let header = AST.getDeepestContaining @Haskell.Header posRange dyn
let isInPragma = Maybe.isJust pragma
let isInHeader = Maybe.isJust header
if

Check warning on line 190 in src/StaticLS/IDE/Completion.hs

View workflow job for this annotation

GitHub Actions / hlint

Warning in getLangextPrefix in module StaticLS.IDE.Completion: Redundant multi-way if ▫︎ Found: "if | isInPragma && extPrefix /= \"\" -> Just extPrefix\n | otherwise -> Nothing" ▫︎ Perhaps: "(if isInPragma && extPrefix /= \"\" then Just extPrefix else Nothing)"
| isInPragma {- && isInHeader -} && extPrefix /= "" -> Just extPrefix
| isInPragma && extPrefix /= "" -> Just extPrefix
| otherwise -> Nothing

-- TODO return LanguageExtensionMode when appropriate



getCompletionMode :: Context -> StaticLsM CompletionMode
Expand Down

0 comments on commit 784c4dd

Please sign in to comment.