Skip to content

Commit

Permalink
Fix building issues with failed release 0.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeehut committed Apr 24, 2022
1 parent 6101f10 commit 77e24fd
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions Sources/AnyLint/Checkers/FileContentsChecker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,23 @@ extension FileContentsChecker: Checker {
locationInfo = fileContents.locationInfo(of: match.range.lowerBound)

case .upper:
locationInfo = fileContents.locationInfo(of: match.range.lowerBound)
locationInfo = fileContents.locationInfo(of: match.range.upperBound)
}

case .captureGroup(let index):
let capture = match.captures[index]!
let captureRange = NSRange(match.string.range(of: capture)!, in: match.string)

switch self.violationLocation.bound {
case .lower:
locationInfo = fileContents.locationInfo(of: match.range.lowerBound)
locationInfo = fileContents.locationInfo(
of: fileContents.index(match.range.lowerBound, offsetBy: captureRange.location)
)

case .upper:
locationInfo = fileContents.locationInfo(of: match.range.lowerBound)
locationInfo = fileContents.locationInfo(
of: fileContents.index(match.range.lowerBound, offsetBy: captureRange.location + captureRange.length)
)
}
}

Expand Down Expand Up @@ -117,7 +124,7 @@ extension FileContentsChecker: Checker {
let violationsOnRechecks = try FileContentsChecker(
checkInfo: checkInfo,
regex: regex,
violationLocation: self.violationLocation
violationLocation: self.violationLocation,
filePathsToCheck: filePathsToReCheck,
autoCorrectReplacement: autoCorrectReplacement,
repeatIfAutoCorrected: repeatIfAutoCorrected
Expand Down

0 comments on commit 77e24fd

Please sign in to comment.