Omit needless words: only omit words when they are preceded by a verb or preposition.

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
This commit is contained in:
Doug Gregor
2015-09-03 05:04:11 +00:00
parent d4109f125f
commit 8ce50fbd76
7 changed files with 856 additions and 59 deletions

View File

@@ -36,6 +36,16 @@ namespace swift {
/// ignoring case.
PrepositionKind getPrepositionKind(StringRef word);
/// Describes the part of speech of a particular word.
enum class PartOfSpeech {
Unknown,
Preposition,
Verb
};
/// Determine the part of speech for the given word.
PartOfSpeech getPartOfSpeech(StringRef word);
namespace camel_case {
class WordIterator;
@@ -252,7 +262,7 @@ enum class NameRole {
FirstParameter,
// Subsequent parameters in a function or method.
SubsequentParameter,
SubsequentParameter,
// The name of a property.
Property,