Omit needless words: "Index" in the name matches "Int" or "Integer" in the type.

Swift SVN r31671
This commit is contained in:
Doug Gregor
2015-09-03 21:05:50 +00:00
parent 213c6a5c7b
commit 21f3153025
3 changed files with 26 additions and 9 deletions

View File

@@ -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;
}