@@ -873,6 +873,18 @@ static bool shouldPlacePrepositionOnArgLabel(StringRef beforePreposition,
873
873
afterPreposition == " Z" )
874
874
return false ;
875
875
876
+ // The preposition "of" binds tightly to the left word, except in
877
+ // rare cases.
878
+ if (camel_case::sameWordIgnoreFirstCase (preposition, " of" )) {
879
+ auto following = camel_case::getFirstWord (afterPreposition);
880
+ if (!camel_case::sameWordIgnoreFirstCase (following, " type" ) &&
881
+ !camel_case::sameWordIgnoreFirstCase (following, " types" ) &&
882
+ !camel_case::sameWordIgnoreFirstCase (following, " kind" ) &&
883
+ !camel_case::sameWordIgnoreFirstCase (following, " size" ) &&
884
+ !camel_case::sameWordIgnoreFirstCase (following, " length" ))
885
+ return false ;
886
+ }
887
+
876
888
return true ;
877
889
}
878
890
@@ -1143,12 +1155,9 @@ bool swift::omitNeedlessWords(StringRef &baseName,
1143
1155
}
1144
1156
1145
1157
// If needed, split the base name.
1146
- bool didSplitBaseName = false ;
1147
1158
if (!argNames.empty () &&
1148
- splitBaseName (baseName, argNames[0 ], paramTypes[0 ], firstParamName)) {
1149
- didSplitBaseName = true ;
1159
+ splitBaseName (baseName, argNames[0 ], paramTypes[0 ], firstParamName))
1150
1160
anyChanges = true ;
1151
- }
1152
1161
1153
1162
// Omit needless words based on parameter types.
1154
1163
for (unsigned i = 0 , n = argNames.size (); i != n; ++i) {
@@ -1181,16 +1190,5 @@ bool swift::omitNeedlessWords(StringRef &baseName,
1181
1190
}
1182
1191
}
1183
1192
1184
- // Place a "lonely of" on the base name, rather than having it as
1185
- // the first argument label.
1186
- if (didSplitBaseName &&
1187
- camel_case::sameWordIgnoreFirstCase (argNames[0 ], " of" )) {
1188
- SmallString<16 > newBaseName;
1189
- newBaseName += baseName;
1190
- newBaseName += " Of" ;
1191
- baseName = scratch.copyString (newBaseName);
1192
- argNames[0 ] = StringRef ();
1193
- }
1194
-
1195
1193
return lowercaseAcronymsForReturn ();
1196
1194
}
0 commit comments