Skip to content

Commit

Permalink
realm#2353 - Add offset and length to the ModifierDescription
Browse files Browse the repository at this point in the history
  • Loading branch information
abdulowork committed Dec 20, 2018
1 parent 6651740 commit b048521
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions Source/SwiftLintFramework/Rules/Style/ModifierOrderRule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,23 @@ private extension Dictionary where Key == String, Value == SourceKitRepresentabl
return rhsOffset < lhsOffset
}
.compactMap {
guard let offset = $0.offset else { return nil }
if let attribute = $0.attribute,
let modifierGroup = SwiftDeclarationAttributeKind.ModifierGroup(rawAttribute: attribute) {
let modifierGroup = SwiftDeclarationAttributeKind.ModifierGroup(rawAttribute: attribute),
let length = $0.length {
return ModifierDescription(
keyword: attribute.lastComponentAfter("."),
group: modifierGroup
group: modifierGroup,
offset: offset,
length: length
)
} else if let kind = $0.kind {
let keyword = kind.lastComponentAfter(".")
return ModifierDescription(
keyword: kind.lastComponentAfter("."),
group: .typeMethods
keyword: keyword,
group: .typeMethods,
offset: offset,
length: keyword.count
)
}
return nil
Expand All @@ -144,4 +151,6 @@ private extension String {
private struct ModifierDescription: Equatable {
let keyword: String
let group: SwiftDeclarationAttributeKind.ModifierGroup
let offset: Int
let length: Int
}

0 comments on commit b048521

Please sign in to comment.