| | |
| | | |
| | | enum QuickSearchEngine { |
| | | static func makeDocuments(apps: [AppInfo], store: TagDatabase.Store) -> [QuickSearchDocument] { |
| | | apps.map { app in |
| | | let localizedNames = uniqueOrdered(app.localizedNames) |
| | | apps |
| | | .filter { !AppIndexer.isNestedInsideAppBundle($0.path) } |
| | | .map { app in |
| | | let localizedNames = uniqueOrdered(AppDisplayNameResolver.searchAliases(for: app)) |
| | | let internalBundleNames = internalBundleNames(for: app) |
| | | let note = store.appNotes[app.path.path] ?? app.note ?? "" |
| | | let bundleIdentifier = app.bundleIdentifier ?? "" |
| | |
| | | previousWasLowercase = isLowercase |
| | | } |
| | | return normalizeField(String(parts)) |
| | | } |
| | | |
| | | private static func localizedNames(for app: AppInfo) -> [String] { |
| | | guard let bundle = Bundle(url: app.path) else { return [] } |
| | | let values = [ |
| | | bundle.localizedInfoDictionary?["CFBundleDisplayName"] as? String, |
| | | bundle.infoDictionary?["CFBundleDisplayName"] as? String, |
| | | FileManager.default.displayName(atPath: app.path.path).replacingOccurrences(of: ".app", with: "") |
| | | ] |
| | | return uniqueOrdered(values.compactMap { $0 }.compactMap { value in |
| | | let trimmed = value.trimmingCharacters(in: .whitespacesAndNewlines) |
| | | return trimmed.isEmpty || trimmed == app.name ? nil : trimmed |
| | | }) |
| | | } |
| | | |
| | | private static func internalBundleNames(for app: AppInfo) -> [String] { |