From 77e24fdedb70413dd8f750799dedc4b309b7c8eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cihat=20Gu=CC=88ndu=CC=88z?= Date: Sun, 24 Apr 2022 23:39:25 +0200 Subject: [PATCH] Fix building issues with failed release 0.9.0 --- .../AnyLint/Checkers/FileContentsChecker.swift | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Sources/AnyLint/Checkers/FileContentsChecker.swift b/Sources/AnyLint/Checkers/FileContentsChecker.swift index 558521e..e7a1878 100644 --- a/Sources/AnyLint/Checkers/FileContentsChecker.swift +++ b/Sources/AnyLint/Checkers/FileContentsChecker.swift @@ -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) + ) } } @@ -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