diff --git a/SourceKitStressTester/Sources/StressTester/ActionGenerators.swift b/SourceKitStressTester/Sources/StressTester/ActionGenerators.swift index 6ed12af..dbf065d 100644 --- a/SourceKitStressTester/Sources/StressTester/ActionGenerators.swift +++ b/SourceKitStressTester/Sources/StressTester/ActionGenerators.swift @@ -512,15 +512,15 @@ private struct ActionToken { let name = SwiftName(base: token.text, labels: callArgs) return ExpectedResult(name: name, kind: kind) } - } - if let parent = parent.as(MemberAccessExprSyntax.self), parent.name == token { - if let refArgs = parent.declNameArguments { - let name = SwiftName(base: token.text, labels: refArgs.arguments.map{ $0.name.text }) - return ExpectedResult(name: name, kind: .reference) - } - if let (kind, callArgs) = getParentArgs(of: parent) { - let name = SwiftName(base: token.text, labels: callArgs) - return ExpectedResult(name: name, kind: kind) + if let parentsParent = parent.parent?.as(MemberAccessExprSyntax.self), parentsParent.name == token { + if let refArgs = parentsParent.declNameArguments { + let name = SwiftName(base: token.text, labels: refArgs.arguments.map{ $0.name.text }) + return ExpectedResult(name: name, kind: .reference) + } + if let (kind, callArgs) = getParentArgs(of: parentsParent) { + let name = SwiftName(base: token.text, labels: callArgs) + return ExpectedResult(name: name, kind: kind) + } } } let name = SwiftName(base: token.text, labels: []) diff --git a/SourceKitStressTester/Tests/StressTesterToolTests/ActionGeneratorTests.swift b/SourceKitStressTester/Tests/StressTesterToolTests/ActionGeneratorTests.swift index 5ce3820..fc2edae 100644 --- a/SourceKitStressTester/Tests/StressTesterToolTests/ActionGeneratorTests.swift +++ b/SourceKitStressTester/Tests/StressTesterToolTests/ActionGeneratorTests.swift @@ -188,13 +188,13 @@ class ActionGeneratorTests: XCTestCase { } XCTAssertEqual(edits, [ Action.replaceText(offset: 0, length: 9, text: ""), - Action.replaceText(offset: 0, length: 0, text: "."), // . - Action.replaceText(offset: 1, length: 0, text: "c"), // .c + Action.replaceText(offset: 0, length: 0, text: "c"), // c + Action.replaceText(offset: 0, length: 0, text: "."), // .c Action.replaceText(offset: 0, length: 0, text: "["), // [.c Action.replaceText(offset: 3, length: 0, text: "]"), // [.c] Action.replaceText(offset: 0, length: 0, text: "a"), // a[.c] - Action.replaceText(offset: 1, length: 0, text: "."), // a.[.c] - Action.replaceText(offset: 2, length: 0, text: "b"), // a.b[.c] + Action.replaceText(offset: 1, length: 0, text: "b"), // ab[.c] + Action.replaceText(offset: 1, length: 0, text: "."), // a.b[.c] Action.replaceText(offset: 3, length: 0, text: "("), // a.b([.c] Action.replaceText(offset: 8, length: 0, text: ")"), // a.b([.c]) ])