Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows Compatibility & Save Results Command #1

Merged
merged 3 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -2,7 +2,7 @@
registerLenses
) where

import Control.Monad.IO.Class

Check warning on line 5 in src/Raise/CodeLens.hs

View workflow job for this annotation

GitHub Actions / ubuntu

The import of ‘Control.Monad.IO.Class’ is redundant
import qualified Data.Text as T
import Language.LSP.Protocol.Message
import Language.LSP.Protocol.Types
Expand All @@ -22,6 +22,7 @@
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
Loading