Commit Graph

2971 Commits

Author SHA1 Message Date
Nathan Hawes
e68ab1da8e [SourceKit/DocSupport] Don't synthesize extensions for inherited protocol conformances.
The Base class already includes them, so don't duplicate them in its
subclasses. Also stops us including members from extensions of the base class
itself.

Resolves rdar://problem/50960433
2020-07-21 11:53:06 -07:00
Nathan Hawes
9d4ed5f39c Manually merge remote-tracking branch 'upstream/master' into manually-merge-master-to-master-rebranch 2020-07-20 16:09:55 -07:00
Suyash Srijan
58a84ea4c1 [NFC] Cleanup some code to use 'swift::getParameterList(ValueDecl)' to fetch parameter lists (#32979) 2020-07-20 19:50:37 +01:00
Brent Royal-Gordon
4394e92c3f Merge pull request #32700 from brentdax/magical-and-evolutionary
Revise #file changes from SE-0274
2020-07-17 01:57:23 -07:00
Rintaro Ishizaki
f7fc1ed7b5 [CodeCompletion] Fix a crash in CCExprRemover
- Handle cases where getArgumentLabelLocs().size() == 0
- Add some assertions to verify invariants
- Explicit handling of 'llvm::Optional' for 'getUnlabeledTrailingClosureIndex()'
- Avoid walking into nodes after the removing happens

rdar://problem/65556791
2020-07-15 09:56:20 -07:00
Brent Royal-Gordon
9a838bb654 Differentiate between Swift 5 and “Swift 6” #file
In -swift-version 5 and earlier, #file will continue to be a synonym for #filePath; in a future -swift-version (“Swift 6 mode”), it will become a synonym for #fileID. #file in libraries will be interpreted according to the language mode the library was compiled in, not the language mode its client uses.

Implement this behavior, tied to a frontend flag instead of a language version. We do so by splitting the old `MagicIdentifierLiteralExprKind::File` into two separate cases, `FileIDSpelledAsFile` and `FilePathSpelledAsFile`, and propagating this distinction throughout the AST. This seems cleaner than looking up the setting for the module the declaration belongs to every time we see `File`.

This doesn’t handle module interfaces yet; we’ll take care of those in a separate commit.
2020-07-13 14:06:55 -07:00
Brent Royal-Gordon
acc01aea03 [NFC] Add MagicIdentifierKinds.def
Extracts the list of magic identifier literal kinds into a separate file and updates a lot of code to use macro metaprogramming instead of naming half a dozen cases manually. This is a complicated change, but it should be NFC.
2020-07-13 14:05:13 -07:00
Brent Royal-Gordon
672bd40866 Enable #filePath code completion (and fix a bug)
The meaning of EnableConcisePoundFile is going to shift slightly, so it makes sense to always include #filePath in completions. Also, @rintaro confirmed that this should be using KeywordKind::pound_filePath, not KeywordKind::pound_file.
2020-07-13 14:05:13 -07:00
Rintaro Ishizaki
5cd5a18ffe Merge pull request #32806 from rintaro/ide-completion-rdar61765124
[CodeCompletion] Safer getEquivalentDeclContextFromSourceFile()
2020-07-10 10:43:47 -07:00
Rintaro Ishizaki
185317f722 Merge pull request #32779 from rintaro/ide-completion-closureplaceholder-rdar63607976
[PlaceholderExpansion] Omit return type in closure signature
2020-07-09 21:20:25 -07:00
Rintaro Ishizaki
09f461bdbd [CodeCompletion] Safer getEquivalentDeclContextFromSourceFile()
There seems to be case where parentDC->getAsDecl() returns nullptr.
I haven't been able to find a reproducer.

rdar://problem/61765124
2020-07-09 19:18:35 -07:00
Nathan Hawes
962e0bbd56 Merge pull request #32606 from nathawes/prefer-macOS-to-OSX-spelling-when-printing-platform
[AST] Prefer the 'macOS' spelling over 'OSX' when printing the platform kind.
2020-07-09 17:11:27 -07:00
Rintaro Ishizaki
17be66c3d6 [PlaceholderExpansion] Omit return type in closure signature
Return type in the closure signature is often redundant when expanding
placeholders, because the type of the clossures are usually inferred
from the context (i.e. calling function), users don't need to write the
return type explicitly.

They are not only redundant, but also sometimes harmful when the return
type is a generic parameter or its requirement. Actually, there is no
correct spelling in such cases.

So omit the return type and the parentheses around the parameter clause.

rdar://problem/63607976
2020-07-09 14:37:17 -07:00
Nathan Hawes
244dc4a768 [AST] Rename PlatformKind::OSX to PlatformKind::macOS
Because the names are coming from a .def file used for printing too, this
simplifies the printing logic as well.
2020-07-08 16:29:31 -07:00
Rintaro Ishizaki
a778f517d1 [CodeCompletion] Remove redundant entries from possible callee analysis
This used to cause duplicated results in call signature completions.
i.e.:

  AlertViewController(#^HERE^# // 2 x (coder: NSCoder)

rdar://problem/65081358
2020-07-08 14:30:32 -07:00
Nathan Hawes
9bcb54910e [AST] Prefer the 'macOS' spelling over 'OSX' when printing the platform kind.
This affects module interfaces, interface generation in sourcekitd, and
diagnostics. Also fixes a fixit that was assuming the 'OSX' spelling when
computing the source range to replace.

Resolves rdar://problem/64667960
2020-07-08 13:51:25 -07:00
swift_jenkins
465eae8559 Merge remote-tracking branch 'origin/master' into master-next 2020-06-30 08:58:09 -07:00
Hamish Knight
5c27465a86 Merge pull request #32601 from hamishknight/not-yet-over-and-out 2020-06-30 08:49:53 -07:00
Hamish Knight
7bc5440d17 [Frontend] Internalize createDependencyTracker
Expand the FrontendOptions to allow the enabling
of the dependency tracker for non-system
dependencies, and switch the previous clients of
`createDependencyTracker` over to using this
option. This ensures that the dependency tracker
is now set only during `CompilerInstance::setup`.
2020-06-29 15:26:26 -07:00
swift_jenkins
3c4e9533a0 Merge remote-tracking branch 'origin/master' into master-next 2020-06-29 15:19:28 -07:00
Nathan Hawes
f24571797c [SourceKit/CodeFormat] Fix multi-line array literal elements not indenting relative to their first line.
doStuffWithList([
    firstItem
    .map { $0 }       // This line should be indented further.
    .append(\.foo),   // And so should this one.
    secondItem
])

Resolves rdar://problem/64834040
2020-06-26 21:18:19 -07:00
swift_jenkins
f7b349f97e Merge remote-tracking branch 'origin/master' into master-next 2020-06-24 13:59:28 -07:00
Nathan Hawes
603ca955ad Merge pull request #32513 from nathawes/fix-indentation-after-incomplete-func-decl
[SourceKit/Indentation] Fix over-indent after function decl with no param list or body.
2020-06-24 13:47:57 -07:00
swift_jenkins
f503f422cc Merge remote-tracking branch 'origin/master' into master-next 2020-06-24 09:39:10 -07:00
Rintaro Ishizaki
f50b66689e [CodeCompletion] Fallback to nominal member completion after trailing closure
After trailing closure, we perform "Labeled trailing closure" completion
and fall back to other completion depending on the position.

If the completion happens at a newline position, it used to fallback to
global expression completion, but in type context, we should do override
completion instead.

Also, we didn't use to propagate 'hasCodeCompletion()' status properly.

rdar://problem/64650782
2020-06-24 01:04:33 -07:00
Nathan Hawes
436d47518a [SourceKit/Indentation] Fix over-indent after function declaration with no param list or body. 2020-06-23 13:22:08 -07:00
swift_jenkins
75bea14185 Merge remote-tracking branch 'origin/master' into master-next 2020-06-23 10:39:14 -07:00
Robert Widmann
0da060e95e Merge pull request #32447 from martinboehme/option-set-initializer-list
Give OptionSet an initializer_list constructor
2020-06-23 10:36:57 -07:00
Martin Boehme
d806ba53f6 Give OptionSet an initializer_list constructor.
This makes it easier to specify OptionSet arguments.

Also modify appropriate uses of ModuleDecl::ImportFilter to take
advantage of the new constructor.
2020-06-22 06:57:29 +02:00
swift_jenkins
518bbb3d40 Merge remote-tracking branch 'origin/master' into master-next 2020-06-17 16:39:22 -07:00
Rintaro Ishizaki
6a8d2920b8 Merge pull request #32440 from rintaro/ide-completion-platform-rdar64379019
[CodeCompletion] Suggest 'macOS' instead of 'OSX'
2020-06-17 16:27:30 -07:00
Rintaro Ishizaki
d4da603960 [CodeCompeltion] Suggest 'macOS' instead of 'OSX'
'macOS' is the preferred name for specifying the platform. Since 'OSX'
is deprecated, we don't need to suggest 'OSX' variants.

rdar://problem/64379019
2020-06-17 14:09:25 -07:00
swift_jenkins
cecdf896a7 Merge remote-tracking branch 'origin/master' into master-next 2020-06-17 13:38:42 -07:00
Suyash Srijan
b1b60fbbda [Refactoring] Create 'AddEquatableContext' with extension only when there is an extended nominal declaration (#32435) 2020-06-17 21:33:22 +01:00
swift_jenkins
9cb4f90b57 Merge remote-tracking branch 'origin/master' into master-next 2020-06-16 13:58:29 -07:00
Rintaro Ishizaki
5db0f1a40b [CodeCompletion] Typecheck without CodeCompletionExpr
when falling back to "postfix expression completion" after labeled
trailing closure completion.

rdar://problem/64176730
2020-06-15 21:40:40 -07:00
swift_jenkins
792953c703 Merge remote-tracking branch 'origin/master' into master-next 2020-06-11 09:18:39 -07:00
Rintaro Ishizaki
552134a06d Merge pull request #32276 from rintaro/ide-conformingmethods-disablelabeledtrailingclosure-rdar63781922
[SourceKit] Disable labeled trailing closure completion support except code completion
2020-06-11 08:59:37 -07:00
swift_jenkins
abb1d170fc Merge remote-tracking branch 'origin/master' into master-next 2020-06-11 00:38:31 -07:00
Robert Widmann
fb8fdd9644 Replace resolveCustomAttrType with a Request 2020-06-10 19:31:41 -07:00
swift_jenkins
341070e163 Merge remote-tracking branch 'origin/master' into master-next 2020-06-10 14:58:36 -07:00
Nathan Hawes
41758c047c Merge pull request #32148 from nathawes/doc-info-underscored-protocol-synthesised-extensions
[IDE][SourceKit/DocSupport] Add members of underscored protocol extensions in extensions of conforming types.
2020-06-10 14:49:18 -07:00
swift_jenkins
73e4e60598 Merge remote-tracking branch 'origin/master' into master-next 2020-06-10 10:20:02 -07:00
Robert Widmann
c7efed93ba Merge pull request #32285 from CodaFi/escape-velocity
[Refactoring] Print @escaping For Closures In Generated Memberwise Initializer
2020-06-10 10:02:38 -07:00
swift_jenkins
d4bb5d50b3 Merge remote-tracking branch 'origin/master' into master-next 2020-06-09 18:18:16 -07:00
Robert Widmann
0d1f6ae8bb Print @escaping For Closures In Generated Memberwise Initializer
Augment the "generate memberwise initializer" refactoring action to
automatically print @escaping in parameter position. Closures as stored
properties always escape.

rdar://62202381
2020-06-09 17:21:28 -07:00
Rintaro Ishizaki
67e88f4f26 [SourceKit] Disable labeled trailing closure support except code completion
Don't insert CodeCompletionExpr at the cursor position in
"conforming method list" or "typecontext" mode. This increase the chance
of successful type checking.

rdar://problem/63781922
2020-06-09 13:02:03 -07:00
Rintaro Ishizaki
38d8b13520 [CodeCompletion] Add keypath apply subscript after open bracket
rdar://problem/61016147
2020-06-09 11:04:02 -07:00
Karoy Lorentey
57ea964f2c Merge commit '3eb82c183662945687f48e11c09828f551b34858' into master-next
# Conflicts:
#	include/swift/Frontend/FrontendInputsAndOutputs.h
2020-06-08 16:58:37 -07:00
Karoy Lorentey
68351d2110 Revert "Merge remote-tracking branch 'origin/master-next'"
This reverts commit 1c9b0908e6, reversing
changes made to 3eb82c1836.
2020-06-08 16:48:38 -07:00