@@ -383,11 +383,11 @@ class SDKNode {
383
383
void removeChild (ChildIt CI) { Children.erase (CI); }
384
384
ChildIt getChildBegin () { return Children.begin (); }
385
385
void annotate (NodeAnnotation Anno) { Annotations.insert (Anno); }
386
+ void annotate (NodeAnnotation Anno, StringRef Comment);
386
387
NodePtr getParent () const { return Parent; };
387
388
unsigned getChildrenCount () const { return Children.size (); }
388
389
NodePtr childAt (unsigned I) const ;
389
390
void removeChild (NodePtr C);
390
- void addAnnotateComment (NodeAnnotation Anno, StringRef Comment);
391
391
StringRef getAnnotateComment (NodeAnnotation Anno) const ;
392
392
bool isAnnotatedAs (NodeAnnotation Anno) const ;
393
393
void addChild (SDKNode *Child);
@@ -603,8 +603,9 @@ void SDKNode::removeChild(NodePtr C) {
603
603
Children.erase (std::find (Children.begin (), Children.end (), C));
604
604
}
605
605
606
- void SDKNode::addAnnotateComment (NodeAnnotation Anno, StringRef Comment) {
607
- assert (isAnnotatedAs (Anno) && " Cannot find annotation" );
606
+ void SDKNode::annotate (NodeAnnotation Anno, StringRef Comment) {
607
+ assert (!isAnnotatedAs (Anno) && " already annotated" );
608
+ annotate (Anno);
608
609
AnnotateComments[Anno] = Comment;
609
610
}
610
611
@@ -1974,8 +1975,7 @@ class RemovedAddedNodeMatcher : public NodeMatcher, public MatchedNodeListener {
1974
1975
} else {
1975
1976
return false ;
1976
1977
}
1977
- R->annotate (NodeAnnotation::PropertyName);
1978
- R->addAnnotateComment (NodeAnnotation::PropertyName, A->getPrintedName ());
1978
+ R->annotate (NodeAnnotation::PropertyName, A->getPrintedName ());
1979
1979
foundMatch (R, A);
1980
1980
return true ;
1981
1981
}
@@ -2012,11 +2012,10 @@ class RemovedAddedNodeMatcher : public NodeMatcher, public MatchedNodeListener {
2012
2012
if (auto VC = dyn_cast<SDKNodeVar>(Child)) {
2013
2013
auto LastPartOfA = getLastPartOfUsr (VC);
2014
2014
if (LastPartOfA && LastPartOfR.getValue () == LastPartOfA.getValue ()) {
2015
- R->annotate (NodeAnnotation::ModernizeEnum);
2016
2015
std::string FullName = (llvm::Twine (A->getName ()) + " ." +
2017
2016
Child->getName ()).str ();
2018
- R->addAnnotateComment (NodeAnnotation::ModernizeEnum,
2019
- R->getSDKContext ().buffer (FullName));
2017
+ R->annotate (NodeAnnotation::ModernizeEnum,
2018
+ R->getSDKContext ().buffer (FullName));
2020
2019
foundMatch (R, A);
2021
2020
return true ;
2022
2021
}
@@ -2321,10 +2320,8 @@ static void detectRename(NodePtr L, NodePtr R) {
2321
2320
assert (L->getKind () == R->getKind ());
2322
2321
if (isa<SDKNodeDecl>(L) && L->getPrintedName () != R->getPrintedName ()) {
2323
2322
L->annotate (NodeAnnotation::Rename);
2324
- L->annotate (NodeAnnotation::RenameOldName);
2325
- L->addAnnotateComment (NodeAnnotation::RenameOldName, L->getPrintedName ());
2326
- L->annotate (NodeAnnotation::RenameNewName);
2327
- L->addAnnotateComment (NodeAnnotation::RenameNewName, R->getPrintedName ());
2323
+ L->annotate (NodeAnnotation::RenameOldName, L->getPrintedName ());
2324
+ L->annotate (NodeAnnotation::RenameNewName, R->getPrintedName ());
2328
2325
}
2329
2326
}
2330
2327
@@ -2494,12 +2491,10 @@ class TypeMemberDiffFinder : public SDKNodeVisitor {
2494
2491
diffNode->getKind () == SDKNodeKind::Function &&
2495
2492
node->isNameValid ()) {
2496
2493
diffNode->annotate (NodeAnnotation::Rename);
2497
- diffNode->annotate (NodeAnnotation::RenameOldName);
2498
- diffNode->addAnnotateComment (NodeAnnotation::RenameOldName,
2499
- diffNode->getPrintedName ());
2500
- diffNode->annotate (NodeAnnotation::RenameNewName);
2501
- diffNode->addAnnotateComment (NodeAnnotation::RenameNewName,
2502
- node->getParent ()->getPrintedName ());
2494
+ diffNode->annotate (NodeAnnotation::RenameOldName,
2495
+ diffNode->getPrintedName ());
2496
+ diffNode->annotate (NodeAnnotation::RenameNewName,
2497
+ node->getParent ()->getPrintedName ());
2503
2498
}
2504
2499
}
2505
2500
@@ -2604,12 +2599,9 @@ class ChangeRefinementPass : public SDKTreeDiffPass, public SDKNodeVisitor {
2604
2599
(Node->getName () != Counter->getName ()||
2605
2600
Node->getChildrenCount () != Counter->getChildrenCount ())) {
2606
2601
Node->annotate (NodeAnnotation::TypeRewritten);
2607
- Node->annotate (NodeAnnotation::TypeRewrittenLeft);
2608
- Node->annotate (NodeAnnotation::TypeRewrittenRight);
2609
- Node->addAnnotateComment (NodeAnnotation::TypeRewrittenLeft,
2610
- Node->getPrintedName ());
2611
- Node->addAnnotateComment (NodeAnnotation::TypeRewrittenRight,
2612
- Counter->getPrintedName ());
2602
+ Node->annotate (NodeAnnotation::TypeRewrittenLeft, Node->getPrintedName ());
2603
+ Node->annotate (NodeAnnotation::TypeRewrittenRight,
2604
+ Counter->getPrintedName ());
2613
2605
return true ;
2614
2606
}
2615
2607
return false ;
@@ -2638,9 +2630,8 @@ class ChangeRefinementPass : public SDKTreeDiffPass, public SDKNodeVisitor {
2638
2630
if (auto DT = dyn_cast<SDKNodeTypeDecl>(Results.front ())) {
2639
2631
if (DT->isConformingTo (KnownProtocolKind::RawRepresentable)) {
2640
2632
L->annotate (NodeAnnotation::DictionaryKeyUpdate);
2641
- L->annotate (NodeAnnotation::TypeRewrittenRight);
2642
- L->addAnnotateComment (NodeAnnotation::TypeRewrittenRight,
2643
- DT->getFullyQualifiedName ());
2633
+ L->annotate (NodeAnnotation::TypeRewrittenRight,
2634
+ DT->getFullyQualifiedName ());
2644
2635
return true ;
2645
2636
}
2646
2637
}
0 commit comments