[Omit needless words] Only move "lonely of" arguments back to the base name.

If the first argument label would end up as "of" following splitting
and pruning, move that "of" onto the base name.
This commit is contained in:
Doug Gregor
2016-02-11 13:31:23 -08:00
parent 643725f75a
commit e720333032
2 changed files with 16 additions and 6 deletions

View File

@@ -873,10 +873,6 @@ static bool shouldPlacePrepositionOnArgLabel(StringRef beforePreposition,
afterPreposition == "Z")
return false;
// The preposition "of" binds tightly to the left word.
if (camel_case::sameWordIgnoreFirstCase(preposition, "of"))
return false;
return true;
}
@@ -1147,9 +1143,12 @@ bool swift::omitNeedlessWords(StringRef &baseName,
}
// If needed, split the base name.
bool didSplitBaseName = false;
if (!argNames.empty() &&
splitBaseName(baseName, argNames[0], paramTypes[0], firstParamName))
splitBaseName(baseName, argNames[0], paramTypes[0], firstParamName)) {
didSplitBaseName = true;
anyChanges = true;
}
// Omit needless words based on parameter types.
for (unsigned i = 0, n = argNames.size(); i != n; ++i) {
@@ -1182,5 +1181,16 @@ bool swift::omitNeedlessWords(StringRef &baseName,
}
}
// Place a "lonely of" on the base name, rather than having it as
// the first argument label.
if (didSplitBaseName &&
camel_case::sameWordIgnoreFirstCase(argNames[0], "of")) {
SmallString<16> newBaseName;
newBaseName += baseName;
newBaseName += "Of";
baseName = scratch.copyString(newBaseName);
argNames[0] = StringRef();
}
return lowercaseAcronymsForReturn();
}