Fix codegen formatting

This commit is contained in:
Adam Sharp 2024-05-21 13:11:37 -04:00
parent 424a551ca3
commit 0f41ad1d74
No known key found for this signature in database
19 changed files with 96 additions and 11 deletions

View File

@ -16,3 +16,6 @@ Scripts/sds_codegen/sds_parse_swift_bridging.py --src-path . --swift-bridging-p
Scripts/sds_codegen/sds_parse_objc.py --src-path SignalServiceKit/ --swift-bridging-path Scripts/sds_codegen/sds-includes
Scripts/sds_codegen/sds_regenerate.sh
# lint & reformat generated sources
find SignalServiceKit -type f -exec grep --quiet --fixed-strings '// --- CODE GENERATION MARKER' {} \; -print0 | xargs -0 Scripts/precommit.py

View File

@ -59,10 +59,10 @@ def pretty_module_path(path):
def write_text_file_if_changed(file_path, text):
if os.path.exists(file_path):
with open(file_path, "rt") as f:
with open(file_path, "r") as f:
oldText = f.read()
if oldText == text:
return
with open(file_path, "wt") as f:
with open(file_path, "w") as f:
f.write(text)

View File

@ -46,7 +46,7 @@ def update_generated_snippet(file_path, marker, snippet):
start_index = text.find(marker)
end_index = text.rfind(marker)
if start_index < 0 or end_index < 0 or start_index >= end_index:
fail("Could not find markers:", file_path)
fail(f"Could not find markers ('{marker}'): {file_path}")
text = (
text[:start_index].strip()
@ -2527,9 +2527,6 @@ public extension %(model_name)s {
swift_body = sds_common.clean_up_generated_swift(swift_body)
# Add some random whitespace to trigger the auto-formatter.
swift_body = swift_body + (" " * random.randint(1, 100))
sds_common.write_text_file_if_changed(swift_filepath, swift_body)

View File

@ -27,6 +27,14 @@ NS_ASSUME_NONNULL_BEGIN
- (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
// --- CODE GENERATION MARKER
// This snippet is generated by /Scripts/sds_codegen/sds_generate.py. Do not manually edit it, instead run
// `sds_codegen.sh`.
// --- CODE GENERATION MARKER
@end
NS_ASSUME_NONNULL_END

View File

@ -49,6 +49,14 @@ NS_ASSUME_NONNULL_BEGIN
return OWSInteractionType_Unknown;
}
// --- CODE GENERATION MARKER
// This snippet is generated by /Scripts/sds_codegen/sds_generate.py. Do not manually edit it, instead run
// `sds_codegen.sh`.
// --- CODE GENERATION MARKER
@end
NS_ASSUME_NONNULL_END

View File

@ -49,6 +49,14 @@ NS_ASSUME_NONNULL_BEGIN
- (SignalServiceAddress *)theirSignalAddress;
// --- CODE GENERATION MARKER
// This snippet is generated by /Scripts/sds_codegen/sds_generate.py. Do not manually edit it, instead run
// `sds_codegen.sh`.
// --- CODE GENERATION MARKER
@end
NS_ASSUME_NONNULL_END

View File

@ -87,6 +87,14 @@ NS_ASSUME_NONNULL_BEGIN
return self;
}
// --- CODE GENERATION MARKER
// This snippet is generated by /Scripts/sds_codegen/sds_generate.py. Do not manually edit it, instead run
// `sds_codegen.sh`.
// --- CODE GENERATION MARKER
@end
NS_ASSUME_NONNULL_END

View File

@ -16,6 +16,10 @@ NS_ASSUME_NONNULL_BEGIN
// --- CODE GENERATION MARKER
// This snippet is generated by /Scripts/sds_codegen/sds_generate.py. Do not manually edit it, instead run
// `sds_codegen.sh`.
// --- CODE GENERATION MARKER
@end

View File

@ -16,6 +16,10 @@ NS_ASSUME_NONNULL_BEGIN
// --- CODE GENERATION MARKER
// This snippet is generated by /Scripts/sds_codegen/sds_generate.py. Do not manually edit it, instead run
// `sds_codegen.sh`.
// --- CODE GENERATION MARKER
- (BOOL)shouldUseReceiptDateForSorting

View File

@ -16,6 +16,10 @@ NS_ASSUME_NONNULL_BEGIN
// --- CODE GENERATION MARKER
// This snippet is generated by /Scripts/sds_codegen/sds_generate.py. Do not manually edit it, instead run
// `sds_codegen.sh`.
// --- CODE GENERATION MARKER
@end

View File

@ -18,6 +18,10 @@ NS_ASSUME_NONNULL_BEGIN
// --- CODE GENERATION MARKER
// This snippet is generated by /Scripts/sds_codegen/sds_generate.py. Do not manually edit it, instead run
// `sds_codegen.sh`.
// --- CODE GENERATION MARKER
- (BOOL)shouldUseReceiptDateForSorting

View File

@ -60,8 +60,6 @@ NS_ASSUME_NONNULL_BEGIN
// This snippet is generated by /Scripts/sds_codegen/sds_generate.py. Do not manually edit it, instead run
// `sds_codegen.sh`.
// clang-format off
// clang-format on
// --- CODE GENERATION MARKER

View File

@ -118,14 +118,11 @@ NS_ASSUME_NONNULL_BEGIN
return self;
}
// --- CODE GENERATION MARKER
// This snippet is generated by /Scripts/sds_codegen/sds_generate.py. Do not manually edit it, instead run
// `sds_codegen.sh`.
// clang-format off
// clang-format on
// --- CODE GENERATION MARKER

