Skip to content

Commit 4de0299

Browse files
committed
Added support for C++ enums and better handling of non-anonymous ones
1 parent bc27fea commit 4de0299

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ SCXcodeSwitchExpander is a small Xcode plugin that expands switch statements by
3030

3131
- takes a bit for it to kick in after starting Xcode as it's waiting for the IDEIndexDidChange notification. I found that building the project usually makes that happen.
3232

33-
- only works with NS_ENUM but keeps default Xcode behavior for old style enums
33+
- does not work with anonymous enums
3434

3535
### Installation
3636

SCXcodeSwitchExpander/DVTTextCompletionController+SCXcodeSwitchExpander.m

+3
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ - (BOOL)tryExpandingSwitchStatement
6565

6666
// Fetch all symbols matching the autocomplete item type
6767
NSString *symbolName = (item.displayType.length ? item.displayType : item.displayText);
68+
symbolName = [[symbolName componentsSeparatedByString:@"::"] lastObject]; // Remove C++ namespaces
69+
symbolName = [[symbolName componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] lastObject]; // Remove enum keyword
70+
6871
IDEIndexCollection *collection = [index allSymbolsMatchingName:symbolName kind:nil];
6972

7073
// Find the first one of them that is a container

0 commit comments

Comments
 (0)