forked from mac-cain13/R.swift
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4e8569b
commit 8f38351
Showing
2 changed files
with
53 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// AssetSubfolders.swift | ||
// Spectre | ||
// | ||
// Created by Tom Lokhorst on 2017-06-06. | ||
// | ||
|
||
import Foundation | ||
|
||
struct AssetSubfolders { | ||
let folders: [NamespacedAssetSubfolder] | ||
let duplicates: [NamespacedAssetSubfolder] | ||
|
||
init(all subfolders: [NamespacedAssetSubfolder], assetIdentifiers: [SwiftIdentifier]) { | ||
var dict: [SwiftIdentifier: NamespacedAssetSubfolder] = [:] | ||
|
||
for subfolder in subfolders { | ||
let name = SwiftIdentifier(name: subfolder.name) | ||
if let duplicate = dict[name] { | ||
duplicate.subfolders += subfolder.subfolders | ||
duplicate.imageAssets += subfolder.imageAssets | ||
} else { | ||
dict[name] = subfolder | ||
} | ||
} | ||
|
||
self.folders = dict.values.filter { !assetIdentifiers.contains(SwiftIdentifier(name: $0.name)) } | ||
self.duplicates = dict.values.filter { assetIdentifiers.contains(SwiftIdentifier(name: $0.name)) } | ||
} | ||
|
||
func printWarningsForDuplicates() { | ||
for subfolder in duplicates { | ||
warn("Skipping asset subfolder because symbol '\(subfolder.name)' would conflict with image: \(subfolder.name)") | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters