-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from jxxcarlson/function-body
Add module Install.FunctionBody
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
module Install.FunctionBody exposing (..) | ||
|
||
import Elm.Syntax.Declaration exposing (Declaration(..)) | ||
import Elm.Syntax.Expression exposing (Case, Expression(..), Function, FunctionImplementation) | ||
import Elm.Syntax.ModuleName exposing (ModuleName) | ||
import Elm.Syntax.Node as Node exposing (Node(..)) | ||
import Elm.Syntax.Pattern exposing (Pattern(..)) | ||
import Elm.Syntax.Range exposing (Range) | ||
import List.Extra | ||
import Review.Fix as Fix exposing (Fix) | ||
import Review.Rule as Rule exposing (Error, Rule) | ||
import Set exposing (Set) | ||
import String.Extra | ||
|
||
|
||
{-| Configuration for makeRule: add a clause to a case expression in a specified function in a specified module. | ||
-} | ||
type Config | ||
= Config | ||
{ moduleName : String | ||
, functionName : String | ||
, functionArgs : List String | ||
, functionBody : String | ||
, customErrorMessage : CustomError | ||
} | ||
|
||
|
||
{-| Custom error message to be displayed when running `elm-review --fix` or `elm-review --fix-all` | ||
-} | ||
type CustomError | ||
= CustomError { message : String, details : List String } | ||
|
||
|
||
init : String -> String -> List String -> String -> Config | ||
init moduleName functionName functionArgs functionBody = | ||
Config | ||
{ moduleName = moduleName | ||
, functionName = functionName | ||
, functionArgs = functionArgs | ||
, functionBody = functionBody | ||
, customErrorMessage = CustomError { message = "Replace function body for function " ++ clause, details = [ "" ] } | ||
} |