fpco-api-1.1.0: Simple interface to the FP Complete IDE API.

Safe HaskellNone

FP.Server

Description

Main entry point to the server.

Synopsis

Documentation

runWithConfig :: Server b -> Config -> IO bSource

Run the given Server command with the config. Good for testing in the repl.

startServer :: Bool -> Server ()Source

Start the server.

acceptConnection :: Socket -> Server ()Source

Accept a connection on the given socket.

handleLine :: Handle -> Server ()Source

Handle a line of input.

handleMessage :: Handle -> Msg -> Server ()Source

Handle any incoming message from the client.

writeEmacsConfig :: Handle -> Either Text FayProjectId -> FilePath -> Server ()Source

Write out the .dir-locals.el file for the project.

downloadFiles :: Handle -> Either Text FayProjectId -> FilePath -> Server ()Source

Download all files in the project, overwriting any local copies.

hoogleDb :: Handle -> FayProjectId -> Text -> Server ()Source

Hoogle search whole database.

hoogleIdent :: Handle -> FayProjectId -> String -> Text -> Server ()Source

Hoogle search for an identifier in a module.

autoComplete :: Handle -> FayProjectId -> FilePath -> Text -> Server ()Source

Autocomplete the given prefix replying with a list of completions.

getDefinition :: Handle -> FayProjectId -> FilePath -> FilePath -> Int -> Int -> Int -> Int -> Server ()Source

Get the definition location of the identifier at the given span.

makeModuleId :: FayModuleId -> ModuleIdSource

Print a package:module pair.

typeInfo :: Handle -> FayProjectId -> String -> Int -> Int -> Int -> Int -> Server ()Source

Get type info of span.

saveTheModule :: Handle -> FayProjectId -> FilePath -> FilePath -> Server ()Source

Save the given module.

checkModule :: Handle -> FayProjectId -> FilePath -> FilePath -> FilePath -> Server ()Source

Check the given module. Necessary for flycheck.

reply :: (ToJSON a, Show a) => Handle -> a -> Server ()Source

Reply with the given value.

close :: Handle -> Server ()Source

Close the given handle.

waitSource

Arguments

:: FayProjectId

The project to poll on.

-> Callback

Take the message or pass it back.

-> Server () 

Start poller if there isn't already one running for the given project, and in any case add the given callback to the list. This blocks on the result.

removePoller :: FayProjectId -> Server ()Source

Remove a poller from the polling list and any broadcast callbacks.

poll :: FayProjectId -> Server ()Source

Poll for new messages and apply any queued callbacks to them.

getIPI :: FayProjectId -> Server ()Source

Get initial project information.

applyCallbacks :: [Callback] -> (Maybe Int, RunnerMessage) -> Server [Callback]Source

Applies the given callbacks to the given message. Returns a new list of callbacks. If any of the callbacks are now done, they will be removed from the list.

updateFileContents :: MVar (Map FilePath FayTutorialToken) -> FayProjectId -> FilePath -> FilePath -> Server ()Source

Update the contents of the given file from the server.

updateToken :: MVar (Map FilePath FayTutorialToken) -> FilePath -> FilePath -> FayTutorialToken -> Server ()Source

Update the token of the given file.

withTokens :: (MVar (Map FilePath FayTutorialToken) -> Server a) -> Server aSource

Do something exclusively with tokens. Due to the fact that flychecking and buffer saving *can* occur simultaneously from Emacs, we don't want those two racing save capabilities.

On the other hand it doesn't matter what order they occur because they'll be saving the same content. So we simply require that any command that uses module tokens needs to happen in an exclusion.

getFayProjectId :: Either Text FayProjectId -> Server FayProjectIdSource

Get the project ID from either a URL or a project ID.

stripSlash :: Text -> TextSource

Strip the trailing slash.

convertMsg :: FilePath -> SourceInfo -> CompileMessageSource

Convert an API message to a more structurally convenient reply message.