Skip to content

Commit

Permalink
remove Debug.todos #12
Browse files Browse the repository at this point in the history
  • Loading branch information
decioferreira committed Oct 10, 2024
1 parent 6c18aac commit 726be33
Show file tree
Hide file tree
Showing 19 changed files with 106 additions and 78 deletions.
2 changes: 1 addition & 1 deletion elm.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"elm/json": "1.1.3",
"elm/parser": "1.1.0",
"elm/time": "1.0.0",
"elm/url": "1.0.0",
"elm-community/array-extra": "2.6.0",
"elm-community/basics-extra": "4.1.0",
"elm-community/list-extra": "8.7.0",
Expand All @@ -28,7 +29,6 @@
"indirect": {
"elm/random": "1.0.0",
"elm/regex": "1.0.0",
"elm/url": "1.0.0",
"elm/virtual-dom": "1.0.3",
"fredcy/elm-parseint": "2.0.1",
"pilatch/flip": "1.0.0"
Expand Down
5 changes: 3 additions & 2 deletions src/Builder/File.elm
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import Data.IO as IO exposing (IO(..))
import Json.Decode as Decode
import Json.Encode as Encode
import Time
import Utils.Crash exposing (todo)
import Utils.Main as Utils exposing (FilePath, ZipArchive, ZipEntry)


Expand Down Expand Up @@ -135,7 +136,7 @@ hGetContentsSizeHint handle =
-- )
-- in
-- readChunks []
Debug.todo "hGetContentsSizeHint"
todo "hGetContentsSizeHint"


encodingError : FilePath -> IO.IOError -> IO.IOError
Expand All @@ -149,7 +150,7 @@ encodingError path ioErr =
-- (Just path)
-- _ ->
-- ioErr
Debug.todo "encodingError"
todo "encodingError"



Expand Down
22 changes: 13 additions & 9 deletions src/Builder/Http.elm
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@ module Builder.Http exposing
, upload
)

import Basics.Extra exposing (uncurry)
import Compiler.Elm.Version as V
import Compiler.Parse.Keyword exposing (type_)
import Data.IO as IO exposing (IO(..))
import Json.Decode as Decode
import Json.Encode as Encode
import Url.Builder
import Utils.Crash exposing (todo)
import Utils.Main as Utils exposing (HTTPResponse(..), SomeException(..))


Expand Down Expand Up @@ -73,12 +76,13 @@ toUrl url params =
url

_ :: _ ->
url ++ "?" ++ urlEncodeVars params
url ++ urlEncodeVars params


urlEncodeVars : List ( String, String ) -> String
urlEncodeVars params =
Debug.todo "urlEncodeVars"
-- includes the `?`
Url.Builder.toQuery (List.map (uncurry Url.Builder.string) params)



Expand Down Expand Up @@ -147,7 +151,7 @@ fetch methodVerb manager url headers onError onSuccess =
addDefaultHeaders : List Header -> List Header
addDefaultHeaders headers =
-- ( hUserAgent, userAgent ) :: ( hAcceptEncoding, "gzip" ) :: headers
Debug.todo "addDefaultHeaders"
todo "addDefaultHeaders"


userAgent : String
Expand All @@ -158,7 +162,7 @@ userAgent =
accept : String -> Header
accept mime =
-- ( hAccept, mime )
Debug.todo "accept"
todo "accept"



Expand Down Expand Up @@ -188,7 +192,7 @@ handleHttpException url onError httpException =
-- IO.pure (Err (onError (BadUrl url reason)))
-- HttpExceptionRequest _ content ->
-- IO.pure (Err (onError (BadHttp url content)))
Debug.todo "handleHttpException"
todo "handleHttpException"


handleSomeException : String -> (Error -> e) -> SomeException -> IO (Result e a)
Expand Down Expand Up @@ -251,13 +255,13 @@ upload manager url parts =
-- <|
-- \_ ->
-- return (Right ())
Debug.todo "upload"
todo "upload"


filePart : String -> String -> MultiPart
filePart name filePath =
-- Multi.partFileSource (String.fromString name) filePath
Debug.todo "filePart"
todo "filePart"


