Skip to content

Commit

Permalink
Merge pull request #1 from stinem1/master
Browse files Browse the repository at this point in the history
Windows Compatibility & Save Results Command
  • Loading branch information
JakuJ authored Aug 27, 2024
2 parents 3966f33 + f9b5e46 commit 0ac7e24
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 8 deletions.
2 changes: 2 additions & 0 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ dependencies:
- text
- lens
- process
- directory
- filepath
- megaparsec
- optparse-applicative

Expand Down
8 changes: 7 additions & 1 deletion rsl-language-server.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 1.12

-- This file has been generated from package.yaml by hpack version 0.34.4.
-- This file has been generated from package.yaml by hpack version 0.37.0.
--
-- see: https://github.com/sol/hpack

Expand Down Expand Up @@ -39,6 +39,8 @@ library
ghc-options: -flate-dmd-anal -flate-specialise -Wall -Wcompat -Wno-unused-do-bind -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints
build-depends:
base >=4.7 && <5
, directory
, filepath
, lens
, lsp
, lsp-types
Expand All @@ -60,6 +62,8 @@ executable rsl-language-server
ghc-options: -flate-dmd-anal -flate-specialise -Wall -Wcompat -Wno-unused-do-bind -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints -O2 -threaded -rtsopts -with-rtsopts=-N
build-depends:
base >=4.7 && <5
, directory
, filepath
, lens
, lsp
, lsp-types
Expand All @@ -85,6 +89,8 @@ test-suite rsl-language-server-test
ghc-options: -flate-dmd-anal -flate-specialise -Wall -Wcompat -Wno-unused-do-bind -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N -Wno-incomplete-uni-patterns
build-depends:
base >=4.7 && <5
, directory
, filepath
, hspec
, hspec-discover
, lens
Expand Down
1 change: 1 addition & 0 deletions src/Raise/CodeLens.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ cmdList :: [(T.Text, T.Text)]
cmdList = [ ("Typecheck", "raise.typeCheck")
, ("Compile to SML", "raise.compileToSML")
, ("Run SML", "raise.runSML")
, ("Save Results", "raise.saveResults")
]

registerLenses :: LspM () ()
Expand Down
1 change: 0 additions & 1 deletion src/Raise/DiagnosticParser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ parseDiagnosticLine = T.pack <$> someTill asciiChar newline

parseDiagnostic :: Parser Diagnostic
parseDiagnostic = do
lookAhead $ oneOf ("./" :: String) -- filepaths start with . (relative) or / (absolute)
someTill asciiChar (string ".rsl:")
row <- max 0 . subtract 1 . read <$> someTill digitChar (char ':')
column <- read <$> someTill digitChar (char ':')
Expand Down
17 changes: 11 additions & 6 deletions src/Raise/Diagnostics.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,23 @@ import qualified Language.LSP.Protocol.Lens as J
import qualified Language.LSP.Protocol.Types as J
import Language.LSP.Server
import Raise.DiagnosticParser (parseRSLTC)
import System.Directory (withCurrentDirectory)
import System.FilePath (takeDirectory, takeFileName)
import System.Process (readProcessWithExitCode)

runTool :: String -> [String] -> IO T.Text
runTool tool args = do
(_, stdout, _) <- readProcessWithExitCode tool args ""
pure $ T.pack stdout
runTool :: String -> [String] -> FilePath -> IO T.Text
runTool tool args path = do
let dir = takeDirectory path
file = takeFileName path
withCurrentDirectory dir $ do
(_, stdout, _) <- readProcessWithExitCode tool (args ++ [file]) ""
pure $ T.pack stdout

runChecker :: FilePath -> IO T.Text
runChecker path = runTool "rsltc" [path]
runChecker path = runTool "rsltc" [] path

runCompiler :: FilePath -> IO T.Text
runCompiler path = runTool "rsltc" ["-m", path]
runCompiler path = runTool "rsltc" ["-m"] path

sendDiagnostics :: Bool -> J.NormalizedUri -> FilePath -> LspM () ()
sendDiagnostics compile fileUri filePath = do
Expand Down

0 comments on commit 0ac7e24

Please sign in to comment.