Commit Graph

1181 Commits

Author SHA1 Message Date
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
Rintaro Ishizaki
1b3c4ad4a5 Merge pull request #23372 from rintaro/ide-completion-escapedident-16232627
[CodeCompletion] Escape declaration base name if needed
2019-03-19 22:22:32 -07:00
Rintaro Ishizaki
df473f641d [CodeCompletion] Escape declaration base name if needed
There should be escaped identifiers in code completion:
- As primary expression: Any keyword name except for `self` and `Self`.
- After dot: Something named `init`.

rdar://problem/16232627
2019-03-19 16:42:46 -07:00
Ben Langmuir
f8a3afb7bb Fix lifetime of type context in result builder
There usually won't be a lot of expected types, so just use a
SmallVector and copy it instead of trying to get tricky with the
lifetime.
2019-03-19 07:04:39 -07:00
Ben Langmuir
b817cbb9bc [code-completion] Add type context for single-expression closures
When completing in the only expression of closure, use the return type
of the closure as the type context for the code-completion. However,
since code-completion may be on an incomplete input, we only use the
return type to improve the quality of the result, not to mark it
invalid, since (a) we may add another statement afterwards, or (b) if
the context type is Void it doesn't need to match the value.
2019-03-18 17:04:33 -07:00
Rintaro Ishizaki
fd542e267c [CodeCompletion] 'case' keyword completion at the top of 'switch' stmt
rdar://problem/35943849
2019-03-18 16:58:52 -07:00
Rintaro Ishizaki
df20597e8f [Gardening][CodeCompletion] Remove unused parameter
Non-`Outermost` parameter isn't used anymore. It used to be used for
adding tuple label in calling parameter.
2019-03-17 14:25:09 -07:00
Rintaro Ishizaki
71aeea93f5 [CodeCompletion] Fix an assertion failure
If the type has unbound generic parameter, we cannot substitute types
for member decls.

rdar://problem/48896424
2019-03-14 12:22:19 -07:00
Azoy
6f7d20b99e Synthesize default values for memberwise init
Introduce stored property default argument kind

Fix indent

Assign nil to optionals with no initializers

Don't emit generator for stored property default arg

Fix problem with rebase

Indentation

Serialize stored property default arg text

Fix some tests

Add missing constructor in test

Print stored property's initializer expression

cleanups

preserve switch

complete_constructor

formatting

fix conflict
2019-03-13 18:57:36 -05:00
Rintaro Ishizaki
97d7111fa6 [CodeCompletion] Clean-up result build for method/function all
Don't emit duplicate results for implicitly curried instance methods
with defaulted parameters.
2019-03-05 16:45:48 -08:00
Rintaro Ishizaki
489a53864c [CodeCompletion] Display mapped type for subscript result 2019-03-05 16:45:48 -08:00
Rintaro Ishizaki
c99af83901 [CodeCompletion] Consolidate parameter list processing funcitons
There were 2 functions to output argument list. Consolidate them and
consistently use it from every call like production (i.e. function call,
constructor call, enum with associated values, subscript)
2019-03-05 16:45:48 -08:00
Rintaro Ishizaki
82b5f2a195 [CodeCompletion] Find parsed expression from typechecked decl context
Instead of re-typechecking parsed expression, find typechecked
expression that corresponds to the parsed expression from the
typechecked decl context, because the sub expressions of the parsed
expression can be weirdly mutated/replaced by decl context typechecking.

rdar://problem/48141174
2019-02-28 18:39:46 -08:00
Rintaro Ishizaki
6872f6c0cb Merge pull request #19742 from AnthonyLatsis/class-var-override-compl
[CodeCompletion][Parser] Completions for overridable static members
2019-02-26 09:52:37 -08:00
Rintaro Ishizaki
dc8508435b [CodeCompletion] Show bound generic types for enum elements
We weren't displaying bound generic types for enum elements. It's
inconsistent with functions and initializiers.
2019-02-20 11:31:04 -08:00
Rintaro Ishizaki
25f9b8843c [CodeCompletion] Show the enum type for enum element with assoc values
enum MyEnum {
    case null
    case str(String)
}

