HaRe-0.7.2.6: the Haskell Refactorer.

Safe HaskellNone

Language.Haskell.Refact.Utils.Utils

Contents

Synopsis

Managing the GHC / project environment

getModuleGhc :: FilePath -> RefactGhc ()Source

Once the module graph has been loaded, load the given module into the RefactGhc monad TODO: relax the equality test, if the file is loaded via cabal it may have a full filesystem path.

parseSourceFileGhc :: FilePath -> RefactGhc ()Source

Parse a single source file into a GHC session

activateModule :: TargetModule -> RefactGhc ModSummarySource

In the existing GHC session, put the requested TypeCheckedModule into the RefactGhc Monad, after ensuring that its originating target is the currently loaded one

getModuleDetails :: ModSummary -> RefactGhc ()Source

In the existing GHC session, put the requested TypeCheckedModule into the RefactGhc monad

The bits that do the work

runRefacSessionSource

Arguments

:: RefactSettings 
-> Cradle

Identifies the surrounding project

-> RefactGhc [ApplyRefacResult]

The computation doing the refactoring. Normally created via applyRefac

-> IO [FilePath] 

Manage a whole refactor session. Initialise the monad, load the whole project if required, and then apply the individual refactorings, and write out the resulting files.

It is intended that this forms the umbrella function, in which applyRefac is called

applyRefacSource

Arguments

:: RefactGhc a

The refactoring

-> RefacSource

where to get the module and toks

-> RefactGhc (ApplyRefacResult, a) 

Apply a refactoring (or part of a refactoring) to a single module

refactDone :: [ApplyRefacResult] -> BoolSource

Returns True if any of the results has its modified flag set

type ApplyRefacResult = ((FilePath, Bool), ([Line PosToken], [PosToken], RenamedSource))Source

The result of a refactoring is the file, a flag as to whether it was modified, the updated token stream, and the updated AST type ApplyRefacResult = ((FilePath, Bool), ([Ppr],[PosToken], GHC.RenamedSource))

updateSource

Arguments

:: Update t t1 
=> t

The syntax phrase to be updated.

-> t

The new syntax phrase.

-> t1

The contex where the old syntax phrase occurs.

-> RefactGhc t1

The result.

Update the occurrence of one syntax phrase in a given scope by another syntax phrase of the same type

fileNameToModName :: FilePath -> RefactGhc ModuleNameSource

From file name to module name.

getModuleName :: ParsedSource -> Maybe (ModuleName, String)Source

Extract the module name from the parsed source, if there is one

clientModsAndFiles :: ModuleName -> RefactGhc [([FilePath], ModSummary)]Source

Return the client modules and file names. The client modules of module, say m, are those modules which directly or indirectly import module m.

serverModsAndFiles :: GhcMonad m => ModuleName -> m [ModSummary]Source

Return the server module and file names. The server modules of module, say m, are those modules which are directly or indirectly imported by module m. This can only be called in a live GHC session TODO: make sure this works with multiple targets. Is that needed? No?