38 auto Name = Decl->getName();
39 auto NewName = Decl->getName().str();
41 if (Style == CategoryProperty) {
42 Index = Name.find_first_of(
'_') + 1;
43 NewName.replace(0, Index - 1, Name.substr(0, Index - 1).lower());
45 if (Index < Name.size()) {
46 NewName[Index] = tolower(NewName[Index]);
47 if (NewName != Name) {
48 return FixItHint::CreateReplacement(
49 CharSourceRange::getTokenRange(SourceRange(Decl->getLocation())),
50 llvm::StringRef(NewName));
85 size_t Start = PropertyName.find_first_of(
'_');
86 assert(Start != llvm::StringRef::npos && Start + 1 < PropertyName.size());
87 auto Prefix = PropertyName.substr(0, Start);
88 if (Prefix.lower() != Prefix) {
92 return RegexExp.match(PropertyName.substr(Start + 1));
105 const auto *MatchedDecl =
106 Result.Nodes.getNodeAs<ObjCPropertyDecl>(
"property");
107 assert(!MatchedDecl->getName().empty());
108 auto *DeclContext = MatchedDecl->getDeclContext();
109 auto *CategoryDecl = llvm::dyn_cast<ObjCCategoryDecl>(DeclContext);
111 if (CategoryDecl !=
nullptr &&
114 CategoryDecl->IsClassExtension()) {
115 NamingStyle Style = CategoryDecl->IsClassExtension() ? StandardProperty
117 diag(MatchedDecl->getLocation(),
118 "property name '%0' not using lowerCamelCase style or not prefixed "
119 "in a category, according to the Apple Coding Guidelines")
124 diag(MatchedDecl->getLocation(),
125 "property name '%0' not using lowerCamelCase style or not prefixed in "
126 "a category, according to the Apple Coding Guidelines")
127 << MatchedDecl->getName()