Commit Graph

1181 Commits

Author SHA1 Message Date
Rintaro Ishizaki
e9c438cdd5 [CodeCompletion] Dont mark type mismatching items 'not recommended'
func foo() {}
let a: Int = #^HERE^#

Previously, we marked 'foo()' as 'NotRecommented' because 'Void' doesn't
have any member hence it cannot be 'Int'. But it wass confusing with
'deprecated'.

Now that we output 'typerelation' which is 'invalid' in this case. So clients
can deprioritize results, or even filter them out.

rdar://problem/57726512
2020-05-05 10:40:05 -07:00
Daniel Sweeney
ea526c6383 Converting ModuleDecl::ImportedModule from std::pair to a dedicated struct. (#31360) 2020-04-30 20:26:03 -07:00
Rintaro Ishizaki
2b4cc8581e Merge pull request #31316 from rintaro/ide-completion-protocolext-rdar53591636
[CodeCompletion] Don't show protocol extension only members in override
2020-04-28 09:08:39 -07:00
Rintaro Ishizaki
b2a742cb17 Merge pull request #31307 from rintaro/ide-completion-rdar62121221
[CodeCompletion] Prioritize type matching overload for unresovled member
2020-04-27 12:10:19 -07:00
Rintaro Ishizaki
ab7ba4ce79 [CodeCompletion] Don't show protocol extension only members in override
Protocol extension only members are not customization point. Code
completion should not suggest them in override/conformance completion.

rdar://problem/53591636
2020-04-27 11:52:27 -07:00
Rintaro Ishizaki
e947512875 [CodeCompletion] Prioritize type matching overload for unresovled member
For exmaple:

    func foo(_: Int, _: IntOption)
    func foo(_: Float, _: FloatOption)

    foo(intVal, .<HERE>)

Previously code completion suggests static member from 'IntOption' and
'FloatOption' without any prioritization. Prioritize members from
'IntOption' because the user probably wants to input them.

In such cases, 'CodeCompletionExpr' at the cursor position is
pre-typechecked to 'IntOption'. So mark results with matching type with
'ExprSpecific'.

rdar://problem/62121221
2020-04-24 18:01:59 -07:00
Anthony Latsis
74252028ca AST: Rename getFullName -> getName on ValueDecl & MissingMemberDecl 2020-04-23 05:16:55 +03:00
Rintaro Ishizaki
0f1cffd2d2 [CodeCompletion] Completion for control trasfer target
Completion after 'break' and 'continue'

rdar://problem/57016218
2020-04-17 14:18:33 -07:00
Rintaro Ishizaki
315f65f962 [CodeCompletion] Use AnyFunctionType::Param::getParameterType()
instead of getOldType() in KeyPath as funtions completion.
Also, don't think keypath's are convertible to functions that receives
variadic parameters.
2020-04-10 15:55:32 -07:00
Rintaro Ishizaki
c633da047d [CodeCompletion] Add IDE test case for annotated description 2020-04-07 00:50:43 -07:00
Rintaro Ishizaki
d54e70cd70 [CodeCompletion] Option to swift-ide-test to test annotated results 2020-04-07 00:50:43 -07:00
Rintaro Ishizaki
ad8415a5c2 [CodeCompletion] Include 'annotated' to cache key 2020-04-07 00:46:14 -07:00
Rintaro Ishizaki
773a464e83 [CodeCompletion] Add an option to emit annotated description 2020-04-07 00:46:14 -07:00
Nathan Hawes
1a65b84a42 [IDE] Completion after a qualifying module should return symbols from its shadowing cross-import overlays. 2020-04-03 16:04:32 -07:00
Nathan Hawes
9f6f76308e Add method to ModuleDecl to lazily compute the underlying module for cross-import overlays
Also update code completion, indexing, interface generation and doc info to use it.
2020-04-03 16:04:32 -07:00
Robert Widmann
630d0f631a Merge pull request #30606 from AnthonyLatsis/rename-getfullname
[NFC] Preparations to address the «Rename to getName?» TODO on ValueDecl::getFullName
2020-04-01 09:00:04 -07:00
Anthony Latsis
d0ae3ee580 [AST] Replace FuncDecl::getName & EnumElementDecl::getName with ValueDecl::getBaseIdentifier 2020-03-29 00:35:51 +03:00
Anthony Latsis
41fe367a7e [CodeCompletion] Don't skip derived conformance members on override completion lookup 2020-03-28 23:59:18 +03:00
Hamish Knight
6f212634c8 Add getOperatorDecls to FileUnit and ModuleDecl
Query the SourceLookupCache for the operator decls,
and use ModuleDecl::getOperatorDecls for both
frontend stats and to clean up some code
completion logic.

In addition, this commit switches getPrecedenceGroups
over to querying SourceLookupCache.
2020-03-27 09:44:55 -07:00
Nathan Hawes
8b03b05f1d [Index] Add index support for cross import overlays.
Resolves rdar://problem/59445445
2020-03-25 10:04:41 -07:00
swift-ci
41301c2597 Merge pull request #30542 from marcrasi/fix-autocomplete-crash-callasfunction 2020-03-20 16:57:49 -07:00
Marc Rasi
5772ddda7e fix autocomplete crash 2020-03-20 14:43:46 -07:00
Rintaro Ishizaki
80848682cc [LookupVisibleDecls] Tweak unquialified lookup
- Show static var decls in non-qualified metatype lookup
- Show enum element decls in non-qualified metatype lookup
- Never show initializers in non-qualified lookup
- Perform instance lookups in lazy var initializer
- Perform non-qualified metatype lookup inside static func

rdar://problem/57622639
2020-03-20 10:44:24 -07:00
Robert Widmann
21cfcfef2c Merge pull request #30505 from CodaFi/ligated-legacy
[NFC] Remove the Legacy Semantic Queries Bit
2020-03-19 13:45:27 -07:00
Robert Widmann
6d60d01420 [NFC] Remove the Legacy Semantic Queries Bit
Clients that wish to avoid semantic requests should decline to register
those requests.
2020-03-19 11:04:12 -07:00
Nathan Hawes
fd82d87db0 Merge pull request #30402 from nathawes/cross-import-code-completion
[IDE/CodeCompletion] Add code completion support for cross import overlays.
2020-03-18 18:16:03 -07:00
Nathan Hawes
63636100be [IDE/CodeCompletion] Add code completion support for cross import overlays.
If a cross-import overlay shadows another module and has a name starting with
'_', don't present that overlay in places where module name completions are
offered and present symbols comining from that module as if they came from
the shadowed module instead.

Resolves rdar://problem/59445688
2020-03-18 12:02:20 -07:00
Dmitri Gribenko
841eeb05b0 Merge pull request #30403 from MForster/forster/string-fixes
Cherry-pick StringRef->std::string conversion fixes into `master`
2020-03-17 12:09:36 +01:00
Robert Widmann
70b6bbcb13 Remove swift::createTypeChecker
Replace it with the "legacy semantic queries" bit. The remaining client
of this bit is SourceKit, which appears to require this bit be set
conditionally so certain semantic property wrapper requests return
a sentinel value.

We should migrate these requests to a syntactic interface as soon as
possible.

rdar://60516325
2020-03-16 19:20:22 -07:00
Fred Riss
259d78a350 Adapt to llvm.org StringRef API change 2020-03-13 19:08:22 +01:00
Rintaro Ishizaki
9225cfce3d [CodeCompletion] Type annotation for call argument completions 2020-03-12 17:46:25 -07:00
Rintaro Ishizaki
f8147f72d9 [CodeCompletion] Call argument label with value placeholder
When a completion happens at a call argument position, insert
'label: <#T##TypeName#>' instead of just 'label: '.

rdar://problem/60379654
2020-03-12 11:48:15 -07:00
Rintaro Ishizaki
fbc79d2f47 [CodeCompletion] Support SE-0253 callAsFunction()
- In member completions, when 'callAsFunction' decls are found, suggest
  call patterns
- In call pattern completions, fallback to search 'callAsFunction' if
  the base type is not a function type

rdar://problem/59792682
2020-03-11 16:27:27 -07:00
Rintaro Ishizaki
12fd864543 Merge pull request #30136 from rintaro/ide-completion-rdar59285399
[CodeCompletion] Primarily use getPossibleCallees() for calling signature completion
2020-03-03 11:10:53 -08:00
Rintaro Ishizaki
78d0f6aa4a [CodeCompletion] Primarily use getPossibleCallees() for call signature completion
instead of the pre-typechecked type and the referenced decl in the AST
so that we can suggests all overloads even if it happen to be
typechecked to a method. For example

    struct MyType {
      func foo() {}
      func foo(_ int: Int) {}
      func foo(name: String, value: String) {}
    }
    func test(val: MyType) {
      value.foo(#^COMPLETE^#)
    }

In this case, the call is typechecked to 'MyType.foo(_:)', but we want
to suggest all overloads.

rdar://problem/59285399
2020-02-28 16:44:03 -08:00
Rintaro Ishizaki
fc28f909b8 [CodeCompletion] Tweak canBeUsedAsRequirementFirstType() 2020-02-26 10:58:01 -08:00
Rintaro Ishizaki
0dd0092e9e [CodeCompletion] Only suggest generic params in where for non-protocol
nominal types
2020-02-26 09:57:18 -08:00
Rintaro Ishizaki
ea6886114a [CodeCompletion] Generalize generic requirement completion
Align completion logics for all 'where' clauses.
2020-02-26 09:57:18 -08:00
Rintaro Ishizaki
e5cdbb7fab [CodeCompletion] completeGenericRequirement to use the decl context
instead of the parsed type name for the extension.
Preparation for generalize this to other 'where' clause (e.g. functions)
2020-02-26 09:57:17 -08:00
Rintaro Ishizaki
5cf88a15cf [CodeCompletion] Rename GenericParam kind to GenericRequiremnt
NFC
2020-02-26 09:57:17 -08:00
Rintaro Ishizaki
ea947987e9 [CodeCompletion] Associated types after where on a protocol extesnion
rdar://problem/58580482
2020-02-26 09:57:17 -08:00
Brent Royal-Gordon
f8df2f66fd Add mechanism for per-SourceFile overlays
When a “separately imported overlay” is added to a SourceFile, two things happen:

1. The direct import of the underlying module is removed from getImports*() by default. It is only visible if the caller passes ImportFilterKind:: ShadowedBySeparateOverlay. This means that non-module-scoped lookups will search _OverlayModule before searching its re-export UnderlyingModule, allowing it to shadow underlying declarations.

2. When you ask for lookupInModule() to look in the underlying module in that source file, it looks in the overlays instead. This means that UnderlyingModule.foo() can find declarations in _OverlayModule.
2020-02-18 11:07:12 -08:00
Rintaro Ishizaki
bfa385c0b7 [CodeCompletion] Update for SE-0249 KeyPath as functions
If the context type is a function type that receives one argument, infer
the key path expressions root type from the context.

rdar://problem/59302416
2020-02-13 13:11:36 -08:00
Robert Widmann
d2360d2e8c [Gardening] dyn_cast -> isa 2020-02-07 16:09:31 -08:00
Rintaro Ishizaki
cc8d4965f8 [CodeCompletion] Ensure cached results have 'unknown' type relation 2020-02-05 17:05:23 -08:00
Rintaro Ishizaki
566a84d641 [CodeCompletion] Handle new kinds in type relation printing 2020-02-05 15:35:01 -08:00
Rintaro Ishizaki
e9c51a0755 [CodeCompletion] Report 'Unrelated' type relation for keywords 2020-02-05 15:09:14 -08:00
Rintaro Ishizaki
c31bfaeeed [CodeCompletion] Introduce 'Unknown' type relation
Now

* NotApplicable: The result is not relevant for type relation (e.g.
  keywords, and overloads)
* Unknown: the relation was not calculated (e.g. cached results), or the
  context type is unknown.
* Invalid: The result type is invalid for this context (i.e. 'Void' for
  non-'Void' context)
* Unrelated: The result type has no relation to the context type
* Convertible: The result type is convertible to the context type
* Identical: The result type is identical to the context type
2020-02-05 14:23:59 -08:00
Rintaro Ishizaki
17abedf1ef [CodeCompletion] Introduce 'NotApplicable' type relation
For keywords, and overrides.
2020-02-05 14:23:59 -08:00
Rintaro Ishizaki
71aeffdf17 [CodeCompletion] Calculate type relation for EnumElementDecl 2020-02-03 17:20:50 -08:00