When completing elements for enum like this, the former shows `MyEnum`,
but the latter shows `(String) -> MyEnum`. This is inconsistent with
function call pattern which only shows the result type.

rdar://problem/48220244
2019-02-20 10:29:59 -08:00
fischertony
ae415b2a4b When followed by an 'override' or CC token inside a class, treat 'class' as a modifier rather than an introducer. 2019-02-16 16:02:22 +03:00
fischertony
ecfce56110 Don't exclude @autoclosure from the attribute list when printing override completions 2019-02-16 16:02:22 +03:00
fischertony
86d9d7a6b5 Fix override completions when a valid introducer is present but the override keyword is not. 2019-02-16 16:02:22 +03:00
fischertony
bb9482bab5 [CodeCompletion][Parser] Completions for overridable static members 2019-02-16 16:02:06 +03:00
Rintaro Ishizaki
0bebba840e Merge pull request #22539 from rintaro/ide-codecompletion-dottype-rdar22072865
[CodeCompletion] Implement .Type completion in expression context
2019-02-12 16:03:29 -08:00
Rintaro Ishizaki
ec85151a80 [CodeCompletion] Add '.Protocol' completion for protocol in type context 2019-02-12 10:58:30 -08:00
Rintaro Ishizaki
01b8fbc1bf [CodeCompletion] Implement .Type completion in expression context
rdar://problem/22072865
2019-02-12 10:40:08 -08:00
Rintaro Ishizaki
1d845d6e3f [IDE/SourceKit] New SourceKit request for filtered method list
`source.request.conformingmethods` is a new SourceKit request which
receives a source position and a list of protocol namses, returns a list
of methods whose return type conforms to the requested protocols.

rdar://problem/44699573
2019-02-08 12:56:58 -08:00
Robert Widmann
c5b7230d22 [NFC] Upgrade EnumElementDecl to a DeclContext
Pure plumbing for the sake of default arguments.
2019-01-16 18:39:30 -05:00
Slava Pestov
e3c5eb7d3a IDE: Remove unused function 2019-01-14 14:57:03 -05:00
Rintaro Ishizaki
b446d6b051 Merge pull request #21377 from rintaro/ide-contextinfo
[SourceKit][IDE] New SourceKit request to retrieve context type information
2019-01-15 01:54:16 +09:00
Rintaro Ishizaki
cc1d5c1147 [IDE] Move typeCheckContext() to ExprContextAnalysis.cpp
NFC
2019-01-10 17:52:37 +09:00
Rintaro Ishizaki
2fbd3fe682 [IDE] Move ExprContextAnalyser to its own file
NFC
2019-01-10 17:52:37 +09:00
Rintaro Ishizaki
d17bb78a0b [AST] Add shouldHideFromEditor() method
This replaces shouldHideDeclFromCompletionResults() in IDE.
2019-01-10 17:52:36 +09:00
Rintaro Ishizaki
867c28ea74 [IDE] Rename collectArgumentExpectation() to analyzeApplyExpr()
Removed unnecessary arguments.
2019-01-10 17:52:36 +09:00
Rintaro Ishizaki
e3387c6fdb [IDE] ExprContextAnalyzer::Analyze() doesn't need to return success 2019-01-10 17:52:36 +09:00
Rintaro Ishizaki
758ba5e5d0 [IDE] Decouple ExprContextAnalyzer and ExprContextInfo
Just refactoring.
ExprContextInfo automatically construct analyzer and analyze().
2019-01-10 17:52:36 +09:00
Rintaro Ishizaki
5c64324740 [IDE] Refactor ExprContextAnalyzer. NFC
We don't need to keep ExprFinder beyond analysis.
2019-01-10 17:52:36 +09:00
Rintaro Ishizaki
2fb542537f [IDE] Rename CodeCompletionTypeContextAnalyzer to ExprContextAnalyzer
NFC
2019-01-10 17:52:36 +09:00
Rintaro Ishizaki
b033f4880c [CodeCompletion] Only analyze inner most context
Now that this passes all test cases we currently have. Stop analyzing
outer contexts because it may emit invalid context type.
2019-01-10 17:52:36 +09:00