Skip to content

Commit b340ad4

Browse files
committed
Show warning for files
1 parent 719d738 commit b340ad4

File tree

7 files changed

+12
-11
lines changed

7 files changed

+12
-11
lines changed

R.swift/Generators/ColorGenerator.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,17 @@ struct ColorGenerator: Generator {
1414
let internalStruct: Struct? = nil
1515

1616
init(colorPalettes palettes: [ColorPalette]) {
17+
let groupedPalettes = palettes.groupBySwiftIdentifiers { $0.filename }
18+
groupedPalettes.printWarningsForDuplicatesAndEmpties(source: "color palette", result: "file")
19+
1720
externalStruct = Struct(
1821
comments: ["This `R.color` struct is generated, and contains static references to \(palettes.count) color palettes."],
1922
type: Type(module: .Host, name: "color"),
2023
implements: [],
2124
typealiasses: [],
2225
properties: [],
2326
functions: [],
24-
structs: palettes.flatMap(ColorGenerator.colorStructFromPalette)
27+
structs: groupedPalettes.uniques.flatMap(ColorGenerator.colorStructFromPalette)
2528
)
2629
}
2730

R.swift/Generators/FontGenerator.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ struct FontGenerator: Generator {
1313
let internalStruct: Struct? = nil
1414

1515
init(fonts: [Font]) {
16+
let groupedFonts = fonts.groupBySwiftIdentifiers { $0.name }
17+
groupedFonts.printWarningsForDuplicatesAndEmpties(source: "font resource", result: "file")
1618

17-
let fontProperties: [Property] = fonts.map {
19+
let fontProperties: [Property] = groupedFonts.uniques.map {
1820
Let(
1921
comments: ["Font `\($0.name)`."],
2022
isStatic: true,
@@ -30,7 +32,7 @@ struct FontGenerator: Generator {
3032
implements: [],
3133
typealiasses: [],
3234
properties: fontProperties,
33-
functions: fonts.map(FontGenerator.fontFunctionFromFont),
35+
functions: groupedFonts.uniques.map(FontGenerator.fontFunctionFromFont),
3436
structs: []
3537
)
3638
}

R.swift/Generators/NibGenerator.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ struct NibGenerator: Generator {
3737

3838
init(nibs: [Nib]) {
3939
let groupedNibs = nibs.groupBySwiftIdentifiers { $0.name }
40-
41-
groupedNibs.printWarningsForDuplicatesAndEmpties(source: "xib", result: "xib")
40+
groupedNibs.printWarningsForDuplicatesAndEmpties(source: "xib", result: "file")
4241

4342
internalStruct = Struct(
4443
type: Type(module: .Host, name: "nib"),

R.swift/Generators/ResourceFileGenerator.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ struct ResourceFileGenerator: Generator {
1414

1515
init(resourceFiles: [ResourceFile]) {
1616
let groupedResourceFiles = resourceFiles.groupBySwiftIdentifiers { $0.fullname }
17-
1817
groupedResourceFiles.printWarningsForDuplicatesAndEmpties(source: "resource file", result: "file")
1918

2019
let resourceFileProperties: [Property] = groupedResourceFiles

R.swift/Generators/ReuseIdentifierGenerator.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ struct ReuseIdentifierGenerator: Generator {
1919
.flatMap { $0.first }
2020

2121
let groupedReusables = deduplicatedReusables.groupBySwiftIdentifiers { $0.identifier }
22-
2322
groupedReusables.printWarningsForDuplicatesAndEmpties(source: "reuseIdentifier", result: "reuseIdentifier")
2423

2524
let reuseIdentifierProperties = groupedReusables

R.swift/Generators/StoryboardGenerator.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ struct StoryboardGenerator: Generator {
1414

1515
init(storyboards: [Storyboard]) {
1616
let groupedStoryboards = storyboards.groupBySwiftIdentifiers { $0.name }
17-
18-
groupedStoryboards.printWarningsForDuplicatesAndEmpties(source: "storyboard", result: "storyboard")
17+
groupedStoryboards.printWarningsForDuplicatesAndEmpties(source: "storyboard", result: "file")
1918

2019
let storyboardStructs = groupedStoryboards
2120
.uniques

ResourceApp/ResourceAppTests/ResourceAppTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ class ResourceAppTests: XCTestCase {
1414

1515
let expectedWarnings = [
1616
"warning: [R.swift] Skipping 2 images because symbol 'second' would be generated for all of these images: Second, second",
17-
"warning: [R.swift] Skipping 2 xibs because symbol 'duplicate' would be generated for all of these xibs: Duplicate, duplicate",
18-
"warning: [R.swift] Skipping 2 storyboards because symbol 'duplicate' would be generated for all of these storyboards: Duplicate, duplicate",
17+
"warning: [R.swift] Skipping 2 xibs because symbol 'duplicate' would be generated for all of these files: Duplicate, duplicate",
18+
"warning: [R.swift] Skipping 2 storyboards because symbol 'duplicate' would be generated for all of these files: Duplicate, duplicate",
1919
"warning: [R.swift] Skipping 2 reuseIdentifiers because symbol 'duplicateCellView' would be generated for all of these reuseIdentifiers: DuplicateCellView, duplicateCellView",
2020
"warning: [R.swift] Skipping 2 segues for 'SecondViewController' because symbol 'toFirst' would be generated for all of these segues: ToFirst, toFirst",
2121
"warning: [R.swift] Skipping 2 images because symbol 'theAppIcon' would be generated for all of these images: The App Icon, TheAppIcon",

0 commit comments

Comments
 (0)