1366 Commits

Author SHA1 Message Date
Rintaro Ishizaki
be2fabe762 [CodeCompletion] Enable custom attribute completion for func decl
rdar://problem/50352482
2019-06-18 16:09:49 -07:00
Hamish Knight
a3ead02902 Merge remote-tracking branch 'upstream/master' into a-couple-of-tangents 2019-06-13 14:46:55 +01:00
Rintaro Ishizaki
04ca9752cf [CodeCompletion] Enable type name completion for param decl attribute
rdar://problem/50074177
2019-06-11 17:34:45 -07:00
Doug Gregor
0494574706 Factor the computation of default arguments into ParameterListInfo.
Provide a place where we can capture more information about the parameters
from a declaration being called.
2019-06-11 17:34:44 -07:00
Rintaro Ishizaki
32a0b2e771 [CodeCompletion] Exclude precedence groups from type completion 2019-05-31 11:10:04 -07:00
Rintaro Ishizaki
9ba232d718 [CodeCompletion] Implement completion at custom attribute argument 2019-05-31 11:09:54 -07:00
Rintaro Ishizaki
878c9c600b [CodeCompletion] Enable type completion at beginning of attribute
for 'VarDecl' or if we don't know the kind of the decl.
Property delegate allows arbitrary type name (with `@propertyDelegate`
attr).
2019-05-31 09:44:19 -07:00
Rintaro Ishizaki
afd6d66130 [CodeCompletion] Fix attribute completion for var/let decl
There's no attribute declared for PatternBindingDecl. There are for
VarDecl. Code completion should consider DeclKind::PatternBinding as
DeclKind::Var.
2019-05-31 09:42:50 -07:00
Hamish Knight
2872210735 [CodeCompletion] Fix a call to computeDefaultMap
Resolves SR-10795.
2019-05-31 15:53:27 +01:00
Slava Pestov
c947eda18f AST: Use ProtocolDecl::getAssociatedTypeMembers() where possible 2019-05-28 22:08:31 -04:00
Rintaro Ishizaki
e2a4621b14 [CodeCompletion] Suggest #selector and #keyPath after # only if applicable
Also, add type annotation, and make it `TypeRelation[Identical]`.
'ExprSpecific' is too strong.
2019-05-21 17:25:53 -07:00
Rintaro Ishizaki
3c957de1c9 [CodeCompletion] Use CompletionLookup.CurrModule instance property 2019-05-21 17:24:59 -07:00
Rintaro Ishizaki
83084e2b5f [CodeCompletion] Suggest 'file', 'line', et al. after #
rdar://problem/47169238
2019-05-21 17:24:59 -07:00
Rintaro Ishizaki
1b688d5e21 [CodeCompletion] Implement call signature completion for subscript
rdar://problem/28874899
2019-05-17 14:20:28 -07:00
Rintaro Ishizaki
5b5d342995 [CodeCompletion] Enable call signature completion for unresolved member
rdar://problem/50696432
2019-05-15 17:31:19 -07:00
Rintaro Ishizaki
14d2f7c0a7 [CodeCompletion] Enable context type analysis for implict member expression
At argument part of implict member expression, we need context type
analysis to complete arguments.

rdar://problem/50696432
2019-05-15 12:34:26 -07:00
Rintaro Ishizaki
7b7c320bd5 [CodeCompletion] Allow ErrorType in constructor
Even if the constructor has `ErrorType` we can suggest it as long as it's
`FunctionType`.

rdar://problem/49480808
2019-05-13 01:32:57 -07:00
Rintaro Ishizaki
558cc6382e Merge pull request #24455 from rintaro/ide-complete-import-swiftmodule
[CodeCompletion] Complete Swift only module name after 'import'
2019-05-08 14:02:34 -07:00
Rintaro Ishizaki
ffde2280c9 [CodeCompletion] Hide 'SwiftOnoneSupport' from module name completion 2019-05-08 10:12:29 -07:00
Rintaro Ishizaki
6956089b0b [CodeCompletion] Complete Swift only module name after 'import'
rdar://problem/39392446
2019-05-08 10:11:52 -07:00
Gwen Mittertreiner
06ac6f4753 Properly Iterate Through RequestedCachedResults
Clearing the cache and the end of the for loop invalidates the interator
and prevents iterating through the rest of the vector. This should be
cleared after we're done iterating.
2019-05-07 17:33:13 -07:00
Ben Langmuir
8f38e4b765 [code-completion] Avoid invalid member substitution for keypath dynamic lookup
When performing keypath dynamic member lookup, avoid substituting the
base type in override detection and completion, as the base type of the
lookup is not the base type of the member. For now, we just avoid the
substitution entirely to fix potential crashes; in a future commit we
will change to using the subscript return type and substituting with the
base type of the subscript instead of the base type of the lookup.

