mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Omit needless words: "Index" in the name matches "Int" or "Integer" in the type.
Swift SVN r31671
This commit is contained in:
@@ -358,15 +358,14 @@ StringRef swift::omitNeedlessWords(StringRef name, OmissionTypeName typeName,
|
||||
}
|
||||
}
|
||||
|
||||
// If this is a skippable suffix, skip it and keep looking.
|
||||
if (nameWordRevIter == nameWordRevIterBegin) {
|
||||
if (auto withoutSuffix = skipTypeSuffix(typeName.Name)) {
|
||||
typeName.Name = *withoutSuffix;
|
||||
typeWords = camel_case::getWords(typeName.Name);
|
||||
typeWordRevIter = typeWords.rbegin();
|
||||
typeWordRevIterEnd = typeWords.rend();
|
||||
continue;
|
||||
}
|
||||
// Special case: "Index" in the name matches "Int" or "Integer" in the type.
|
||||
if (camel_case::sameWordIgnoreFirstCase(nameWord, "Index") &&
|
||||
(camel_case::sameWordIgnoreFirstCase(*typeWordRevIter, "Int") ||
|
||||
camel_case::sameWordIgnoreFirstCase(*typeWordRevIter, "Integer"))) {
|
||||
anyMatches = true;
|
||||
++nameWordRevIter;
|
||||
++typeWordRevIter;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Special case: if the word in the name ends in 's', and we have
|
||||
@@ -388,6 +387,17 @@ StringRef swift::omitNeedlessWords(StringRef name, OmissionTypeName typeName,
|
||||
}
|
||||
}
|
||||
|
||||
// If this is a skippable suffix, skip it and keep looking.
|
||||
if (nameWordRevIter == nameWordRevIterBegin) {
|
||||
if (auto withoutSuffix = skipTypeSuffix(typeName.Name)) {
|
||||
typeName.Name = *withoutSuffix;
|
||||
typeWords = camel_case::getWords(typeName.Name);
|
||||
typeWordRevIter = typeWords.rbegin();
|
||||
typeWordRevIterEnd = typeWords.rend();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user