Commit Graph

1365 Commits

Author SHA1 Message Date
Rintaro Ishizaki
be7466eb3f [CodeCompletion] Annotate 'async' functions/initializers in results
Similar to how it shows "throws" today.

Introduced CodeCompletionStringChunk::ChunkKind::AsyncKeyword

rdar://problem/72198530
2020-12-14 11:03:24 -08:00
Rintaro Ishizaki
82eca57e13 [CodeCompletion] Complete 'await' in expression position
rdar://problem/72199267
2020-12-11 11:53:32 -08:00
Richard Wei
de2dbe57ed [AutoDiff] Bump-pointer allocate pullback structs in loops. (#34886)
In derivatives of loops, no longer allocate boxes for indirect case payloads. Instead, use a custom pullback context in the runtime which contains a bump-pointer allocator.

When a function contains a differentiated loop, the closure context is a `Builtin.NativeObject`, which contains a `swift::AutoDiffLinearMapContext` and a tail-allocated top-level linear map struct (which represents the linear map struct that was previously directly partial-applied into the pullback). In branching trace enums, the payloads of previously indirect cases will be allocated by `swift::AutoDiffLinearMapContext::allocate` and stored as a `Builtin.RawPointer`.
2020-11-30 15:49:38 -08:00
Nathan Hawes
240a26244d [CodeCompletion] Rename isSingleExpressionBody to isImplicitSingleExpressionReturn for clarity
This bool was true only for single-expression closure and function bodies that
do not have an explicit `return` in the source. Rename it and its associated
methods, to avoid confusion with the hasSingleExpressionBody methods on
ClosureExpr and AbstractFuncDecl. Those don't care whether the expression was
explicitly written in the source or not.
2020-11-19 13:33:57 +11:00
Nathan Hawes
ca7fb37aba [CodeCompletion][Sema][Parse] Migrate unresolved member completion to the solver-based completion implementation
Following on from updating regular member completion, this hooks up unresolved
member completion (i.e. .<complete here>) to the typeCheckForCodeCompletion API
to generate completions from all solutions the constraint solver produces (even
those requiring fixes), rather than relying on a single solution being applied
to the AST (if any). This lets us produce unresolved member completions even
when the contextual type is ambiguous or involves errors.

Whenever typeCheckExpression is called on an expression containing a code
completion expression and a CompletionCallback has been set, each solution
formed is passed to the callback so the type of the completion expression can
be extracted and used to lookup up the members to return.
2020-11-13 15:37:14 -08:00
Pavel Yaskevich
51bd8d93d6 Merge pull request #34510 from maustinstar/sr-11711
[SR-11711]  [Parse] Single-expression implicit returns within #if declarations
2020-11-05 21:14:44 -08:00
Rintaro Ishizaki
d221f14215 [CodeCompletion] Deduplicate results in ExprContextInfo
Using canonical types. Otherwise 'Optional<T>' and 'T?' aren't
considered the same.

Also, for example, the expected context types are 'T?' and 'T', don't
get results from 'T' twice.

rdar://problem/71063455
2020-11-05 11:32:16 -08:00
maustinstar
f6c9769bf0 Statement setter for last element 2020-11-03 22:20:23 -05:00
maustinstar
37b17338e5 [SR-11711] Single-expression returns for #if declarations within functions 2020-11-03 12:47:39 -05:00
Ben Barham
95ae19255e [CodeCompletion] Do not include decl in own (string interp) initializer
Strings are a single token, so the previous check would treat
completions inside string interpolations as being outside of the
initializer.

Grab the end of the token from the Lexer, but wrap in a context check to
avoid performing that for every declaration found in the lookup.

Resolves rdar://70833348
2020-11-03 16:42:28 +10:00
Ben Barham
4cf7426698 [CodeCompletion] Do not include decl completion in its own initializer
`::lookupVisibleDecls` had an inline consumer in order to remove
"unusable" results. Refactor this method, moving the consumer (now
`UsableFilteringDeclConsumer`) to allow its use when looking up top
level module declarations.

Also use the `AccessFilteringDeclConsumer` in preference to a condition
in `addVarDecl`.

Resolves rdar://56755598
2020-11-02 08:49:05 +10:00
Nathan Hawes
62a5fb1698 [CodeCompletion] Dedupe completion results if multiple lookups were made.
Solver-based member completion performs a lookup per solution, but if the base
types in each solution are variations of the same generic (e.g. Array<Int>,
Array<String>), we can end up with the same result appearing twice (e.g. count)
2020-10-26 15:41:24 -07:00
Doug Gregor
6d41524fe6 [SE-0289] Finish renaming source code, tests to "result builders" 2020-10-20 22:18:51 -07:00
Doug Gregor
0d568a93d4 [SE-0289] Update diagnostics & many other strings to "result builders" 2020-10-20 21:44:09 -07:00
Brent Royal-Gordon
e843a16649 Merge pull request #33935 from brentdax/these-imports-are-testing-my-patience
Add -testable-import-module frontend flag (+ refactoring)
2020-10-11 12:49:09 -07:00
Brent Royal-Gordon
b440ab7331 [NFC] Move several types/functions to Import.h
To help consolidate our various types describing imports, this commit moves the following types and methods to Import.h:

* ImplicitImports
* ImplicitStdlibKind
* ImplicitImportInfo
* ModuleDecl::ImportedModule
* ModuleDecl::OrderImportedModules (as ImportedModule::Order)
* ModuleDecl::removeDuplicateImports() (as ImportedModule::removeDuplicates())
* SourceFile::ImportFlags
* SourceFile::ImportOptions
* SourceFile::ImportedModuleDesc

This commit is large and intentionally kept mechanical—nothing interesting to see here.
2020-10-09 18:57:07 -07:00
Nathan Hawes
a91cede79b [Parse][CodeCompletion] Don't special case code completion when forming single-expression closures/function bodies (NFC)
Code completion used to avoid forming single expression closures/function
bodies when the single expression contained the code completion expression
because a contextual type mismatch could result in types not being applied
to the AST, giving no completions.

Completions that have been migrated to the new solver-based completion
mechanism don't need this behavior, however. Rather than trying to guess
whether the type of completion we're going to end up performing is one of
the ones that haven't been migrated to the solver yet when parsing, instead
just always form single-expression closures/function bodies (like we do for
regular compilation) and undo the transformation if and when we know we're
going to perform a completion kind we haven't migrated yet.

Once all completion kinds are migrated, the undo-ing code can be removed.
2020-10-09 16:02:13 -07:00
Varun Gandhi
d3369f7711 [NFC] Rename ImportFilterKind cases to be clearer. 2020-09-23 12:50:20 -07:00
Rintaro Ishizaki
d669247cd1 Merge pull request #33978 from rintaro/ide-completion-settyperelation
[CodeCompletion] Calculate type relation when adding type annotation
2020-09-17 13:59:52 -07:00
Rintaro Ishizaki
ee7f4ad3ae [CodeCompletion] Merge shouldUseFunctionReference to addCompoundFunctionName 2020-09-16 22:49:48 -07:00
Rintaro Ishizaki
84f0c5723a [CodeCompletion] Calculate type relation when adding type annotation
Calculate and set the type relation in each result building logic which
knows the actual result type.

CodeCompletionResultBuilder couldn't know the actual result type. From
the declaration alone, it cannot know the correct result type because it
doesn't know how the declaration is used (e.g. calling? referencing by
compound name? curried?)
2020-09-16 22:04:50 -07:00
Doug Gregor
25cd671ed5 [Code completion] Test and fix 'static func' for function builder methods. 2020-09-16 15:12:12 -07:00
Doug Gregor
51baa57c51 [Code completion] Add doc comments for function builder build functions
Add brief documentation comments to each of the code completions
produced for a build* function in a code completion.
2020-09-16 12:59:04 -07:00
Doug Gregor
20ab640e56 [Function builders] Add code completion for build* functions.
When performing code completion inside the declaration of a type with
the function builder attribute, also include completions for all of
the possible "build" functions.
2020-09-16 11:55:09 -07:00
Slava Pestov
1298f71554 Merge pull request #33922 from slavapestov/sil-parser-overhaul
SILParser: Fix for removal of parse-time name lookup
2020-09-12 08:11:26 -04:00
Slava Pestov
dbdbbff743 SILParser: Overhaul to not rely on parse-time lookup 2020-09-11 20:05:47 -04:00
Doug Gregor
3c49e46f4f Merge pull request #33906 from DougGregor/concurrency-actors
[Concurrency] Basic support for actor classes and actor isolation
2020-09-11 15:10:45 -07:00
Brent Royal-Gordon
cff4ddf13a [NFC] Adopt new ImportPath types and terminology
# Conflicts:
#	lib/IDE/CodeCompletion.cpp
2020-09-10 19:07:49 -07:00
Ben Barham
107ba0bab4 Merge pull request #33884 from bnbarham/completion-copy-cleanup
[Gardening] Add re-usable copy* utility methods to use in code completion
2020-09-11 08:22:28 +10:00
Doug Gregor
22a350b1ac [Concurrency] Add parsing support for actor classes.
Introduce the "actor class" syntax. Ensure that it is only used for
root classes or classes that inherit from other actor classes.
2020-09-09 20:46:30 -07:00
Nathan Hawes
a1ef6e4dac Merge pull request #33749 from nathawes/new-member-completion
[CodeCompletion] Update member completion to handle ambiguous and invalid base expressions
2020-09-09 18:51:22 -07:00
Ben Barham
4f5d4d80bb [Gardening] Add re-usable copy* utility methods to use in code completion
Various copy* methods were re-implemented in a bunch of files, move them
to CodeCompletion.h so they can be re-used everywhere that needs them.
2020-09-10 11:42:33 +10:00
Nathan Hawes
b15c1fd349 [CodeCompletion] Deduplicate the two isMemberCompletion functions in ParseExpr.cpp and ParseDecl.cpp
Also:
- propagate the Solution -> Result rename to Solution parameter of deliverDotExprResults
- fixup header comment in CodeCompletionTypeChecking.h
2020-09-09 12:14:53 -07:00
Nathan Hawes
7a06792e5d [CodeCompletion] Remove unused field in CodeCompletionCallbacksImpl (NFC) 2020-09-08 17:31:43 -07:00
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