@@ -25,18 +25,6 @@ import SourceKitD
25
25
/// - `foo(_:b:)`
26
26
/// - `foo` if no argument labels are specified, eg. for a variable.
27
27
fileprivate struct CompoundDeclName {
28
- enum CompoundDeclNameParsingError : Error , CustomStringConvertible {
29
- case missingClosingParenthesis
30
- case closingParenthesisNotAtEnd
31
-
32
- var description : String {
33
- switch self {
34
- case . missingClosingParenthesis: " Name contains '(' but no matching ')' "
35
- case . closingParenthesisNotAtEnd: " Additional text after ')' "
36
- }
37
- }
38
- }
39
-
40
28
/// The parameter of a compound decl name, which can either be the parameter's name or `_` to indicate that the
41
29
/// parameter is unnamed.
42
30
enum Parameter : Equatable {
@@ -62,20 +50,15 @@ fileprivate struct CompoundDeclName {
62
50
let parameters : [ Parameter ]
63
51
64
52
/// Parse a compound decl name into its base names and parameters.
65
- init ( _ compoundDeclName: String ) throws {
53
+ init ( _ compoundDeclName: String ) {
66
54
guard let openParen = compoundDeclName. firstIndex ( of: " ( " ) else {
67
55
// We don't have a compound name. Everything is the base name
68
56
self . baseName = compoundDeclName
69
57
self . parameters = [ ]
70
58
return
71
59
}
72
60
self . baseName = String ( compoundDeclName [ ..< openParen] )
73
- guard let closeParen = compoundDeclName. firstIndex ( of: " ) " ) else {
74
- throw CompoundDeclNameParsingError . missingClosingParenthesis
75
- }
76
- guard compoundDeclName. index ( after: closeParen) == compoundDeclName. endIndex else {
77
- throw CompoundDeclNameParsingError . closingParenthesisNotAtEnd
78
- }
61
+ let closeParen = compoundDeclName. firstIndex ( of: " ) " ) ?? compoundDeclName. endIndex
79
62
let parametersText = compoundDeclName [ compoundDeclName. index ( after: openParen) ..< closeParen]
80
63
// Split by `:` to get the parameter names. Drop the last element so that we don't have a trailing empty element
81
64
// after the last `:`.
@@ -549,8 +532,8 @@ extension SwiftLanguageServer {
549
532
oldName: oldNameString,
550
533
in: snapshot
551
534
)
552
- let oldName = try CompoundDeclName ( oldNameString)
553
- let newName = try CompoundDeclName ( newNameString)
535
+ let oldName = CompoundDeclName ( oldNameString)
536
+ let newName = CompoundDeclName ( newNameString)
554
537
555
538
try Task . checkCancellation ( )
556
539
0 commit comments