Swiftify-Corp / Swiftify

42 stars 24 forks source link

Constants from .h are misplaced when following a forward declaration #198

Closed amorde closed 2 years ago

amorde commented 2 years ago

Input:

@protocol SomeProtocol;

// A comment about these keys blah blah blah something something something
extern NSString *_Nonnull const SomeConstantStringA;
extern NSString *_Nonnull const SomeConstantStringB;

output:

// A comment about these keys blah blah blah something something somethinglet SomeConstantStringA = "SomeKeyString"
let SomeConstantStringB = "SomeOtherKeyString"

Notice how the let SomeConstantStringA declaration is placed at the end of the comment instead of a new line.

This only happens with the @protocol SomeProtocol; declaration above the constants.

alex-swiftify commented 2 years ago

@amorde I believe that could be the case, but can't reproduce so far.

Online converter: https://swiftify.me/rzzqxi Xcode Extension, "Convert Selection to Swift" command: https://take.ms/I82R6

Let me know how exactly did you get such results? Maybe that was a part of the larger conversion? Did you use the web converter, Xcode Extension, Advanced Project Converter, etc?

amorde commented 2 years ago

Ah apologies forgot to mention I am using the offline converter, and I verified my sample using the standalone application (not the Xcode extension)

alex-swiftify commented 2 years ago

@amorde I just retried the same by copying the code you provided to a file (test.h), and converting it using the Offline Converter (video).

Still got the same results as the above. Can you please double-check and provide the exact input code and/or steps to reproduce this?

amorde commented 2 years ago

Here's an exact repro - Open the included folder "swifty_constants" and run the offline converter on both the .h and .m by checking both. I noticed in the video there was only a .h - maybe that's related?

swiftify_constants.zip

alex-swiftify commented 2 years ago

@amorde Acknowledged. Yeah, this is reproducible when converting both the header and the source files together. Will take care.

alex-swiftify commented 2 years ago

@amorde Fixed (will be available since the next converter update).

Converter output:

// A comment about these keys blah blah blah something something something
let SomeConstantStringA = "SomeKeyString"
let SomeConstantStringB = "SomeOtherKeyString"