HaRe 0.7.2.1 → 0.7.2.2
raw patch · 6 files changed
+73/−14 lines, 6 filesdep ~ghc-mod
Dependency ranges changed: ghc-mod
Files
- ChangeLog +5/−0
- HaRe.cabal +9/−7
- src/Language/Haskell/Refact/Refactoring/Renaming.hs +1/−1
- src/Language/Haskell/Refact/Utils/LocUtils.hs +7/−1
- src/Language/Haskell/Refact/Utils/Monad.hs +3/−3
- src/Language/Haskell/Refact/Utils/TypeUtils.hs +48/−2
ChangeLog view
@@ -1,3 +1,8 @@+2014-04-03 v0.7.2.2+ * Fix renaming so that it also renames types in the export list of+ a module+ * revert to ghc-mod >= 4.0, with note that FFI exports can't+ currently be processed 2014-04-01 v0.7.2.1 * limit ghc-mod to <= 3.1.7, new version 4.0 does not deal with FFI exports. This does not stop ghc-mod >= 4.0 being used in the
HaRe.cabal view
@@ -1,5 +1,5 @@ Name: HaRe-Version: 0.7.2.1+Version: 0.7.2.2 Author: Chris Brown, Huiqing Li, Simon Thompson, Alan Zimmerman Maintainer: Alan Zimmerman Stability: Alpha@@ -29,6 +29,8 @@ The renaming refactoring seems reasonably reliable, as does lifting and demoting .+ At the moment parsing of any file with FFI exports will fail.+ . Synopsis: the Haskell Refactorer. Category: Development, Refactoring@@ -52,8 +54,8 @@ , ghc-paths , ghc-prim , ghc-syb-utils- -- , ghc-mod >= 4.0- , ghc-mod >= 3.1.6 && <= 3.1.7+ , ghc-mod >= 4.0+ -- , ghc-mod >= 3.1.6 && <= 3.1.7 -- , lens , mtl , old-time@@ -119,8 +121,8 @@ , ghc-paths , ghc-prim , ghc-syb-utils- -- , ghc-mod >= 4.0- , ghc-mod >= 3.1.6 && <= 3.1.7+ , ghc-mod >= 4.0+ -- , ghc-mod >= 3.1.6 && <= 3.1.7 -- , lens , mtl , old-time@@ -171,8 +173,8 @@ , ghc-paths == 0.1.* , ghc-prim , ghc-syb-utils- -- , ghc-mod >= 4.0- , ghc-mod >= 3.1.6 && <= 3.1.7+ , ghc-mod >= 4.0+ -- , ghc-mod >= 3.1.6 && <= 3.1.7 , hspec , mtl , old-time
src/Language/Haskell/Refact/Refactoring/Renaming.hs view
@@ -59,7 +59,7 @@ getModuleGhc fileName renamed <- getRefactRenamed parsed <- getRefactParsed- -- logm $ "comp:renamed=" ++ (SYB.showData SYB.Renamer 0 renamed) -- ++AZ+++ logm $ "comp:renamed=" ++ (SYB.showData SYB.Renamer 0 renamed) -- ++AZ++ -- logm $ "comp:parsed=" ++ (SYB.showData SYB.Parser 0 parsed) -- ++AZ++ modu <- getModule
src/Language/Haskell/Refact/Utils/LocUtils.hs view
@@ -28,7 +28,7 @@ isNestedComment-},isMultiLineComment {-,isOpenBracket,isCloseBracket, -} ,isOpenSquareBracket,isCloseSquareBracket {- ,isOpenBrace,isConid, isLit,isWhereOrLet,isWhere,isLet-},isIn {- ,isCase,isDo,isIf,isForall,- isHiding,isModule-} ,isComma {-,isEqual,isLambda,isIrrefute -},isBar --,isMinus,+ isHiding,isModule-} ,isComma, isOpenParen {-,isEqual,isLambda,isIrrefute -},isBar --,isMinus, ,endsWithNewLn,startsWithNewLn,hasNewLn {- ,startsWithEmptyLn, lastNonSpaceToken,firstNonSpaceToken -} ,compressPreNewLns,compressEndNewLns @@ -221,6 +221,12 @@ isComma ((GHC.L _ t),_s) = case t of GHC.ITcomma -> True _ -> False++isOpenParen :: PosToken -> Bool+isOpenParen ((GHC.L _ t),_s) = case t of+ GHC.IToparen -> True+ _ -> False+ {- isEqual (t,(_,s)) = t==Reservedop && s=="=" isLambda (t,(_,s)) = t==Reservedop && s=="\\"
src/Language/Haskell/Refact/Utils/Monad.hs view
@@ -235,8 +235,8 @@ -- getCabalAllTargets :: Cradle -> PackageDescription -> IO ([FilePath],[FilePath],[FilePath],[FilePath]) getCabalAllTargets cradle cabal = do currentDir <- getCurrentDirectory- let cabalDir = gfromJust "getCabalAllTargets" (cradleCabalDir cradle)- -- let cabalDir = cradleRootDir cradle+ -- let cabalDir = gfromJust "getCabalAllTargets" (cradleCabalDir cradle)+ let cabalDir = cradleRootDir cradle setCurrentDirectory cabalDir @@ -296,7 +296,7 @@ loadTarget :: [FilePath] -> RefactGhc () loadTarget targetFiles = do setTargetFiles targetFiles- checkSlowAndSet+ -- checkSlowAndSet void $ GHC.load GHC.LoadAllTargets -- ---------------------------------------------------------------------
src/Language/Haskell/Refact/Utils/TypeUtils.hs view
@@ -4169,14 +4169,60 @@ #endif renameHsTyVarBndr x = return x + -- ---------------------------------+ renameLIE :: (GHC.LIE GHC.Name) -> RefactGhc (GHC.LIE GHC.Name) renameLIE (GHC.L l (GHC.IEVar n)) | (GHC.nameUnique n == GHC.nameUnique oldPN) = do- logm $ "renamePNworker:renameLIE at :" ++ (showGhc l)+ -- logm $ "renamePNworker:renameLIE.IEVar at :" ++ (showGhc l) worker useQual l Nothing return (GHC.L l (GHC.IEVar newName))- renameLIE x = return x++ renameLIE (GHC.L l (GHC.IEThingAbs n))+ | (GHC.nameUnique n == GHC.nameUnique oldPN)+ = do+ -- logm $ "renamePNworker:renameLIE.IEThingAbs at :" ++ (showGhc l)+ worker useQual l Nothing+ return (GHC.L l (GHC.IEThingAbs newName))++ renameLIE (GHC.L l (GHC.IEThingAll n))+ | (GHC.nameUnique n == GHC.nameUnique oldPN)+ = do+ -- logm $ "renamePNworker:renameLIE.IEThingAll at :" ++ (showGhc l)+ worker useQual l Nothing+ return (GHC.L l (GHC.IEThingAll newName))++ -- TODO: check inside the ns here too+ renameLIE (GHC.L l (GHC.IEThingWith n ns))+ | (GHC.nameUnique n == GHC.nameUnique oldPN)+ = do+ logm $ "renamePNworker:renameLIE.IEThingWith at :" ++ (showGhc l)+ worker useQual l Nothing+ return (GHC.L l (GHC.IEThingWith newName ns))+ | any (\nn -> (GHC.nameUnique nn == GHC.nameUnique oldPN)) ns+ = do+ -- We have to find the right token, no locations to help+ toks <- getToksForSpan l+ -- find the opening parenthesis+ let (_,pt) = break isOpenParen $ filter (not . isWhiteSpaceOrIgnored) toks+ -- logm $ "renamePNworker:renameLIE.IEThingWith ns pt=" ++ (show pt)+ let nstoks = gtail "renamePNworker" pt+ let unQualOld = (GHC.occNameString $ GHC.getOccName oldPN)+ -- logm $ "renamePNworker:renameLIE.IEThingWith unquaOld=" ++ (show unQualOld)+ let _tok@(GHC.L lt _,_) = ghead "renamePNworker" $ filter (\tt -> tokenCon tt == showGhc oldPN || tokenCon tt == unQualOld) nstoks+ -- logm $ "renamePNworker:renameLIE.IEThingWith ns tok=" ++ (show _tok)+ logm $ "renamePNworker:renameLIE.IEThingWith ns at :" ++ (showGhc lt)+ worker useQual lt Nothing+ -- TODO: update ns+ return (GHC.L l (GHC.IEThingWith newName ns))++ renameLIE x = do+ -- logm $ "renamePNworker:renameLIE miss for :" ++ (showGhc x)+ return x++ -- ---------------------------------+ renameLPat :: (GHC.LPat GHC.Name) -> RefactGhc (GHC.LPat GHC.Name) renameLPat v@(GHC.L l (GHC.VarPat n))