Current non-working version of file parsing
[lsp-test.git] / src / Language / Haskell / LSP / Test / Recorded.hs
index e2dce5c811f1b4104f801ce985df3479d3a19ec1..41df16d08bc0a8ccf66c698669fc7441ccd158b1 100644 (file)
@@ -61,14 +61,17 @@ replay cfp sfp curRootDir = do
 
   let recRootDir = rootDir unswappedClientMsgs
 
-  (clientMsgs, fileMap) <- swapFiles emptyFileMap recRootDir curRootDir unswappedClientMsgs
+  clientMsgs <- swapFiles recRootDir curRootDir unswappedClientMsgs
+
+  print clientMsgs
+  error "sdaf"
 
   tmpDir <- getTemporaryDirectory
   (mappedClientRecFp, mappedClientRecIn) <- openTempFile tmpDir "clientRecInMapped"
   mapM_ (B.hPut mappedClientRecIn . addHeader) clientMsgs
   hSeek mappedClientRecIn AbsoluteSeek 0
 
-  (expectedMsgs, _) <- swapFiles fileMap recRootDir curRootDir =<< getAllMessages serverRecIn
+  expectedMsgs <- swapFiles recRootDir curRootDir =<< getAllMessages serverRecIn
 
   -- listen to server
   forkIO $ runReaderT (listenServer expectedMsgs serverOut semas) didPass
@@ -159,7 +162,7 @@ listenServer expectedMsgs h semas@(reqSema, rspSema) = do
           lift $ putStrLn $ "Got notification " ++ show (n ^. LSP.method)
           lift $ print n
 
-          lift $ putStrLn $ (show ((length $ filter isNotification expectedMsgs) - 1)) ++ " notifications remaining"
+          lift $ putStrLn $ show (length (filter isNotification expectedMsgs) - 1) ++ " notifications remaining"
 
           if n ^. LSP.method == LSP.WindowLogMessage
             then return expectedMsgs
@@ -170,15 +173,15 @@ listenServer expectedMsgs h semas@(reqSema, rspSema) = do
               _ = expected == msg -- make expected type same as res
           failSession ("Out of order\nExpected\n" ++ show expected ++ "\nGot\n" ++ show msg ++ "\n")
 
-        markReceived msg = do
+        markReceived msg =
           let new = deleteFirstJson msg expectedMsgs
-           in if (new == expectedMsgs) 
+           in if new == expectedMsgs
               then failSession ("Unexpected message: " ++ show msg) >> return new
               else return new
 
         deleteFirstJson _ [] = []
         deleteFirstJson msg (x:xs)
-          | (Just msg) == (decode x) = xs
+          | Just msg == decode x = xs
           | otherwise = x:deleteFirstJson msg xs
 
         firstExpected = head $ filter (not . isNotification) expectedMsgs