[PATCH] D42947: Support special acronyms inside property names and allow plural forms
Yan Zhang via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 6 13:18:47 PST 2018
Wizard updated this revision to Diff 133066.
Wizard added a comment.
resolve comments
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D42947
Files:
clang-tidy/objc/PropertyDeclarationCheck.cpp
test/clang-tidy/objc-property-declaration.m
Index: test/clang-tidy/objc-property-declaration.m
===================================================================
--- test/clang-tidy/objc-property-declaration.m
+++ test/clang-tidy/objc-property-declaration.m
@@ -14,6 +14,9 @@
@property(strong, nonatomic) UIViewController *notificationsVC;
@property(strong, nonatomic) NSString *URL_string;
// CHECK-MESSAGES: :[[@LINE-1]]:40: warning: property name 'URL_string' not using lowerCamelCase style or not prefixed in a category, according to the Apple Coding Guidelines [objc-property-declaration]
+ at property(strong, nonatomic) NSString *supportURLsCamelCase;
+ at property(strong, nonatomic) NSString *supportURLCamelCase;
+ at property(strong, nonatomic) NSString *VCsPluralToAdd;
@end
@interface Foo (Bar)
Index: clang-tidy/objc/PropertyDeclarationCheck.cpp
===================================================================
--- clang-tidy/objc/PropertyDeclarationCheck.cpp
+++ clang-tidy/objc/PropertyDeclarationCheck.cpp
@@ -12,8 +12,8 @@
#include "../utils/OptionsUtils.h"
#include "clang/AST/ASTContext.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
-#include "llvm/ADT/STLExtras.h"
#include "clang/Basic/CharInfo.h"
+#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/Regex.h"
@@ -118,6 +118,12 @@
return FixItHint();
}
+std::string AcronymsGroupRegex(llvm::ArrayRef<std::string> EscapedAcronyms) {
+ return "(" +
+ llvm::join(EscapedAcronyms.begin(), EscapedAcronyms.end(), "s?|") +
+ "s?)";
+}
+
std::string validPropertyNameRegex(llvm::ArrayRef<std::string> EscapedAcronyms,
bool UsedInMatcher) {
// Allow any of these names:
@@ -130,11 +136,9 @@
// bundleID
std::string StartMatcher = UsedInMatcher ? "::" : "^";
- return StartMatcher + "((" +
- llvm::join(EscapedAcronyms.begin(), EscapedAcronyms.end(), "|") +
- ")[A-Z]?)?[a-z]+[a-z0-9]*([A-Z][a-z0-9]+)*" + "(" +
- llvm::join(EscapedAcronyms.begin(), EscapedAcronyms.end(), "|") +
- ")?$";
+ return StartMatcher + "(" + AcronymsGroupRegex(EscapedAcronyms) +
+ "[A-Z]?)?[a-z]+[a-z0-9]*(" + AcronymsGroupRegex(EscapedAcronyms) +
+ "|([A-Z][a-z0-9]+))*$";
}
bool hasCategoryPropertyPrefix(llvm::StringRef PropertyName) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42947.133066.patch
Type: text/x-patch
Size: 2312 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180206/040681c3/attachment-0001.bin>
More information about the cfe-commits
mailing list