Skip to content

Commit

Permalink
refactor(nextcloud): Generate correctly formatted WebDAV props code
Browse files Browse the repository at this point in the history
Signed-off-by: provokateurin <kate@provokateurin.de>
  • Loading branch information
provokateurin committed Mar 27, 2024
1 parent f7dddf9 commit 5960541
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions packages/nextcloud/generate_props.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,21 @@ void main() {

final namespaceVariable = convertNamespace(namespacePrefix);
final variable = namespacePrefix + name.toLowerCase().replaceAll(RegExp('[^a-z]'), '');
valueProps.add(
"@annotation.XmlElement(name: '$name', namespace: $namespaceVariable, includeIfNull: false,)\n final $type? $variable;",
);
findProps.add(
"@annotation.XmlElement(name: '$name', namespace: $namespaceVariable, includeIfNull: true, isSelfClosing: true,)\n final List<String?>? $variable;",
);
valueProps.add('''
@annotation.XmlElement(
name: '$name',
namespace: $namespaceVariable,
includeIfNull: false,
)
final $type? $variable;''');
findProps.add('''
@annotation.XmlElement(
name: '$name',
namespace: $namespaceVariable,
includeIfNull: true,
isSelfClosing: true,
)
final List<String?>? $variable;''');
variables.add(variable);
}
}
Expand All @@ -77,6 +86,7 @@ void main() {
variables,
isPropfind: true,
),
'',
...generateClass(
'WebDavProp',
'prop',
Expand All @@ -85,6 +95,7 @@ void main() {
variables,
isPropfind: false,
),
'',
...generateClass(
'WebDavOcFilterRules',
'filter-rules',
Expand Down Expand Up @@ -118,7 +129,7 @@ List<String> generateClass(
if (isPropfind) ...[
' const $name.fromBools({',
...variables.map((variable) => ' bool $variable = false,'),
' }) : ${variables.map((variable) => '$variable = $variable ? const [null] : null').join(', ')};',
' }) : ${variables.map((variable) => '$variable = $variable ? const [null] : null').join(',\n ')};',
'',
],
' factory $name.fromXmlElement(XmlElement element) => _\$${name}FromXmlElement(element);',
Expand Down

0 comments on commit 5960541

Please sign in to comment.