Code formatter has stopped working properly

I'm seeing some strange behaviour in the 3.0.1. All of a sudden the code formatter has started formatting my log macros on the same line as if statements. It only seems to be doing it for macros.


I've reset the formatter to the default (which does a really nice job) but it still formats my code like this:

if (error) {LogApp(Error, @"my log message");
}


I'm not sure what's triggered it but it's driving me a little mad. Any pointers are most welcome.

8 comments
Comment actions Permalink

Macro formatting was essentially changed in 3.0, and minor change comes with 3.0.1.
Do you have the same problem with 3.0?
Macro formatting has strong dependence from macro syntax. Could you provide the macro definition?

0
Comment actions Permalink

Many thanks for the super fast reply. It led me to finding the problem:


In my pch, I define my logger macros like this:

 
if defined (DEBUG)
#define LogApp(level, ...)           LogMessageF(__FILE__, __LINE__, __FUNCTION__, @"App", level, __VA_ARGS__)
 
#define LogApp(...)     while(0){}


Then all is well and the formatting works.

0
Comment actions Permalink

Yes, I see. Currently the "empty" macros aren't formatted due to plenty of variants.
We can made an exception for macros with the parameters. Please, create the request if you need this.

0
Comment actions Permalink

Thanks for the reply, I will raise a request.

I'm beginning to think there's something else going on around pre-processor #if etc.

I don't think AppCode is taking any notice of the various defines I have in my targets.

For example:

#if defined(PREPROCESSOR_DEFINED_IN_TARGET_1)
     void* error = This should produce an inspection parse error and be flagged as invalid syntax but it isn't.
#elif defined(PREPROCESSOR_DEFINED_IN_TARGET_2)
NSLog(@"This line never gets indented when I run the code formatter");
#else
     NSLog(@"This is the only statement that is syntax highlighted regardless of the selected target");
endif



Regardless of the target I'm building, only the code in the #else ever get's 'attention' from AppCode.

If I #define PREPROCESSOR_DEFINED_IN_TARGET_1 immediately before the code example above, AppCode shifts its 'attention' to the syntax error.

This issue also has the effect that optimise imports may remove imports required by code in #defined blocks that AppCode ignores.


Am I missing something here? Have I got my build setup wrong? Perhaps a bug?

Any help would be gratefully received.

0
Comment actions Permalink

Does changing resolve context on the status bar changes the way the file is highlighted?
Screenshot 2014-07-30 13.09.16.png

0
Comment actions Permalink

Thanks for the reply, I'm now feeling a little silly.

That works nicely.

Is there a way to link the context with the build scheme so when I switch schemes, it selects the equivalent DEBUG context?

0
Comment actions Permalink

No, there is no such at the moment, but we'll think about your suggestion

0
Comment actions Permalink

Great, thanks for getting back to me (I'm still feeling somewhat silly).

0

Please sign in to leave a comment.