rdar://50449788
2019-05-06 10:02:39 -07:00
Ben Langmuir
34da079aa6 Pass DynamicLookupInfo through VisibleDeclConsumers NFC
This commit adds a new type DynamicLookupInfo that provides information
about how a dynamic member lookup found a particular Decl. This is
needed to correctly handle KeyPath dynamic member lookups, but for now
just plumb it through everywhere.
2019-05-06 10:02:39 -07:00
Slava Pestov
fa12d85739 AST: Clean up associated type default representation a bit 2019-04-26 21:47:02 -04:00
Ben Langmuir
81ce653bc3 Merge pull request #23587 from benlangmuir/cc-omit-return
[code-completion] Add type context for single-expression function bodies
2019-04-25 13:49:45 -07:00
Rintaro Ishizaki
502a7bf3d7 Merge pull request #24180 from rintaro/ide-completion-static-subscript-rdar49131687
[CodeCompletion] Completion support for static subscript
2019-04-22 09:59:07 -07:00
Rintaro Ishizaki
6e0b8c2b67 [CodeCompletion] Completion support for static subscript
rdar://problem/49131687
2019-04-19 21:36:17 -07:00
Rintaro Ishizaki
3a2454c2c7 [CodeCompletion] Use opaque type for override completion if preferable
rdar://problem/49354106
2019-04-19 17:34:08 -07:00
Rintaro Ishizaki
8055583ddf [IDE] Print opaque result type as protocol composition
rdar://problem/49354663
2019-04-19 17:34:08 -07:00
Rintaro Ishizaki
7078862921 [CodeCompletion] Provide 'some' keyword where applicable
rdar://problem/49353647
2019-04-19 17:11:16 -07:00
Alexis Laferrière
007fbb6ebd Merge pull request #23932 from xymus/IsFinalRequest
Sema: implement `isFinal` using a request evaluator
2019-04-19 13:02:07 -07:00
Joe Groff
71912bbfd6 AST: Represent OpaqueTypeDecls.
To represent the abstracted interface of an opaque type, we need a generic signature that refines
the outer context generic signature with an additional generic parameter representing the underlying
type and its exposed constraints. Opaque types also need to be keyed by their originating decl, so
that we can treat values of the same opaque type as the same. When we check a FuncDecl with an
opaque type specified as its return type, create an OpaqueTypeDecl and associate it with the
originating decl. (A representation for *types* derived from the opaque decl will come next.)
2019-04-17 14:43:32 -07:00
Alexis Laferrière
98059831c9 Sema: implement isFinal using a request evaluator
Add the request evaluator `IsFinalRequest` to lazily determine if a
`ValueDecl` is final.
2019-04-17 09:17:44 -07:00
Slava Pestov
5062a81e3d AST: Start returning SelfProtocolConformances from ModuleDecl::lookupConformance()
Fixes <rdar://problem/49241923>, <https://bugs.swift.org/browse/SR-10015>.
2019-04-16 23:02:50 -04:00
Slava Pestov
91dffc9d44 Sema: Use AnyFunctionType::printParams() to print argument lists instead of printing a tuple type
Once the '@escaping' bit is removed from TupleTypeElt, it no longer makes
sense to print argument lists as if they were TupleTypes or ParenTypes,
since function types are '@escaping' by default inside tuples but not
in argument lists.

Instead, print ArrayRef<AnyFunctionType::Param> directly. For now this
introduces some awkward usages of AnyFunctionType::decomposeInput();
these will go away once the AST is changed to represent the argument list
as a list of expressions and not a single tuple expression.
2019-04-15 00:22:29 -04:00
Rintaro Ishizaki
93632f0bbe Merge pull request #23716 from rintaro/ide-completion-calleedecl-rdar49158044
[CodeCompletion] Associate callee declaration with call patterns
2019-04-05 17:50:37 -07:00
Slava Pestov
3095c36585 IDE: Remove prepareForRetypechecking() 2019-04-02 01:51:57 -04:00
Rintaro Ishizaki
0c38f2df8a [CodeCompletion] Associate callee declaration with call patterns
In `addFunctionCallPattern()` we should associate declarations if
possible.

