mirror of
https://github.com/koalaman/shellcheck
synced 2025-07-15 01:23:07 -07:00
Process replacements according to AST depth (fixes #1431)
This commit is contained in:
parent
394f4d6505
commit
434b904746
7 changed files with 382 additions and 84 deletions
|
@ -52,7 +52,8 @@ module ShellCheck.Interface
|
|||
, newComment
|
||||
, Fix(fixReplacements)
|
||||
, newFix
|
||||
, Replacement(repStartPos, repEndPos, repString)
|
||||
, InsertionPoint(InsertBefore, InsertAfter)
|
||||
, Replacement(repStartPos, repEndPos, repString, repPrecedence, repInsertionPoint)
|
||||
, newReplacement
|
||||
) where
|
||||
|
||||
|
@ -209,16 +210,25 @@ newComment = Comment {
|
|||
data Replacement = Replacement {
|
||||
repStartPos :: Position,
|
||||
repEndPos :: Position,
|
||||
repString :: String
|
||||
repString :: String,
|
||||
-- Order in which the replacements should happen: highest precedence first.
|
||||
repPrecedence :: Int,
|
||||
-- Whether to insert immediately before or immediately after the specified region.
|
||||
repInsertionPoint :: InsertionPoint
|
||||
} deriving (Show, Eq, Generic, NFData)
|
||||
|
||||
data InsertionPoint = InsertBefore | InsertAfter
|
||||
deriving (Show, Eq, Generic, NFData)
|
||||
|
||||
instance Ord Replacement where
|
||||
compare r1 r2 = (repStartPos r1) `compare` (repStartPos r2)
|
||||
|
||||
newReplacement = Replacement {
|
||||
repStartPos = newPosition,
|
||||
repEndPos = newPosition,
|
||||
repString = ""
|
||||
repString = "",
|
||||
repPrecedence = 1,
|
||||
repInsertionPoint = InsertAfter
|
||||
}
|
||||
|
||||
data Fix = Fix {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue