On 18. May 2007, at 18:53, Fritz Anderson wrote:
Consider the following code: [...] The name of the method setSerialNumber: is not highlighted, and it does not appear in the function popup. Removing the #ifndef cures both problems.
Is there something I can do? Is there a later version of the Obj-C bundle that covers this?
That’s a tricky problem to solve (sort of).
In the C grammar there are rules to mark #if 0 … #endif as commented. This is a little more complex than so, as it needs to handle nesting of such preprocessor instructions, the #else case, etc. It also has a general #if(n?def)? match so that an #else belonging to an outer #if/ #else/#endif is not mistaken as belonging to the #if 0/#endif.
Between the preprocessor conditionals, the C grammar includes $base, meaning full Objective-C, if that is the chosen language.
But, in Objective-C methods are only matched between @implementation / @end. So it is not enough to include $base in the C grammar, it really wants something like $parent (referring to the rules which were active in the parent scope), though this functionality does not presently exist.
One fix could be to always match methods (in the Objective-C grammar), another would be to not care about matching #if(n?def)? in the root scope -- I am actually not entirely sure we need to track it, since #else binds to the innermost conditional. But I’ll have to ponder this before making any changes to the grammar.