Prepend "is" to Boolean property names (e.g., "empty" becomes
"isEmpty") unless the property name strongly indicates its Boolean
nature or we're likely to ruin the name. Therefore, the presence of
one of the following in the property name will suppress this
transformation:
* An auxiliary verb, such as "is", "has", "may", "should", or "will".
* A word ending in "s", indicating either a plural (for which
prepending "is" would be incorrect) or a verb in the continuous
tense (which indicates its Boolean nature, e.g., "translates" in
"translatesCoordinates").
Swift SVN r32458
This takes an highly-redundant API name like NSBezierPath's
func bezierPathByReversingPath() -> NSBezierPath
and turns it into
func reversing() -> NSBezierPath
Also, handle 'instancetype' properly when omitting words matching the
result type from the front of the base name.
Swift SVN r32119
For cases where the Clang importer provides a defaulted argument,
e.g., "[]" for option sets and "nil" for optionals, remove the
corresponding arguments at any call sites that simply specify "[]" or
"nil". Such arguments are basically noise, and tend to harm
readability when there are low-content argument labels like "with:" or
"for".
Some examples from Lister:
self.updateUserActivity(AppConfiguration.UserActivity.watch,
userInfo: userInfo, webpageURL: nil)
becomes
self.updateUserActivity(AppConfiguration.UserActivity.watch,
userInfo: userInfo)
and
contentView.hitTest(tapLocation, with: nil)
becomes
contentView.hitTest(tapLocation)
and
document.closeWithCompletionHandler(nil)
becomes simply
document.close()
and a whole pile of optional "completion handler" arguments go away.
Swift SVN r31978
For methods with at least a single parameter, split the base name at
the last preposition, so long as there are no other verbs or gerunds
in between. This separates out the action of the method from the
description of the first parameter, the latter of which can still have
needless words removed. This is particularly fun with
appendBezierPath*:
func appendBezierPath(with _: NSRect)
func appendBezierPath(withPoints _: NSPointArray, count: Int)
func appendBezierPathWithOval(`in` _: NSRect)
func appendBezierPathWithArc(withCenter _: NSPoint, radius: CGFloat,
startAngle: CGFloat, endAngle: CGFloat, clockwise: Bool)
func appendBezierPathWithArc(withCenter _: NSPoint, radius: CGFloat,
startAngle: CGFloat, endAngle: CGFloat)
func appendBezierPathWithArc(from _: NSPoint, to: NSPoint, radius:
CGFloat)
func appendBezierPath(with _: NSGlyph, `in`: NSFont)
func appendBezierPath(withGlyphs _: UnsafeMutablePointer<NSGlyph>,
count: Int, `in`: NSFont)
func appendBezierPath(withPackedGlyphs _: UnsafePointer<Int8>)
@available(OSX 10.5, *)
func appendBezierPath(withRoundedRect _: NSRect, xRadius: CGFloat,
yRadius: CGFloat)
Note: "point" and "name" are terrible verbs.
Swift SVN r31976
When the prefix of a method/property name is restating the result
type, followed by "By" and then a gerund, drop everything up to the
gerund. For example:
func stringByAppendingString(string: String) -> String
becomes
func appending(string: String) -> String
Swift SVN r31683
The presence of a verb or preposition prior to the redundant part
provides a firm linguistic split that lets the actual argument fill in
for the reader. For other parts of speech (adjectives, especially)
it's awkward to transition from "reading part of the name" to "reading
the argument". This eliminates a significant number of bad omissions,
e.g., "setTextColor()" -> "setText()", and generally makes the
transformation more conservative.
Swift SVN r31656