Skip to content

Commit 3297e1f

Browse files
authored
Merge pull request swiftlang#164 from ahoppen/syntax-identifiable
Make Syntax nodes conform to Identifiable
2 parents 2daebf7 + af30152 commit 3297e1f

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

Sources/SwiftSyntax/Syntax.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ public extension SyntaxProtocol {
339339
}
340340

341341
/// Returns a value representing the unique identity of the node.
342-
var uniqueIdentifier: SyntaxIdentifier {
342+
var id: SyntaxIdentifier {
343343
return data.nodeId
344344
}
345345

@@ -600,7 +600,7 @@ extension ReversedTokenSequence: CustomReflectable {
600600
/// This is a more efficient representation than `Syntax` because it avoids casts
601601
/// to `Syntax` for representing the parent hierarchy.
602602
/// It provides generic information, like the node's position, range, and
603-
/// `uniqueIdentifier`, while still allowing getting the associated `Syntax`
603+
/// a unique `id`, while still allowing getting the associated `Syntax`
604604
/// object if necessary.
605605
///
606606
/// `SyntaxParser` uses `SyntaxNode` to efficiently report which syntax nodes
@@ -668,7 +668,7 @@ public struct SyntaxNode {
668668
}
669669

670670
/// Returns a value representing the unique identity of the node.
671-
public var uniqueIdentifier: SyntaxIdentifier {
671+
public var id: SyntaxIdentifier {
672672
return absoluteRaw.info.nodeId
673673
}
674674
}

Tests/SwiftSyntaxTest/IncrementalParsingTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ public class IncrementalParsingTestCase: XCTestCase {
4444
XCTAssertEqual("\(reusedNode)", "\nstruct B {}")
4545

4646
XCTAssertEqual(newStructB.byteRange, reusedRange)
47-
XCTAssertEqual(origStructB.uniqueIdentifier, reusedNode.uniqueIdentifier)
47+
XCTAssertEqual(origStructB.id, reusedNode.id)
4848
XCTAssertEqual(origStructB, reusedNode.asCodeBlockItem)
4949
XCTAssertTrue(reusedNode.isCodeBlockItem)
5050
XCTAssertEqual(origStructB, reusedNode.asCodeBlockItem!)
51-
XCTAssertEqual(origStructB.parent!.uniqueIdentifier, reusedNode.parent!.uniqueIdentifier)
51+
XCTAssertEqual(origStructB.parent!.id, reusedNode.parent!.id)
5252
}
5353
}

Tests/SwiftSyntaxTest/SyntaxTests.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ public class SyntaxAPITestCase: XCTestCase {
5757
let tokset = Set(toks+rtoks)
5858
XCTAssertEqual(tokset.count, 6)
5959

60-
XCTAssertEqual(toks[0].uniqueIdentifier, rtoks[5].uniqueIdentifier)
61-
XCTAssertEqual(toks[1].uniqueIdentifier, rtoks[4].uniqueIdentifier)
62-
XCTAssertEqual(toks[2].uniqueIdentifier, rtoks[3].uniqueIdentifier)
63-
XCTAssertEqual(toks[3].uniqueIdentifier, rtoks[2].uniqueIdentifier)
64-
XCTAssertEqual(toks[4].uniqueIdentifier, rtoks[1].uniqueIdentifier)
65-
XCTAssertEqual(toks[5].uniqueIdentifier, rtoks[0].uniqueIdentifier)
60+
XCTAssertEqual(toks[0].id, rtoks[5].id)
61+
XCTAssertEqual(toks[1].id, rtoks[4].id)
62+
XCTAssertEqual(toks[2].id, rtoks[3].id)
63+
XCTAssertEqual(toks[3].id, rtoks[2].id)
64+
XCTAssertEqual(toks[4].id, rtoks[1].id)
65+
XCTAssertEqual(toks[5].id, rtoks[0].id)
6666
}
6767

6868
public func testPositions() {

0 commit comments

Comments
 (0)