Skip to content

Commit e57232d

Browse files
authored
[migrator] Add a viewer utility for child indices to facilitate access. NFC (#8925)
1 parent 72e7f9a commit e57232d

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

include/swift/IDE/APIDigesterData.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ struct CommonDiffItem: public APIDiffItem {
6969
SDKNodeKind NodeKind;
7070
NodeAnnotation DiffKind;
7171
StringRef ChildIndex;
72+
private:
73+
llvm::SmallVector<uint8_t, 4> ChildIndexPieces;
74+
public:
7275
StringRef LeftUsr;
7376
StringRef RightUsr;
7477
StringRef LeftComment;
@@ -80,6 +83,7 @@ struct CommonDiffItem: public APIDiffItem {
8083
StringRef LeftComment, StringRef RightComment,
8184
StringRef ModuleName);
8285

86+
ArrayRef<uint8_t> getChildIndices() { return ChildIndexPieces; }
8387
static StringRef head();
8488
bool operator<(CommonDiffItem Other) const;
8589
static bool classof(const APIDiffItem *D);

lib/IDE/APIDigesterData.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ CommonDiffItem(SDKNodeKind NodeKind, NodeAnnotation DiffKind,
5959
RightUsr(RightUsr), LeftComment(LeftComment),
6060
RightComment(RightComment), ModuleName(ModuleName) {
6161
assert(!ChildIndex.empty() && "Child index is empty.");
62+
llvm::SmallVector<StringRef, 4> Pieces;
63+
ChildIndex.split(Pieces, ":");
64+
std::transform(Pieces.begin(), Pieces.end(),
65+
std::back_inserter(ChildIndexPieces),
66+
[](StringRef Piece) { return std::stoi(Piece); });
6267
}
6368

6469
StringRef swift::ide::api::CommonDiffItem::head() {

0 commit comments

Comments
 (0)