rdar://problem/49158044
2019-04-01 11:21:43 -07:00
Jordan Rose
0ba6c495ba Add @_implementationOnly
This is an attribute that gets put on an import in library FooKit to
keep it from being a requirement to import FooKit. It's not checked at
all, meaning that in this form it is up to the author of FooKit to
make sure nothing in its API or ABI depends on the implementation-only
dependency. There's also no debugging support here (debugging FooKit
/should/ import the implementation-only dependency if it's present).

The goal is to get to a point where it /can/ be checked, i.e. FooKit
developers are prevented from writing code that would rely on FooKit's
implementation-only dependency being present when compiling clients of
FooKit. But right now it's not.

rdar://problem/48985979
2019-03-28 15:57:53 -07:00
Jordan Rose
9ed3fe061d Change ModuleDecl::getImportedModules to take an option set
...in preparation for me adding a third kind of import, making the
existing "All" kind a problem. NFC, except that I did rewrite the
ClangModuleUnit implementation of getImportedModules to be simpler!
2019-03-28 14:44:41 -07:00
Ben Langmuir
e255bac6be [code-completion] Fix type context for single-expression implicit getter
This adds an implicit body so that we can dig out the return type
context the same way as a normal function. For now, we are also treating
the first expression in a multi-statement implicit getter body the same
way; we'll need to refactor how we complete in accessors to
differentiate those cases.
2019-03-26 16:45:32 -07:00
Ben Langmuir
b14cd916a3 [code-completion] Add type context for single-expression functions
Extend the support for single-expression closures to handle
single-expression functions of all kinds. This allows, e.g.

    func foo() -> MyEnum { .<here> }

to complete members of `MyEnum`.
2019-03-26 16:45:27 -07:00
Rintaro Ishizaki
42d36431f0 Merge pull request #23502 from rintaro/ide-completion-unresolvedoptional-rdar47806831
[CodeCompletion] Don't provide 'init(nilLiteral:)' et al in optional context
2019-03-26 11:31:03 -07:00
Rintaro Ishizaki
e64b037962 Merge pull request #23542 from rintaro/ide-completion-keypathcontext-rdar46102807
[CodeCompletion] Infer keypath root type from the context type
2019-03-26 10:16:04 -07:00
Ted Kremenek
fe215edb9b Merge pull request #19743 from Azoy/smarter-struct-init
[Sema] Synthesize default values for memberwise init
2019-03-25 17:31:01 -07:00
Rintaro Ishizaki
65d8d29d2a [CodeCompletion] Infer keypath root type from the context type
So that this works:

```
func foo(_: KeyPath<SomeObject, Int>) {}
foo(\.<HERE>)
```

rdar://problem/46102807
2019-03-25 16:29:19 -07:00
Rintaro Ishizaki
b1efc21e08 [CodeCompletion] Don't ignore .some(Wrapped) and .none for now
with "TODO: ignore them in expression context".
They are useful in pattern context, so we should provide them in
completion.
2019-03-25 16:08:44 -07:00
Rintaro Ishizaki
7e3a5dc50b [CodeCompletion] Don't provide 'init(nilLiteral:)' et al in optional context
For unresolved member completion, member decls in `Optional`
referenceable by implicit member expression are useless in most cases.
- `init(_: <#Wrapped#>)`
- `init(nilLiteral: ())`
- `.some(<#Wrapped#>)`
- `.none`

Instead, provide `nil` with erasing `.` instruction.

rdar://problem/47806831
2019-03-22 15:21:15 -07:00
Rintaro Ishizaki
7ae18ff0f1 [CodeCompletion] Provide empty call pattern after paren
This improves discoverability of no-parameter initializers.

rdar://problem/46215262
2019-03-22 10:56:40 -07:00
Ben Langmuir
f5a216fc04 Merge pull request #23411 from benlangmuir/cc-1-close
[code-completion] Add type context for single-expression closures
2019-03-20 06:56:49 -07:00