Commit Graph

1181 Commits

Author SHA1 Message Date
Nathan Hawes
d60116d11a [CodeCompletion] Remove unused forward declaration and fix up an out-of-date comment (NFC) 2020-09-08 17:02:31 -07:00
Nathan Hawes
9b8fb7d37d [CodeCompletion] Rename a few types/methods for clarity plus other small refactorings (NFC)
Also put subclasses of TypeCheckCompletionCallback into their own header.
2020-09-08 16:16:39 -07:00
Nathan Hawes
ee660c6dee [CodeCompletion] Remove old DotExpr completion handling code - it's unreachable now. 2020-09-08 11:43:12 -07:00
Suyash Srijan
db6e3af002 [IDE] Fix a typo (#33841) 2020-09-08 17:32:07 +01:00
Nathan Hawes
491b691dbc [CodeCompletion][NFC] Add doc comments and rename symbols for clarity in the new member completion implementation. 2020-09-01 15:04:42 -07:00
Rintaro Ishizaki
679aaca7ed Merge pull request #33601 from LucianoPAlmeida/SR-13426-code-completion-keypath-optional
[CodeCompletion] Do not offer completion Wrapped members for optional key path root type
2020-09-01 11:36:10 -07:00
Luciano Almeida
ecc5b90aa5 [CodeCompletion] Do not erase dot for code completion key path optiona root unwrapped members 2020-09-01 12:33:00 -03:00
Nathan Hawes
6e657e8615 [CodeCompletion] Fix incorrect type relations in complete_enum_elements test.
We were reporting methods that return function types that return void (rather
than returning void directly) as being invalid in contexts that expect non-void
expressions and testing for that incorrect behavior.
2020-08-28 22:24:24 -07:00
Nathan Hawes
5100de4293 [CodeCompletion] Fallback to typechecking just the completion expression in cases where typeCheckExpression is never called.
This happens when, e.g. an expression being switched on is invalid so
expression patterns in the switch cases (which may contain the completion
expression) are not checked.

Also setup the Lookup object to handle member completion in ObjC selector
expressions correctly, and fix passing the wrong expression when computing
isStaticallyDerivedMetatype().
2020-08-28 22:24:23 -07:00
Nathan Hawes
3d8561502b [CodeCompletion] Move CompletionCollector to ASTContext + bug fixes. 2020-08-28 22:24:23 -07:00
Nathan Hawes
fe9df72d55 [CodeCompletion] Add initial implementation of solver-based member completion.
This hooks up member completion to the new typeCheckForCodeCompletion API to
generate completions from all solutions the constraint solver produces (include
ones requiring fixes) rather than relying purely the single solution being
applied to the AST (if any). This lets us still give completion results in
ambiguous and invalid code.
2020-08-28 22:24:23 -07:00
Nathan Hawes
cf60b2fe61 [CodeCompletion] Pass the CodeCompletionExpr rather than just the base expression to the DotExpr completion callback. 2020-08-28 22:24:22 -07:00
Frederick Kellison-Linn
db33dfa3a1 [IDE] Offer unresolved member completions with non-matching types
Since the user can now write additional member accesses off of an UnresolvedMemberExpr, we should offer all available completions rather than just those that match the contextual type.
2020-08-26 22:42:30 -04:00
Anthony Latsis
492156c10f Remove SubscriptDecl::getBodyResultTypeLoc 2020-08-19 00:09:10 +03:00
Robert Widmann
b50a2cf430 Merge pull request #33251 from AnthonyLatsis/type-locura-1
Rid performTypeLocChecking of TypeLoc
2020-08-04 12:04:10 -07:00
Anthony Latsis
7bcc4baa33 [NFC] TypeLoc: Rid performTypeLocChecking off TypeLoc 2020-08-04 19:15:55 +03:00
Varun Gandhi
3882beb85d [NFC] Use consistent naming scheme for predicate methods. (#33265)
bool throws() -> isThrowing(), bool async() -> isAsync()
2020-08-03 16:37:29 -07:00
Slava Pestov
b4ea644910 IDE: Replace some calls to getDeclaredType() with getDeclaredInterfaceType() 2020-07-31 13:39:02 -04:00
Rintaro Ishizaki
dab216dc49 [CodeCompletion] Use TypeContextInfo to get expected return types
If the type check return type from the context has unresolved types, it
can't be used for checking convertibility. Fallback to get
'TypeContextInfo' of the closure position.

rdar://problem/66002497
2020-07-23 14:34:54 -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
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
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
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
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
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
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
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
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
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
Rintaro Ishizaki
f21279efad Merge pull request #32053 from rintaro/ide-completion-sself-rdar61307680
[CodeCompletion] Suggest 'Self' inside struct, enum and classe
2020-06-02 17:27:01 -07:00
Rintaro Ishizaki
65b8cf76f3 Merge pull request #32086 from rintaro/ide-completion-skipbody-rdar58687608
[CodeCompletion] Skip type checking unrelated statements in function body
2020-06-02 17:10:07 -07:00
Rintaro Ishizaki
3b97b8647c [CodeCompletion] Suggest 'Self' inside struct, enum and classe
In 'protocol', 'Self' is implicitly declared as a generic parameter.
In 'struct' and 'enum', 'Self' is just an alias for the nominal type.
In 'class', 'Self' is a dynamic type and usable only in result types and
inside function bodies.

rdar://problem/61307680
2020-06-02 14:58:10 -07:00
Rintaro Ishizaki
e6ce361042 [CodeCompletion] Rename typeCheckContextUntil to typeCheckContextAt 2020-06-01 12:36:39 -07:00
Anthony Latsis
9fd1aa5d59 [NFC] Pre- increment and decrement where possible 2020-06-01 15:39:29 +03:00
Rintaro Ishizaki
3e200b7783 [CodeCompletion] Skip typechecking unrelated statements in func bodies
rdar://problem/58687608
2020-05-29 14:45:04 -07:00
Rintaro Ishizaki
af27e8f183 [CodeCompletion] Avoid suggesting duplicated module names
in global completion result. Overly modules have the same name as the
shadowed modules. We should not list both names because they are
identical.

Maintain a set of seen module names to avoid suggesting duplicated
names.

rdar://problem/63370253
2020-05-19 15:18:34 -07:00
Anthony Latsis
44a92a926c [NFC] GenericSignatureImpl: Spell conformsToProtocol & getConformsTo in terms of requirements 2020-05-14 22:51:44 +03:00
Rintaro Ishizaki
7e170ded66 [CodeCompletion] Remove unused parameter from a couple of lambda 2020-05-12 10:42:04 -07:00
Rintaro Ishizaki
ecfd369f35 [CodeCompletion] Typo: 'getAnnnoateResult' -> 'getAnnotateResult' 2020-05-12 10:33:45 -07:00
Rintaro Ishizaki
7086ffb79f [CodeCompletion] Annotated result type
Introduced 'TypeAnnotationBegin' chunk kind for grouping the result type
name chunks.

rdar://problem/62617558
2020-05-11 22:56:22 -07:00
Rintaro Ishizaki
75a0c9f819 [CodeCompletion] Add 'IsSystem' flag to code completion result item
'key.is_system: 1' is added if the associated declaration is from a
system module.

rdar://problem/62617558
2020-05-11 12:24:36 -07:00
Ben Langmuir
37b98af4e6 [CodeCompletion] Pre-expand closures in argument completion
When completing a single argument for a trailing closure, pre-expand the
closure expression syntax instead of using a placeholder. It's not valid
to pass a non-closure anyway.

rdar://62189182
2020-05-06 01:56:41 -04:00
Rintaro Ishizaki
7407a8092d [CodeCompletion] Postfix expr completion after trailing closures 2020-05-06 01:56:41 -04:00
Rintaro Ishizaki
1cbb1e76d4 [CodeCompletion] Update for braceless multiple trailing closure 2020-05-06 01:56:41 -04:00
Rintaro Ishizaki
fd68f092f2 [CodeCompletion] Completion inside multiple trailing closure
rdar://problem/59688477
2020-05-06 01:56:40 -04:00