This mapping has 2 multi-map groups: several pairings are equally correct there. The code view shows one arbitrary valid pairing, not the only one.

Before

1// SPDX-FileCopyrightText: Nextcloud GmbH
2// SPDX-FileCopyrightText: 2018 Marino Faggiana
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5import UIKit
6@preconcurrency import NextcloudKit
7import RealmSwift
8import SVGKit
9
10class NCService: NSObject {
11 let utilityFileSystem = NCUtilityFileSystem()
12 let utility = NCUtility()
13 let database = NCManageDatabase.shared
14 let global = NCGlobal.shared
…lines 15–259 unchanged (245 lines)
260 session: NCNetworking.shared.sessionDownloadBackground,
261 selector: NCGlobal.shared.selectorSynchronizationOffline)
262 }
263 }
264 }
265
266 // MARK: -
267
268 private func requestDashboardWidget(account: String) async {
269 let results = await NextcloudKit.shared.getDashboardWidgetAsync(account: account, taskHandler: { task in
270 Task {
271 let identifier = await NCNetworking.shared.networkingTasks.createIdentifier(account: account,
272 name: "getDashboardWidget")
273 await NCNetworking.shared.networkingTasks.track(identifier: identifier, task: task)
274 }
275 })
276 if results.error == .success,
277 let dashboardWidgets = results.dashboardWidgets {
278 await NCManageDatabase.shared.addDashboardWidgetAsync(account: account, dashboardWidgets: dashboardWidgets)
279 for widget in dashboardWidgets {
280 if let url = URL(string: widget.iconUrl),
281 let fileName = widget.iconClass {
282 let results = await NextcloudKit.shared.downloadPreviewAsync(url: url, account: account) { task in
283 Task {
284 let identifier = await NCNetworking.shared.networkingTasks.createIdentifier(account: account,
285 path: url.absoluteString,
286 name: "DownloadPreview")
287 await NCNetworking.shared.networkingTasks.track(identifier: identifier, task: task)
288 }
289 }
290 if results.error == .success,
291 let data = results.responseData?.data {
292 await MainActor.run {
293 let size = CGSize(width: 256, height: 256)
294 let finalImage: UIImage?
295 if let uiImage = UIImage(data: data)?.resizeImage(size: size) {
296 finalImage = uiImage
297 } else if let svgImage = SVGKImage(data: data) {
298 svgImage.size = size
299 finalImage = svgImage.uiImage
300 } else {
301 print("Unsupported image format")
302 finalImage = nil
303 }
304 if let image = finalImage {
305 let filePath = (self.utilityFileSystem.directoryUserData as NSString).appendingPathComponent(fileName + ".png")
306 do {
307 try image.pngData()?.write(to: URL(fileURLWithPath: filePath), options: .atomic)
308 } catch {
309 print("Failed to write image to disk: \(error.localizedDescription)")
310 }
311 }
312 }
313 }
314 }
315 }
316 }
317 }
318
…lines 319–440 unchanged (122 lines)

After

