Jordan Rose
1ef99c533c
omitNeedlessWords: don't bother lowercasing an intermediate name
...
All of the remaining name-matching logic is case-insensitive, and
the resulting name will have a stronger form of lowercasing applied
anyway, so we can leave the name with a leading uppercase letter in
its intermediate state. Slightly less pure, but also slightly less
code and slightly less memory use.
2019-10-16 19:55:47 -07:00
Jordan Rose
a5d521698c
omitNeedlessWords: separate BaseName in trailing type name matching
...
Method base names are where the most complicated logic is, so let's
split it out from the other cases a bit. Also makes early returns more
explicit.
No intended functionality change.
2019-10-16 19:55:47 -07:00
Jordan Rose
0f071e28ea
Simplify getPrepositionKind to isPreposition
...
No one was distinguishing directional and non-directional prepositions
anymore. No functionality change.
2019-10-16 19:55:46 -07:00
Jordan Rose
86de8b8257
omitNeedlessWords: Rename helper: omitTrailingTypeNameWithSpecialCases
...
Previously this was /also/ called 'omitNeedlessWords'. Rename it to
avoid confusion and better describe the particular step it's taking.
I don't love the "with special cases" but I think it's important to
note that this isn't an exact parallel of matchLeadingTypeName.
2019-10-10 10:48:14 -07:00
Jordan Rose
758e727e07
omitNeedlessWords: Use existing helpers getPriorStr and getRestOfStr
...
...rather than asking WordIterators for their position and then
immediately calling StringRef::substr.
No functionality change.
2019-10-10 10:48:13 -07:00
Jordan Rose
e1e885ed7d
omitNeedlessWords: delete accidentally dead code
...
StringRef::drop_back returns a new string instead of mutating the
existing one, so this check would never actually make a
difference. Drat.
2019-10-10 10:48:13 -07:00
Jordan Rose
42f7a35c4d
omitNeedlessWords: sink helper enum into .cpp file
...
No functionality change.
2019-10-10 10:48:12 -07:00
Jordan Rose
3fdbd1b154
omitNeedlessWords: split out BaseNameSelf omission
...
This is the only omission kind that needs to look in the middle of a
name rather than just at the start or the end. So, handle that
explicitly instead to simplify all the other code.
2019-10-10 10:48:12 -07:00
Jordan Rose
981d1a9fab
omitNeedlessWords: Factor out matchTypeNameFromBackWithSpecialCases
...
Separate the functional searching bit from the actual "omitting" bit
once the type name is matched. This in turn provides a good place to
flip from reverse iterators back to forward iterators, making the
following code about omitting a fair bit clearer.
No functionality change. This is 90% moving things around and 10%
rephrasing.
2019-10-10 10:48:11 -07:00
Jordan Rose
e22d55d27b
omitNeedlessWords: Early exit instead of using a big if
...
Also, use Optional instead of a value and a separate flag.
No functionality change.
2019-10-10 10:48:11 -07:00
Sam Lazarus
2a38b48eea
Parse / AST: Allow let / var as argument labels with a warning.
...
The diagnostic is now a warning and the new message alerts the user that
though it is valid to have let and var as argument label names,
they are interpreted as argument labels, not keywords.
2019-04-26 04:08:01 -04:00
Sho Ikeda
b506cbadb2
Merge pull request #15205 from ikesyo/stringextras-stringswitch
...
[NFC][StringExtras] Use llvm::StringSwitch in canBeArgumentLabel as with canBeMemberName
2018-03-16 11:58:28 +09:00
Sho Ikeda
521b6598a7
[NFC][StringExtras] Use llvm::StringSwitch in canBeArgumentLabel as with canBeMemberName
2018-03-14 00:59:39 +09:00
Sho Ikeda
eaf33e0998
[gardening][lib/Basic] Replace typedef with using
2018-03-13 13:46:38 +09:00
Hugh Bellamy
f001b7562b
Use relatively new LLVM_FALLLTHROUGH instead of our own SWIFT_FALLTHROUGH
2017-02-12 10:47:03 +07:00
practicalswift
6d1ae2a39c
[gardening] 2016 → 2017
2017-01-06 16:41:22 +01:00
Michael Gottesman
16165482f4
[gardening] Eliminate dead never read variable. Found with clang-tidy.
2016-12-06 23:54:23 -08:00
Michael Gottesman
1af1cbfb76
[gardening] Add a bunch of end namespace comments found by clang-tidy.
2016-12-06 19:22:52 -08:00
practicalswift
797b80765f
[gardening] Use the correct base URL ( https://swift.org ) in references to the Swift website
...
Remove all references to the old non-TLS enabled base URL (http://swift.org )
2016-11-20 17:36:03 +01:00
practicalswift
17503b0d85
[gardening] Use American English.
2016-11-06 10:12:04 +01:00
Robert Widmann
6accc5989e
Disable the ability to use '$' as an identifier harder
...
When in Swift 3 Compatibility Mode we now acceptable a standalone
'$' as an identifier. In all other cases this is now disallowed
and must be surrounded by backticks.
2016-10-27 16:51:18 -04:00
Joe Groff
aac85cb93f
SIL: Introduce a 'closure' convention for unapplied invocation functions.
...
We don't want the machine calling conventions for closure invocation functions to necessarily be tied to the convention for normal thin functions or methods. NFC yet; for now, 'closure' follows the same behavior as the 'method' convention, but as part of partial_apply simplification it will be a requirement that partial_apply takes a @convention(closure) function and a box and produces a @convention(thick) function from them.
2016-10-17 15:55:04 -07:00
Ben Langmuir
04107ed8b2
Revert "[omit-needless-words] Fix a bug found by -Wunused-result"
2016-09-14 14:27:32 -07:00
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