Skip to content

Commit 745d793

Browse files
committed
Support enum extraction when closure passed only single enum argument in Swift.
1 parent 0d19ef4 commit 745d793

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

SCXcodeSwitchExpander/DVTTextCompletionController+SCXcodeSwitchExpander.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,8 @@ - (BOOL)tryExpandingSwitchStatementForLanguage:(DVTSourceCodeLanguageKind)langua
221221
// Fetch all symbols matching the autocomplete item type
222222
NSString *symbolName = (item.displayType.length ? item.displayType : item.displayText);
223223
symbolName = [[symbolName componentsSeparatedByString:@"::"] lastObject]; // Remove C++ namespaces
224-
symbolName = [[symbolName componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] lastObject]; // Remove enum keyword
224+
symbolName = [symbolName stringByReplacingOccurrencesOfString:@"^enum\\s+" withString:@"" options:NSRegularExpressionSearch range:NSMakeRange(0, symbolName.length)]; // Remove enum keyword
225+
symbolName = [symbolName stringByReplacingOccurrencesOfString:@"^\\((.*)\\)$" withString:@"$1" options:NSRegularExpressionSearch range: NSMakeRange(0, symbolName.length)]; // Remove Swift tuple (e.g. `(SomeClass.Result<T, E>)` to `SomeClass.Result<T, E>`). This occurs at the closure passed only single enum argument.
225226

226227
NSArray<IDEIndexSymbol*> *symbols = [self getSymbolsByFullName:symbolName forLanguage:language fromIndex:index];
227228

0 commit comments

Comments
 (0)