1// SPDX-FileCopyrightText: Nextcloud GmbH
2// SPDX-FileCopyrightText: 2018 Marino Faggiana
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5import UIKit
6@preconcurrency import NextcloudKit
7import RealmSwift
8
9class NCService: NSObject {
10 let utilityFileSystem = NCUtilityFileSystem()
11 let utility = NCUtility()
12 let database = NCManageDatabase.shared
13 let global = NCGlobal.shared
14
…lines 15–119 unchanged (105 lines)
120 } else {
121 await self.database.setAvatarLoadedAsync(fileName: fileName)
122 }
123 }
124
125 private func requestDashboardWidget(account: String) async {
126 let resultsDashboardWidget = await NextcloudKit.shared.getDashboardWidgetAsync(account: account)
127 if resultsDashboardWidget.error == .success,
128 let dashboardWidgets = resultsDashboardWidget.dashboardWidgets {
129 await NCManageDatabase.shared.addDashboardWidgetAsync(account: account, dashboardWidgets: dashboardWidgets)
130 for widget in dashboardWidgets {
131 if let url = URL(string: widget.iconUrl),
132 let fileName = widget.iconClass {
133 let resultsDownloadPreview = await NextcloudKit.shared.downloadPreviewAsync(url: url, account: account)
134 if resultsDownloadPreview.error == .success,
135 let data = resultsDownloadPreview.responseData?.data {
136 var image: UIImage?
137 let size = CGSize(width: 256, height: 256)
138
139 if let uiImage = UIImage(data: data)?.resizeImage(size: size) {
140 image = uiImage
141 } else if let svgImage = try? await NCSVGRenderer().renderSVGToUIImage(svgData: data, size: size) {
142 image = svgImage
143 }
144
145 if let image {
146 let filePath = (self.utilityFileSystem.directoryUserData as NSString).appendingPathComponent(fileName + ".png")
147 do {
148 try image.pngData()?.write(to: URL(fileURLWithPath: filePath), options: .atomic)
149 } catch {
150 print("Failed to write image to disk: \(error.localizedDescription)")
151 }
152 }
153 }
154 }
155 }
156 }
157 }
158
…lines 159–291 unchanged (133 lines)
292 await self.database.setMetadataSessionInWaitDownloadAsync(ocId: metadata.ocId,
293 session: NCNetworking.shared.sessionDownloadBackground,
294 selector: NCGlobal.shared.selectorSynchronizationOffline)
295 }
296 }
297 }
298
299 // MARK: -
300
301 func sendClientDiagnosticsRemoteOperation(account: String) async {
302 let capabilities = await NKCapabilities.shared.getCapabilities(for: account)
303 guard capabilities.securityGuardDiagnostics,
304 await self.database.existsDiagnosticsAsync(account: account) else {
…lines 305–420 unchanged (116 lines)

Before

source_file
comment "// SPDX-FileCopyrightText: Nextcloud GmbH"
comment "// SPDX-FileCopyrightText: 2018 Marino Faggiana"
comment "// SPDX-License-Identifier: GPL-3.0-or-later"
import_declaration
import "import"
identifier
simple_identifier "UIKit"
import_declaration
modifiers
attribute
@ "@"
user_type
type_identifier "preconcurrency"
import "import"
identifier
simple_identifier "NextcloudKit"
import_declaration
import "import"
identifier
simple_identifier "RealmSwift"
import_declaration
import "import"
identifier
simple_identifier "SVGKit"
class_declaration
class "class"
type_identifier "NCService"
: ":"
inheritance_specifier
user_type
type_identifier "NSObject"
class_body
{ "{"
property_declaration
value_binding_pattern
let "let"
pattern
simple_identifier "utilityFileSystem"
= "="
call_expression
simple_identifier "NCUtilityFileSystem"
call_suffix
value_arguments
( "("
) ")"
property_declaration
value_binding_pattern
let "let"
pattern
simple_identifier "utility"
= "="
call_expression
simple_identifier "NCUtility"
call_suffix
value_arguments
( "("
) ")"
property_declaration
value_binding_pattern
let "let"
pattern
simple_identifier "database"
= "="
navigation_expression
simple_identifier "NCManageDatabase"
navigation_suffix
. "."
simple_identifier "shared"
property_declaration
value_binding_pattern
let "let"
pattern
simple_identifier "global"
= "="
navigation_expression
simple_identifier "NCGlobal"
navigation_suffix
. "."
simple_identifier "shared"
comment "// MARK: -"
function_declaration (+192 nodes collapsed)
comment "// MARK: -"
function_declaration (+582 nodes collapsed)
function_declaration (+444 nodes collapsed)
function_declaration (+1029 nodes collapsed)
comment "// MARK: -"
function_declaration (+749 nodes collapsed)
comment "// MARK: -"
function_declaration
modifiers
visibility_modifier
private "private"
func "func"
simple_identifier "requestDashboardWidget"
( "("
parameter
simple_identifier "account"
: ":"
user_type
type_identifier "String"
) ")"
async "async"
function_body
{ "{"
statements
property_declaration
value_binding_pattern
let "let"
pattern
simple_identifier "results"
= "="
await_expression
await "await"
call_expression
navigation_expression
navigation_expression
simple_identifier "NextcloudKit"
navigation_suffix
. "."
simple_identifier "shared"
navigation_suffix
. "."
simple_identifier "getDashboardWidgetAsync"
call_suffix
value_arguments
( "("
value_argument
value_argument_label
simple_identifier "account"
: ":"
simple_identifier "account"
, ","
value_argument
value_argument_label
simple_identifier "taskHandler"
: ":"
lambda_literal
{ "{"
lambda_function_type
lambda_function_type_parameters
lambda_parameter
simple_identifier "task"
in "in"
statements
call_expression
simple_identifier "Task"
call_suffix
lambda_literal
{ "{"
statements
property_declaration
value_binding_pattern
let "let"
pattern
simple_identifier "identifier"
= "="
await_expression
await "await"
call_expression
navigation_expression
navigation_expression
navigation_expression
simple_identifier "NCNetworking"
navigation_suffix
. "."
simple_identifier "shared"
navigation_suffix
. "."
simple_identifier "networkingTasks"
navigation_suffix
. "."
simple_identifier "createIdentifier"
call_suffix
value_arguments
( "("
value_argument
value_argument_label
simple_identifier "account"
: ":"
simple_identifier "account"
, ","
value_argument
value_argument_label
simple_identifier "name"
: ":"
line_string_literal
" "\""
line_str_text "getDashboardWidget"
" "\""
) ")"
await_expression
await "await"
call_expression
navigation_expression
navigation_expression
navigation_expression
simple_identifier "NCNetworking"
navigation_suffix
. "."
simple_identifier "shared"
navigation_suffix
. "."
simple_identifier "networkingTasks"
navigation_suffix
. "."
simple_identifier "track"
call_suffix
value_arguments
( "("
value_argument
value_argument_label
simple_identifier "identifier"
: ":"
simple_identifier "identifier"
, ","
value_argument
value_argument_label
simple_identifier "task"
: ":"
simple_identifier "task"
) ")"
} "}"
} "}"
) ")"
if_statement
if "if"
equality_expression
navigation_expression
simple_identifier "results"
navigation_suffix
. "."
simple_identifier "error"
== "=="
prefix_expression
. "."
simple_identifier "success"
, ","
value_binding_pattern
let "let"
simple_identifier "dashboardWidgets"
= "="
navigation_expression
simple_identifier "results"
navigation_suffix
. "."
simple_identifier "dashboardWidgets"
{ "{"
statements
await_expression (+27 nodes collapsed)
for_statement
for "for"
pattern
simple_identifier "widget"
in "in"
simple_identifier "dashboardWidgets"
{ "{"
statements
if_statement
if "if"
value_binding_pattern
let "let"
simple_identifier "url"
= "="
call_expression
simple_identifier "URL"
call_suffix
value_arguments
( "("
value_argument
value_argument_label
simple_identifier "string"
: ":"
navigation_expression
simple_identifier "widget"
navigation_suffix
. "."
simple_identifier "iconUrl"
) ")"
, ","
value_binding_pattern
let "let"
simple_identifier "fileName"
= "="
navigation_expression
simple_identifier "widget"
navigation_suffix
. "."
simple_identifier "iconClass"
{ "{"
statements
property_declaration
value_binding_pattern
let "let"
pattern
simple_identifier "results"
= "="
call_expression
await_expression (+27 nodes collapsed)
call_suffix
lambda_literal
{ "{"
lambda_function_type
lambda_function_type_parameters
lambda_parameter
simple_identifier "task"
in "in"
statements
call_expression
simple_identifier "Task"
call_suffix
lambda_literal
{ "{"
statements
property_declaration
value_binding_pattern
let "let"
pattern
simple_identifier "identifier"
= "="
await_expression
await "await"
call_expression
navigation_expression
navigation_expression
navigation_expression
simple_identifier "NCNetworking"
navigation_suffix
. "."
simple_identifier "shared"
navigation_suffix
. "."
simple_identifier "networkingTasks"
navigation_suffix
. "."
simple_identifier "createIdentifier"
call_suffix
value_arguments
( "("
value_argument
value_argument_label
simple_identifier "account"
: ":"
simple_identifier "account"
, ","
value_argument
value_argument_label
simple_identifier "path"
: ":"
navigation_expression
simple_identifier "url"
navigation_suffix
. "."
simple_identifier "absoluteString"
, ","
value_argument
value_argument_label
simple_identifier "name"
: ":"
line_string_literal
" "\""
line_str_text "DownloadPreview"
" "\""
) ")"
await_expression
await "await"
call_expression
navigation_expression
navigation_expression
navigation_expression
simple_identifier "NCNetworking"
navigation_suffix
. "."
simple_identifier "shared"
navigation_suffix
. "."
simple_identifier "networkingTasks"
navigation_suffix
. "."
simple_identifier "track"
call_suffix
value_arguments
( "("
value_argument
value_argument_label
simple_identifier "identifier"
: ":"
simple_identifier "identifier"
, ","
value_argument
value_argument_label
simple_identifier "task"
: ":"
simple_identifier "task"
) ")"
} "}"
} "}"
if_statement
if "if"
equality_expression
navigation_expression
simple_identifier "results"
navigation_suffix
. "."
simple_identifier "error"
== "=="
prefix_expression
. "."
simple_identifier "success"
, ","
value_binding_pattern
let "let"
simple_identifier "data"
= "="
navigation_expression
navigation_expression
simple_identifier "results"
navigation_suffix
. "."
simple_identifier "responseData"
?
? "?"
navigation_suffix
. "."
simple_identifier "data"
{ "{"
statements any 2:1
await_expression
await "await"
call_expression
navigation_expression
simple_identifier "MainActor"
navigation_suffix
. "."
simple_identifier "run"
call_suffix
lambda_literal
{ "{"
statements any 2:1
property_declaration (+23 nodes collapsed)
property_declaration
value_binding_pattern
let "let"
pattern
simple_identifier "finalImage"
type_annotation
: ":"
optional_type
user_type
type_identifier "UIImage"
?
? "?"
if_statement
if "if"
value_binding_pattern
let "let"
simple_identifier "uiImage"
= "="
call_expression (+27 nodes collapsed)
{ "{"
statements
assignment
directly_assignable_expression
simple_identifier "finalImage"
= "="
simple_identifier "uiImage"
} "}"
else "else"
if_statement
if "if"
value_binding_pattern
let "let"
simple_identifier "svgImage"
= "="
call_expression any 1:2
simple_identifier "SVGKImage"
call_suffix
value_arguments
( "("
value_argument
value_argument_label
simple_identifier "data"
: ":"
simple_identifier "data"
) ")"
{ "{"
statements
assignment
directly_assignable_expression
navigation_expression
simple_identifier "svgImage"
navigation_suffix
. "."
simple_identifier "size"
= "="
simple_identifier "size"
assignment
directly_assignable_expression
simple_identifier "finalImage"
= "="
navigation_expression
simple_identifier "svgImage"
navigation_suffix
. "."
simple_identifier "uiImage"
} "}"
else "else"
{ "{"
statements
call_expression
simple_identifier "print"
call_suffix
value_arguments
( "("
value_argument
line_string_literal
" "\""
line_str_text "Unsupported image format"
" "\""
) ")"
assignment
directly_assignable_expression
simple_identifier "finalImage"
= "="
nil "nil"
} "}"
if_statement
if "if"
value_binding_pattern
let "let"
simple_identifier "image"
= "="
simple_identifier "finalImage"
{ "{"
statements (+118 nodes collapsed)
} "}"
} "}"
} "}"
} "}"
} "}"
} "}"
} "}"
comment "// MARK: -"
function_declaration (+1405 nodes collapsed)
} "}"

After

source_file
comment "// SPDX-FileCopyrightText: Nextcloud GmbH"
comment "// SPDX-FileCopyrightText: 2018 Marino Faggiana"
comment "// SPDX-License-Identifier: GPL-3.0-or-later"
import_declaration
import "import"
identifier
simple_identifier "UIKit"
import_declaration
modifiers
attribute
@ "@"
user_type
type_identifier "preconcurrency"
import "import"
identifier
simple_identifier "NextcloudKit"
import_declaration
import "import"
identifier
simple_identifier "RealmSwift"
class_declaration
class "class"
type_identifier "NCService"
: ":"
inheritance_specifier
user_type
type_identifier "NSObject"
class_body
{ "{"
property_declaration
value_binding_pattern
let "let"
pattern
simple_identifier "utilityFileSystem"
= "="
call_expression
simple_identifier "NCUtilityFileSystem"
call_suffix
value_arguments
( "("
) ")"
property_declaration
value_binding_pattern
let "let"
pattern
simple_identifier "utility"
= "="
call_expression
simple_identifier "NCUtility"
call_suffix
value_arguments
( "("
) ")"
property_declaration
value_binding_pattern
let "let"
pattern
simple_identifier "database"
= "="
navigation_expression
simple_identifier "NCManageDatabase"
navigation_suffix
. "."
simple_identifier "shared"
property_declaration
value_binding_pattern
let "let"
pattern
simple_identifier "global"
= "="
navigation_expression
simple_identifier "NCGlobal"
navigation_suffix
. "."
simple_identifier "shared"
comment "// MARK: -"
function_declaration (+192 nodes collapsed)
comment "// MARK: -"
function_declaration (+582 nodes collapsed)
function_declaration (+444 nodes collapsed)
function_declaration
modifiers
visibility_modifier
private "private"
func "func"
simple_identifier "requestDashboardWidget"
( "("
parameter
simple_identifier "account"
: ":"
user_type
type_identifier "String"
) ")"
async "async"
function_body
{ "{"
statements
property_declaration
value_binding_pattern
let "let"
pattern
simple_identifier "resultsDashboardWidget"
= "="
await_expression
await "await"
call_expression
navigation_expression
navigation_expression
simple_identifier "NextcloudKit"
navigation_suffix
. "."
simple_identifier "shared"
navigation_suffix
. "."
simple_identifier "getDashboardWidgetAsync"
call_suffix
value_arguments
( "("
value_argument
value_argument_label
simple_identifier "account"
: ":"
simple_identifier "account"
) ")"
if_statement
if "if"
equality_expression
navigation_expression
simple_identifier "resultsDashboardWidget"
navigation_suffix
. "."
simple_identifier "error"
== "=="
prefix_expression
. "."
simple_identifier "success"
, ","
value_binding_pattern
let "let"
simple_identifier "dashboardWidgets"
= "="
navigation_expression
simple_identifier "resultsDashboardWidget"
navigation_suffix
. "."
simple_identifier "dashboardWidgets"
{ "{"
statements
await_expression (+27 nodes collapsed)
for_statement
for "for"
pattern
simple_identifier "widget"
in "in"
simple_identifier "dashboardWidgets"
{ "{"
statements
if_statement
if "if"
value_binding_pattern
let "let"
simple_identifier "url"
= "="
call_expression
simple_identifier "URL"
call_suffix
value_arguments
( "("
value_argument
value_argument_label
simple_identifier "string"
: ":"
navigation_expression
simple_identifier "widget"
navigation_suffix
. "."
simple_identifier "iconUrl"
) ")"
, ","
value_binding_pattern
let "let"
simple_identifier "fileName"
= "="
navigation_expression
simple_identifier "widget"
navigation_suffix
. "."
simple_identifier "iconClass"
{ "{"
statements
property_declaration
value_binding_pattern
let "let"
pattern
simple_identifier "resultsDownloadPreview"
= "="
await_expression (+27 nodes collapsed)
if_statement
if "if"
equality_expression
navigation_expression
simple_identifier "resultsDownloadPreview"
navigation_suffix
. "."
simple_identifier "error"
== "=="
prefix_expression
. "."
simple_identifier "success"
, ","
value_binding_pattern
let "let"
simple_identifier "data"
= "="
navigation_expression
navigation_expression
simple_identifier "resultsDownloadPreview"
navigation_suffix
. "."
simple_identifier "responseData"
?
? "?"
navigation_suffix
. "."
simple_identifier "data"
{ "{"
statements any 2:1
property_declaration
value_binding_pattern
var "var"
pattern
simple_identifier "image"
type_annotation
: ":"
optional_type
user_type
type_identifier "UIImage"
?
? "?"
property_declaration (+23 nodes collapsed)
if_statement
if "if"
value_binding_pattern
let "let"
simple_identifier "uiImage"
= "="
call_expression (+27 nodes collapsed)
{ "{"
statements
assignment
directly_assignable_expression
simple_identifier "image"
= "="
simple_identifier "uiImage"
} "}"
else "else"
if_statement
if "if"
value_binding_pattern
let "let"
simple_identifier "svgImage"
= "="
try_expression
try_operator
try "try"
? "?"
call_expression any 1:2
navigation_expression
await_expression
await "await"
call_expression any 1:2
simple_identifier "NCSVGRenderer"
call_suffix
value_arguments
( "("
) ")"
navigation_suffix
. "."
simple_identifier "renderSVGToUIImage"
call_suffix
value_arguments
( "("
value_argument
value_argument_label
simple_identifier "svgData"
: ":"
simple_identifier "data"
, ","
value_argument
value_argument_label
simple_identifier "size"
: ":"
simple_identifier "size"
) ")"
{ "{"
statements
assignment
directly_assignable_expression
simple_identifier "image"
= "="
simple_identifier "svgImage"
} "}"
if_statement
if "if"
value_binding_pattern
let "let"
simple_identifier "image"
{ "{"
statements (+118 nodes collapsed)
} "}"
} "}"
} "}"
} "}"
} "}"
} "}"
function_declaration (+1029 nodes collapsed)
comment "// MARK: -"
function_declaration (+749 nodes collapsed)
comment "// MARK: -"
function_declaration (+1405 nodes collapsed)
} "}"