Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Santiago Weight committed Nov 7, 2022
1 parent 7e06c77 commit 96cc578
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -514,11 +514,8 @@ insertAtStart' old newDecl = do
insertDeclAtStart _ d ds = d : ds

prependDeclToWhereDecls decl newWhereDecl = do
traceShowM "tag2"
ds <- balanceCommentsList =<< hsDecls decl
traceShowM "tag3"
let ds' = prependDecl (wrapDecl newWhereDecl) ds
traceShowM "tag4"
replaceDecls decl ds'

prependDecl :: LHsDecl GhcPs -> [LHsDecl GhcPs] -> [LHsDecl GhcPs]
Expand Down Expand Up @@ -559,8 +556,8 @@ prependDecl ldecl = \case
(L (SrcSpanAnn (EpAnn (Anchor d1Rss d1AncOp) d1Ann epaCs@(EpaCommentsBalanced [] _)) ss) d1) ->
let ld1' = L (SrcSpanAnn (EpAnn (Anchor d1Rss $ MovedAnchor $ DifferentLine 1 0) d1Ann epaCs) ss) d1
in (d1AncOp, ld1')
L (SrcSpanAnn EpAnnNotUsed _) _ -> trace "tag6" error "Unexpected EpAnnNotUsed"
ldecl' = setEntryDP ldecl (maybe (trace "tag7" error "what to do with UnchangedAnchor?") id $ getAnchorOpDp ancOp)
L (SrcSpanAnn EpAnnNotUsed _) _ -> error "Unexpected EpAnnNotUsed"
ldecl' = setEntryDP ldecl (maybe (error "what to do with UnchangedAnchor?") id $ getAnchorOpDp ancOp)

setAnchorDp :: Anchor -> DeltaPos -> Anchor
setAnchorDp (Anchor rss _) dp = Anchor rss (MovedAnchor dp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,6 @@ addToWhere (ParsedModule _ parsedSource _ _) range name _typ = bimap traceShowId
noLocA (Match newDeclMatchAnn (FunRhs (mkUnqual name) Prefix SrcStrict) [] grhss)
newDeclMg = MG NoExtField (L (noAnnSrcSpanDP0 declMatchSrcSpan) [newDeclMatch]) Generated
newDecl = (FunBind NoExtField (mkUnqual name) newDeclMg [])
traceShowM "tag1"
prependDeclToWhereDecls match (noLocA newDecl)
else pure match
let decl' = L locDecl (ValD xVal (FunBind xFunBind idFunBind mg' coreFunBind))
Expand Down
4 changes: 2 additions & 2 deletions plugins/hls-refactor-plugin/test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2380,8 +2380,8 @@ addFunctionArgumentTests =
addToWhereTests :: TestTree
addToWhereTests =
testGroup
"add_to_where"
[ testSession "insert_new_where" $ do
"add to where"
[ testSession "insert new where" $ do
let foo =
[ "module Foo where"
, ""
Expand Down

0 comments on commit 96cc578

Please sign in to comment.