View File

@ -16,6 +16,10 @@ NS_ASSUME_NONNULL_BEGIN
// --- CODE GENERATION MARKER
// This snippet is generated by /Scripts/sds_codegen/sds_generate.py. Do not manually edit it, instead run
// `sds_codegen.sh`.
// --- CODE GENERATION MARKER
@end

View File

@ -18,6 +18,10 @@ NS_ASSUME_NONNULL_BEGIN
// --- CODE GENERATION MARKER
// This snippet is generated by /Scripts/sds_codegen/sds_generate.py. Do not manually edit it, instead run
// `sds_codegen.sh`.
// --- CODE GENERATION MARKER
- (BOOL)shouldUseReceiptDateForSorting

View File

@ -57,6 +57,15 @@ NS_ASSUME_NONNULL_BEGIN
recipientAddressStates:
(nullable NSDictionary<SignalServiceAddress *, TSOutgoingMessageRecipientState *> *)recipientAddressStates
storedMessageState:(TSOutgoingMessageState)storedMessageState NS_DESIGNATED_INITIALIZER;
// --- CODE GENERATION MARKER
// This snippet is generated by /Scripts/sds_codegen/sds_generate.py. Do not manually edit it, instead run
// `sds_codegen.sh`.
// --- CODE GENERATION MARKER
@end
NS_ASSUME_NONNULL_END

View File

@ -139,6 +139,14 @@ NS_ASSUME_NONNULL_BEGIN
return NO;
}
// --- CODE GENERATION MARKER
// This snippet is generated by /Scripts/sds_codegen/sds_generate.py. Do not manually edit it, instead run
// `sds_codegen.sh`.
// --- CODE GENERATION MARKER
@end
NS_ASSUME_NONNULL_END

View File

@ -57,6 +57,15 @@ NS_ASSUME_NONNULL_BEGIN
recipientAddressStates:
(nullable NSDictionary<SignalServiceAddress *, TSOutgoingMessageRecipientState *> *)recipientAddressStates
storedMessageState:(TSOutgoingMessageState)storedMessageState NS_DESIGNATED_INITIALIZER;
// --- CODE GENERATION MARKER
// This snippet is generated by /Scripts/sds_codegen/sds_generate.py. Do not manually edit it, instead run
// `sds_codegen.sh`.
// --- CODE GENERATION MARKER
@end
NS_ASSUME_NONNULL_END

View File

@ -137,6 +137,14 @@ NS_ASSUME_NONNULL_BEGIN
return NO;
}
// --- CODE GENERATION MARKER
// This snippet is generated by /Scripts/sds_codegen/sds_generate.py. Do not manually edit it, instead run
// `sds_codegen.sh`.
// --- CODE GENERATION MARKER
@end
NS_ASSUME_NONNULL_END