Skip to content

Commit

Permalink
Merge pull request #246 from ahoppen/ahoppen/identifierexpr
Browse files Browse the repository at this point in the history
Adjustments because MemberAccessExpr represents the member name as DeclReferenceExpr
  • Loading branch information
ahoppen authored Aug 1, 2023
2 parents 80509c4 + 83b9aa9 commit 5630666
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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: [])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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])
])
Expand Down

0 comments on commit 5630666

Please sign in to comment.