Skip to content

Commit

Permalink
Merge pull request #4307 from PoeticPete/fix-typedef
Browse files Browse the repository at this point in the history
Fix `typedef NS_CLOSED_ENUM` getting an extra space
  • Loading branch information
gmaurel committed Jun 4, 2024
2 parents a40c530 + 24e0aa8 commit 8da0fc4
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 9 deletions.
3 changes: 1 addition & 2 deletions src/tokenizer/combine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1136,8 +1136,7 @@ void do_symbol_check(Chunk *prev, Chunk *pc, Chunk *next)
&& !is_oc_block(pc)
&& pc->GetParentType() != CT_OC_MSG_DECL
&& pc->GetParentType() != CT_OC_MSG_SPEC
&& ( pc->IsString(")")
|| pc->Is(CT_FUNC_TYPE))
&& pc->IsString(")")
&& next->IsString("("))
{
if (language_is_set(lang_flag_e::LANG_D))
Expand Down
14 changes: 7 additions & 7 deletions tests/cli/output/in_fcn_def.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@
# 4> TYPEDEF| NONE| PARENT_NOT_SET[ 1/ 1/ 8/ 0][0/0/0][ e 0000][0-0] typedef
# 4> TYPE| NONE| PARENT_NOT_SET[ 9/ 9/ 13/ 1][0/0/0][ 2 0080][0-1] void
# 4> FUNC_TYPE| TYPEDEF| PARENT_NOT_SET[ 14/ 14/ 22/ 1][0/0/0][ 80][0-0] function
# 4> FPAREN_OPEN| FUNC_CALL| PARENT_NOT_SET[ 22/ 22/ 23/ 0][0/0/0][ 2 0000 0080][0-0] (
# 4> TYPE| NONE| PARENT_NOT_SET[ 23/ 23/ 26/ 0][0/1/0][ 8a 0088][0-0] int
# 4> WORD| NONE| PARENT_NOT_SET[ 27/ 27/ 28/ 1][0/1/0][ 100 0088][0-0] i
# 4> COMMA| NONE| PARENT_NOT_SET[ 28/ 28/ 29/ 0][0/1/0][ 2 0000 0088][0-0] ,
# 4> TYPE| NONE| PARENT_NOT_SET[ 30/ 30/ 36/ 1][0/1/0][ 8a 0088][0-0] double
# 4> WORD| NONE| PARENT_NOT_SET[ 37/ 37/ 38/ 1][0/1/0][ 100 0088][0-0] d
# 4> FPAREN_CLOSE| FUNC_CALL| PARENT_NOT_SET[ 38/ 38/ 39/ 0][0/0/0][ 2 0000 0088][0-0] )
# 4> FPAREN_OPEN| TYPEDEF| PARENT_NOT_SET[ 22/ 22/ 23/ 0][0/0/0][ 2 0000 0080][0-0] (
# 4> TYPE| NONE| PARENT_NOT_SET[ 23/ 23/ 26/ 0][0/1/0][ 8a 0080][0-0] int
# 4> WORD| NONE| PARENT_NOT_SET[ 27/ 27/ 28/ 1][0/1/0][ 100 0080][0-0] i
# 4> COMMA| NONE| PARENT_NOT_SET[ 28/ 28/ 29/ 0][0/1/0][ 2 0000 0080][0-0] ,
# 4> TYPE| NONE| PARENT_NOT_SET[ 30/ 30/ 36/ 1][0/1/0][ 8a 0080][0-0] double
# 4> WORD| NONE| PARENT_NOT_SET[ 37/ 37/ 38/ 1][0/1/0][ 100 0080][0-0] d
# 4> FPAREN_CLOSE| TYPEDEF| PARENT_NOT_SET[ 38/ 38/ 39/ 0][0/0/0][ 2 0000 0080][0-0] )
# 4> SEMICOLON| TYPEDEF| PARENT_NOT_SET[ 39/ 39/ 40/ 0][0/0/0][ 2 0000 0080][0-0] ;
# 4> NEWLINE| NONE| PARENT_NOT_SET[ 40/ 40/ 1/ 0][0/0/0][ 0][2-0]
# -=====-
2 changes: 2 additions & 0 deletions tests/config/oc/60013.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
indent_columns = 4
indent_with_tabs = 0
11 changes: 11 additions & 0 deletions tests/expected/oc/60013-Issue_4306.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#import <Foundation/Foundation.h>

typedef NS_CLOSED_ENUM(NSUInteger, FOO) {
FOOA,
FOOB
};

typedef NS_CLOSED_ENUM(NSUInteger, BAR) {
BARA,
BARB
};
11 changes: 11 additions & 0 deletions tests/input/oc/Issue_4306.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#import <Foundation/Foundation.h>

typedef NS_CLOSED_ENUM(NSUInteger, FOO) {
FOOA,
FOOB
};

typedef NS_CLOSED_ENUM(NSUInteger, BAR) {
BARA,
BARB
};
1 change: 1 addition & 0 deletions tests/objective-c.test
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,4 @@
#11032 oc/U10-Cpp.cfg oc/newlines.mm
60011 oc/UNI-11095.cfg oc/UNI-11095.mm
60012 oc/60012.cfg oc/Issue_4304.mm
60013 oc/60013.cfg oc/Issue_4306.mm

0 comments on commit 8da0fc4

Please sign in to comment.