jsonPart : String -> String -> Encode.Value -> MultiPart
Expand All @@ -267,13 +271,13 @@ jsonPart name filePath value =
-- Multi.RequestBodyLBS <| B.toLazyByteString <| Encode.encodeUgly value
-- in
-- Multi.partFileRequestBody (String.fromString name) filePath body
Debug.todo "jsonPart"
todo "jsonPart"


stringPart : String -> String -> MultiPart
stringPart name string =
-- Multi.partBS (String.fromString name) (BS.pack string)
Debug.todo "stringPart"
todo "stringPart"



Expand Down
5 changes: 3 additions & 2 deletions src/Builder/Reporting/Exit.elm
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import Data.IO exposing (IO)
import Data.Map as Dict exposing (Dict)
import Json.Decode as CoreDecode
import Json.Encode as CoreEncode
import Utils.Crash exposing (todo)
import Utils.Main as Utils exposing (FilePath, HTTPResponse)


Expand Down Expand Up @@ -817,7 +818,7 @@ publishToReport publish =
-- toHttpErrorReport "PROBLEM VERIFYING TAG"
-- httpError
-- "I need to check that the version tag is registered on GitHub"
Debug.todo "PublishCannotGetTag"
todo "PublishCannotGetTag"

PublishCannotGetTagData version url body ->
Help.report "PROBLEM VERIFYING TAG"
Expand Down Expand Up @@ -2235,7 +2236,7 @@ toRedirectDoc response =
-- D.red (D.fromInt code) |> D.a (D.fromChars " - ") |> D.a (D.fromChars (BS_UTF8.toString loc))
-- Nothing ->
-- D.red (D.fromInt code) |> D.a (D.fromChars " - ") |> D.a (D.fromChars (BS_UTF8.toString message))
Debug.todo "toRedirectDoc"
todo "toRedirectDoc"



Expand Down
6 changes: 5 additions & 1 deletion src/Compiler/Data/Name.elm
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ module Compiler.Data.Name exposing
, virtualDom
)

import Utils.Crash exposing (todo)



-- NAME


Expand Down Expand Up @@ -109,7 +113,7 @@ getKernel name =
String.dropLeft (String.length prefixKernel) name

else
Debug.todo "AssertionFailed"
todo "AssertionFailed"



Expand Down
3 changes: 2 additions & 1 deletion src/Compiler/Json/Decode.elm
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import Compiler.Reporting.Annotation as A
import Data.Map as Dict exposing (Dict)
import Data.Set as EverySet exposing (EverySet)
import Json.Decode as Decode
import Utils.Crash exposing (crash)



Expand Down Expand Up @@ -451,7 +452,7 @@ oneOf decoders =
oneOfHelp ast decoders_ [] e

[] ->
Debug.todo "Ran into (Json.Decode.oneOf [])"
crash "Ran into (Json.Decode.oneOf [])"


oneOfHelp : AST -> List (Decoder x a) -> List (Problem x) -> Problem x -> Result (Problem x) a
Expand Down
3 changes: 2 additions & 1 deletion src/Compiler/Parse/Number.elm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Compiler.AST.Utils.Binop as Binop
import Compiler.Parse.Primitives as P exposing (Col, Row)
import Compiler.Parse.Variable as Var
import Compiler.Reporting.Error.Syntax as E
import Utils.Crash exposing (todo)



Expand Down Expand Up @@ -92,7 +93,7 @@ number toExpectation toError =
copy_

Nothing ->
Debug.todo "Failed `String.toFloat`"
todo "Failed `String.toFloat`"

float =
Float copy
Expand Down
3 changes: 2 additions & 1 deletion src/Compiler/Parse/Primitives.elm
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ module Compiler.Parse.Primitives exposing
import Compiler.Reporting.Annotation as A
import Json.Decode as Decode
import Json.Encode as Encode
import Utils.Crash exposing (crash)



Expand Down Expand Up @@ -409,7 +410,7 @@ unsafeIndex str index =
char

