mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[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:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user