Commit Graph

153 Commits

Author SHA1 Message Date
Ben Langmuir
7562c10333 [omit-needless-words] Fix a bug found by -Wunused-result
StringRef::drop_back() returns the new string; it doesn't mutate `this`.
2016-09-14 13:52:59 -07:00
Robert Widmann
9c83e7223e Fixup diagnostics around type(of:) and dynamicType handling
Be laxer about the parsing for type(of:) so as not to get in the way of
other declarations that may use ‘type’ as their base name.
2016-07-30 03:24:05 -07:00
Doug Gregor
5bea187b0f [Omit needless words] Fix lowercasing of initialisms with two-letter initial words.
Fixes rdar://problem/26643039.
2016-06-13 18:15:43 -07:00
Doug Gregor
7b226ad177 [Omit Needless Words] Don't remove a first argument label when the parameter has as default argument.
Parameters that have default arguments should have argument labels;
don't remove them on import. Fixes rdar://problem/26611977.
2016-06-13 11:58:41 -07:00
Doug Gregor
1d39707311 [Omit needless words] Don't split "PlugIn".
Fixes rdar://problem/26334014.
2016-06-12 23:13:01 -07:00
Doug Gregor
c390c97255 [Clang importer] Minor fixes for swift_newtype name adjustments. 2016-05-07 14:44:48 -07:00
Doug Gregor
b6c68449a7 [Omit needless words] Don't avoid keywords that will be allowed after '.'.
In anticipation of SE-0071, teach the Clang importer to only avoid
dynamicType/self/Protocol/init as base names. Fixes
rdar://problem/25399965.
2016-04-26 17:02:35 -07:00
Doug Gregor
a82cc07ee0 [Omit needless words] Strip context from "set" methods.
Fixes rdar://problem/25750367.
2016-04-26 16:42:35 -07:00
Doug Gregor
6e680798ae [Omit needless words] Treat "separated by" as a single preposition.
Fixes rdar://problem/25883450.
2016-04-26 16:05:08 -07:00
Doug Gregor
97e89471fe [Omit needless words] Treat "bound by" as a preposition.
Fixes rdar://problem/25729953.
2016-04-26 15:23:55 -07:00
Michael Ilseman
71e5b17efb [String Extras] fix escaping value bug 2016-03-10 10:49:19 -08:00
Michael Ilseman
32faa62502 [Import as member] Lower case initialisms 2016-03-09 14:26:43 -08:00
Doug Gregor
87f1d577a3 [Omit needless words] Retain "with" after splitting more regularly.
The verb-based heuristic was unpredictable and not clearly
better. Back off to something more obvious.
2016-02-29 13:14:24 -08:00
Doug Gregor
b890e4c29f [Omit needless words] Use the property lists to restrict BaseNameSelf pruning.
This eliminates some apparent inconsistencies in the translation,
fixing rdar://problem/24860176.
2016-02-29 13:14:23 -08:00
Doug Gregor
5290a381b4 [Omit needless words] Stop moving "of" onto the base name.
The benefits from moving "of" onto the base name were outweighed by
the complications to the API guidelines.
2016-02-23 10:24:03 -08:00
Doug Gregor
4e16f625b1 [Omit needless words] "de-" is a verb prefix.
... and handle verb prefixes properly.
2016-02-22 14:11:09 -08:00
Doug Gregor
24cede9543 [Omit needless words] Treat "Mask" as a skippable type suffix.
Fixes rdar://problem/23751733.
2016-02-22 11:39:20 -08:00
Doug Gregor
bc18e4521b [Omit needless words] After "by", recognize gerunds more liberally. 2016-02-12 16:40:10 -08:00
Doug Gregor
0e46850a66 [Omit needless words] "ObjectValue" in the name matches "Object" in the type.
Fixes rdar://problem/24618946.
2016-02-12 12:41:40 -08:00
Doug Gregor
a87782e414 [Omit needless words] Handle "extended prepositions" like "compatible with".
Also, be more careful not to produce base names that are keywords.
2016-02-12 10:33:59 -08:00
Doug Gregor
90af7e60e7 [Omit needless words] "Of" associates left except when determining properties of the result. 2016-02-11 16:44:05 -08:00
Doug Gregor
e720333032 [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.
2016-02-11 16:44:05 -08:00
Doug Gregor
643725f75a [Omit needless words] The preposition "of" binds to the word preceding it. 2016-02-11 16:44:05 -08:00
Doug Gregor
a024fe0115 [Omit needless words] Split at a preposition before "of", if one exists.
This helps for cases such as "appendWithContentsOfFoo", where
"contentsOf" or "contentsOfFoo" is a better argument label than "foo"
or "ofFoo".
2016-02-11 16:44:05 -08:00
Doug Gregor
850e0e2fc3 [Omit needless words] Skip over verbs and gerunds when looking for a preposition. 2016-02-11 16:44:04 -08:00
Doug Gregor
720d67faf4 [Omit needless words] Split out find-last-preposition. NFC 2016-02-11 16:44:04 -08:00
Doug Gregor
55b406a20d [Omit needless words] Stop preventing argument labels named "for", "with", or other vacuous words.
Fixes rdar://problem/23752046.
2016-02-11 16:44:04 -08:00
practicalswift
7d67f58e1f [gardening] Fix recently introduced typo: "prposition" → "preposition" 2016-02-11 19:12:49 +01:00
Doug Gregor
050b324593 [Omit needless words] Split before last preposition in most cases.
Splitting *before* the last preposition tends to keep the
prepositional phrase together. Only leave the preposition on the base
name in rare cases where we would end up with weird argument labels
(e.g., prefer "moveTo(x:y:)" to "move(toX:y:)").

Also, refine our heuristics for when we can remove the preposition
entirely.
2016-02-10 14:20:44 -08:00
Doug Gregor
0533f6158d [Omit needless words] Move a paired preposition into the first argument label.
If the second argument label starts with a preposition for a split
selector, move the preposition into the first argument label. For
example:

-  func transitionFrom(fromViewController: NSViewController, to
toViewController: NSViewController, options:
NSViewControllerTransitionOptions = [], completionHandler completion:
(() -> Void)? = nil)
+  func transition(from fromViewController: NSViewController, to
toViewController: NSViewController, options:
NSViewControllerTransitionOptions = [], completionHandler completion:
(() -> Void)? = nil)
2016-02-08 22:41:16 -08:00
Doug Gregor
8a3a2958e7 [Omit needless words] Improve our handling of plural acronyms. 2016-02-08 22:41:16 -08:00
Doug Gregor
32b0c8c4a8 [Omit needless words] "No" conflicts after "With". 2016-02-08 22:41:15 -08:00
Doug Gregor
d03d831e1e [Omit needless words] Drop split preposition if the first parameter is defaulted. 2016-02-08 16:23:27 -08:00
Doug Gregor
c04a67ae4c [Omit needless words] Don't split setters, "action-like" methods.
Suggested by Brent Royal-Gordon.
2016-02-07 21:40:10 -08:00
Doug Gregor
e05cf6e018 [Omit needless words] Split first selector piece into base name/first argument label. 2016-02-05 23:03:36 -08:00
Doug Gregor
bd8fc9614e [Omit needless words] Match type/name words ignoring case 2016-02-05 22:27:45 -08:00
Doug Gregor
1dec2f1f34 [Clang importer] After stripping a prefix, lowercase initialisms as well. 2016-02-03 16:11:59 -08:00
Doug Gregor
b9955404c8 [Clang importer] Lowercase plural initialisms correctly.
URLs -> urls rather than urLs.
2016-01-27 16:38:11 -08:00
Doug Gregor
769b41e240 [Omit needless words] Prune redundant "self" type following a verb in the base name.
This allows us to prune UIViewController's
"dismissViewControllerAnimated" to "dismissAnimated", eliminating
unnecessary redundancy.
2016-01-19 10:34:23 -08:00
Doug Gregor
e380184cf3 [Omit needless words] Don't strip just "Error". 2016-01-18 22:06:42 -08:00
Doug Gregor
4d2480086e [Omit needless words] Use the getter name for BOOL properties.
Rather than employ complicated heuristics to determine when to add
"is" to the name of a Booleam property, just trust the name of the
getter.
2016-01-05 10:43:32 -08:00
Doug Gregor
bfba3a7968 [Omit needless words] Fix lowercasing of initialisms ending with a non-letter.
Lowercases "UTF8String" to "utf8String" rather than "utF8String".
2016-01-04 16:45:31 -08:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Doug Gregor
c8dd8d0661 Implement SE-0001: Allow (most) keywords as argument labels.
Allow all keywords except for parameter introducers (var/let/inout) to
be argument labels when declaring or calling a
function/initializer/subscript, e.g., this

  func touchesMatching(phase: NSTouchPhase, `in` view: NSView?) -> Set<NSTouch>

can now be expressed as

  func touchesMatching(phase: NSTouchPhase, in view: NSView?) -> Set<NSTouch>

and the call goes from

  event.touchesMatching(phase, `in`: view)

to

  event.touchesMatching(phase, in: view)

Fixes [SR-344](https://bugs.swift.org/browse/SR-344) /
rdar://problem/22415674.
2015-12-22 16:18:28 -08:00
Doug Gregor
1e432568bc Clang importer: Swift 2 lowercased subsequent argument names coming from Objective-C selectors. Mimic this. 2015-12-03 11:50:43 -08:00
Doug Gregor
2ea58f93b0 Clang importer: handle CF type renaming in importFullName.
Ensures that the Swift lookup tables get transformed name for imported
CF types, including original name (which is still
available). Otherwise, this is an NFC refactoring that gets the last
of the naming tricks into importFullName.
2015-12-03 11:50:43 -08:00
Doug Gregor
106bf80152 Omit needless words: don't prune "properties" of the context from the base name.
The properties of a context indicate those things that are considered
"contained within" the context (among other things). This helps us
avoid producing overly-generic names when we identify a redundancy in
the base name. For example, NSView contains the following:

  var gestureRecognizers: [NSGestureRecognizer]
  func addGestureRecognizer(gestureRecognizer: NSGestureRecognizer)
  func removeGestureRecognizer(gestureRecognizer: NSGestureRecognizer)

Normally, omit-needless-words would prune the two method names down to
"add" and "remove", respectively, because they restate type
information. However, this pruning is not ideal, because a view isn't
primarily a collection of gesture recognizers.

Use the presence of the property "gestureRecognizers" to indicate that
we should not strip "gestureRecognizer" or "gestureRecognizers" from
the base names of methods within that class (or its subclasses).

Note that there is more work to do here to properly deal with API
evolution: a newly-added property shouldn't have any effect on
existing APIs. We should use availability information here, and only
consider properties introduced no later than the entity under
consideration.
2015-11-16 15:27:38 -08:00
Doug Gregor
8a044152da Omit needless words: lowercase the initial words of all names, including acroynums.
Cocoa's naming guidelines use lowercase initial words for selector
pieces and property names except when the first word is an
acronym. Force the first word of all imported APIs to be lowercase,
including acronyms.

Swift SVN r32719
2015-10-16 06:28:03 +00:00
Doug Gregor
f8b246980a Omit needless words: drop "with" from the beginning of first argument labels.
For example, copy(withZone:) becomes copy(zone:).

Swift SVN r32708
2015-10-15 18:53:51 +00:00
Doug Gregor
382746cd0d Omit needless words: stop splitting first selector pieces for Boolean parameters.
Swift SVN r32692
2015-10-14 23:29:20 +00:00