Nothing ->
Debug.todo "Error on unsafeIndex!"
crash "Error on unsafeIndex!"


isWord : String -> Int -> Int -> Char -> Bool
Expand Down
57 changes: 35 additions & 22 deletions src/Compiler/Parse/Shader.elm
Original file line number Diff line number Diff line change
Expand Up @@ -120,28 +120,41 @@ parseGlsl startRow startCol src =
Ok (GLS.TranslationUnit decls) ->
P.pure (List.foldr addInput emptyTypes (List.concatMap extractInputs decls))

Err err ->
-- let
-- pos =
-- Parsec.errorPos err
-- row =
-- fromIntegral (Parsec.sourceLine pos)
-- col =
-- fromIntegral (Parsec.sourceColumn pos)
-- msg =
-- Parsec.showErrorMessages
-- "or"
-- "unknown parse error"
-- "expecting"
-- "unexpected"
-- "end of input"
-- (Parsec.errorMessages err)
-- in
-- if row == 1 then
-- failure startRow (startCol + 6 + col) msg
-- else
-- failure (startRow + row - 1) col msg
Debug.todo ("parseGlsl: " ++ Debug.toString err)
Err { position, messages } ->
-- FIXME this should be moved into guida-lang/glsl
let
lines =
String.left position src
|> String.lines

row =
List.length lines

col =
case List.reverse lines of
lastLine :: _ ->
String.length lastLine

_ ->
0

msg =
showErrorMessages messages
in
if row == 1 then
failure startRow (startCol + 6 + col) msg

else
failure (startRow + row - 1) col msg


showErrorMessages : List String -> String
showErrorMessages msgs =
if List.isEmpty msgs then
"unknown parse error"

else
String.join "\n" msgs


failure : Row -> Col -> String -> Parser E.Expr a
Expand Down
3 changes: 2 additions & 1 deletion src/Compiler/Reporting/Doc.elm
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import List.Extra as List
import Prelude
import System.Console.Ansi as Ansi
import Text.PrettyPrint.ANSI.Leijen as P
import Utils.Crash exposing (crash)



Expand Down Expand Up @@ -338,7 +339,7 @@ toJsonHelp : Style -> List String -> P.SimpleDoc -> List E.Value
toJsonHelp style revChunks simpleDoc =
case simpleDoc of
P.SFail ->
Debug.todo <|
crash <|
"according to the main implementation, @SFail@ can not appear uncaught in a rendered @SimpleDoc@"

P.SEmpty ->
Expand Down
3 changes: 2 additions & 1 deletion src/Compiler/Reporting/Error/Json.elm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Compiler.Json.Decode exposing (DecodeExpectation(..), Error(..), ParseErr
import Compiler.Reporting.Annotation as A
import Compiler.Reporting.Doc as D
import Compiler.Reporting.Render.Code as Code
import Utils.Crash exposing (todo)
import Utils.Main as Utils


Expand Down Expand Up @@ -371,7 +372,7 @@ expectationToReport path source context (A.Region start end) expectation reason

region =
if sr == er then
Debug.todo "region"
todo "region"

else
A.Region start start
Expand Down
14 changes: 2 additions & 12 deletions src/Compiler/Reporting/Render/Code.elm
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import Compiler.Reporting.Annotation as A
import Compiler.Reporting.Doc as D exposing (Doc)
import Data.Set as EverySet
import List.Extra as List
import Prelude



Expand Down Expand Up @@ -82,18 +83,7 @@ render sourceLines ((A.Region (A.Position startLine _) (A.Position endLine _)) a
|> List.take (1 + endLine - startLine)

width =
String.length
(String.fromInt
(Tuple.first
(case List.last relevantLines of
Just relevantLine ->
relevantLine

Nothing ->
Debug.todo "*** Exception: Prelude.last: empty list"
)
)
)
String.length (String.fromInt (Tuple.first (Prelude.last relevantLines)))

smallerRegion =
Maybe.withDefault region maybeSubRegion
Expand Down
Loading

0 comments on commit 726be33

Please sign in to comment.