@@ -325,7 +325,8 @@ extractCustomAttrValues(VarDecl *propertyDecl) {
325
325
{label, argExpr->getType (), extractCompileTimeValue (argExpr)});
326
326
}
327
327
}
328
- customAttrValues.push_back ({propertyWrapper->getType (), parameters});
328
+
329
+ customAttrValues.push_back ({propertyWrapper, parameters});
329
330
}
330
331
331
332
return customAttrValues;
@@ -458,29 +459,14 @@ gatherConstValuesForPrimary(const std::unordered_set<std::string> &Protocols,
458
459
return Result;
459
460
}
460
461
461
- void writeFileInformation (llvm::json::OStream &JSON, const VarDecl *VD) {
462
- SourceRange sourceRange = VD->getSourceRange ();
463
- if (sourceRange.isInvalid ())
464
- return ;
465
-
466
- const ASTContext &ctx = VD->getDeclContext ()->getASTContext ();
467
- JSON.attribute (" file" , ctx.SourceMgr .getDisplayNameForLoc (sourceRange.Start ));
468
- JSON.attribute (
469
- " line" ,
470
- ctx.SourceMgr .getPresumedLineAndColumnForLoc (sourceRange.Start ).first );
471
- }
472
-
473
- void writeFileInformation (llvm::json::OStream &JSON,
474
- const NominalTypeDecl *NTD) {
475
- DeclContext *DC = NTD->getInnermostDeclContext ();
476
- SourceLoc loc = extractNearestSourceLoc (DC);
477
- if (loc.isInvalid ())
462
+ void writeLocationInformation (llvm::json::OStream &JSON, SourceLoc Loc,
463
+ const ASTContext &ctx) {
464
+ if (Loc.isInvalid ())
478
465
return ;
479
466
480
- const ASTContext &ctx = DC->getASTContext ();
481
- JSON.attribute (" file" , ctx.SourceMgr .getDisplayNameForLoc (loc));
467
+ JSON.attribute (" file" , ctx.SourceMgr .getDisplayNameForLoc (Loc));
482
468
JSON.attribute (" line" ,
483
- ctx.SourceMgr .getPresumedLineAndColumnForLoc (loc ).first );
469
+ ctx.SourceMgr .getPresumedLineAndColumnForLoc (Loc ).first );
484
470
}
485
471
486
472
void writeValue (llvm::json::OStream &JSON,
@@ -592,17 +578,20 @@ void writeValue(llvm::json::OStream &JSON,
592
578
}
593
579
}
594
580
595
- void writeAttributes (
581
+ void writePropertyWrapperAttributes (
596
582
llvm::json::OStream &JSON,
597
- llvm::Optional<std::vector<CustomAttrValue>> PropertyWrappers) {
583
+ llvm::Optional<std::vector<CustomAttrValue>> PropertyWrappers,
584
+ const ASTContext &ctx) {
598
585
if (!PropertyWrappers.has_value ()) {
599
586
return ;
600
587
}
601
588
602
- JSON.attributeArray (" attributes " , [&] {
589
+ JSON.attributeArray (" propertyWrappers " , [&] {
603
590
for (auto PW : PropertyWrappers.value ()) {
604
591
JSON.object ([&] {
605
- JSON.attribute (" type" , toFullyQualifiedTypeNameString (PW.Type ));
592
+ JSON.attribute (" type" ,
593
+ toFullyQualifiedTypeNameString (PW.Attr ->getType ()));
594
+ writeLocationInformation (JSON, PW.Attr ->getLocation (), ctx);
606
595
JSON.attributeArray (" arguments" , [&] {
607
596
for (auto FP : PW.Parameters ) {
608
597
JSON.object ([&] {
@@ -730,7 +719,9 @@ bool writeAsJSONToFile(const std::vector<ConstValueTypeInfo> &ConstValueInfos,
730
719
" kind" ,
731
720
TypeDecl->getDescriptiveKindName (TypeDecl->getDescriptiveKind ())
732
721
.str ());
733
- writeFileInformation (JSON, TypeDecl);
722
+ writeLocationInformation (
723
+ JSON, extractNearestSourceLoc (TypeDecl->getInnermostDeclContext ()),
724
+ TypeDecl->getInnermostDeclContext ()->getASTContext ());
734
725
JSON.attributeArray (" properties" , [&] {
735
726
for (const auto &PropertyInfo : TypeInfo.Properties ) {
736
727
JSON.object ([&] {
@@ -741,9 +732,11 @@ bool writeAsJSONToFile(const std::vector<ConstValueTypeInfo> &ConstValueInfos,
741
732
JSON.attribute (" isStatic" , decl->isStatic () ? " true" : " false" );
742
733
JSON.attribute (" isComputed" ,
743
734
!decl->hasStorage () ? " true" : " false" );
744
- writeFileInformation (JSON, decl);
735
+ writeLocationInformation (JSON, decl->getLoc (),
736
+ decl->getDeclContext ()->getASTContext ());
745
737
writeValue (JSON, PropertyInfo.Value );
746
- writeAttributes (JSON, PropertyInfo.PropertyWrappers );
738
+ writePropertyWrapperAttributes (
739
+ JSON, PropertyInfo.PropertyWrappers , decl->getASTContext ());
747
740
writeResultBuilderInformation (JSON, TypeDecl, decl);
748
741
writeAttrInformation (JSON, decl->getAttrs ());
749
742
});
0 commit comments