Commit Graph

29 Commits

Author SHA1 Message Date
Ahmed Elrefaey
1bc96857a8 Merge pull request #82464 from a7medev/feat/full-documentation-in-code-completion
[IDE] Add full documentation to code completion result
2025-09-04 10:06:21 +01:00
Ahmed Mahmoud
491b3a0fbc [IDE] Erase archetypes with no declaration generic signature
This generalization enables curried functions with generic parameters coming from the initial declaration to be printed with the archetype's upperbound rather than '_' unresolved type.

As an added benefit, T.self and T.Type for generic parameters now get shown as the upperbound of the generic parameter provided
2025-08-29 13:39:58 +03:00
Hamish Knight
f73054ad10 [Completion] Don't suggest nested type in where clause
We allow the unqualifed use of the enclosing nominal type in a where
clause, but only when it isn't a nested type, e.g:

```
struct S<T> {
  typealias T = T
  struct R<U> {
    typealias U = U
  }
}
extension S where S.T == Int {}   // allowed
extension S.R where R.U == Int {} // not allowed
```

Tweak the completion logic such that we don't suggest the type for
the nested case, instead it must be qualified.
2025-02-25 14:49:12 +00:00
Hamish Knight
0fc825b6fb [Completion] Remove uses of unbounded generic types
Ensure we always produce bounded generic type annotations and
contextual types.
2025-02-25 14:49:12 +00:00
Alex Hoppen
1650052150 [CodeCompletion] Fix missing completions in type member access of right-hand side in generic where clause
Fixes the issue in https://github.com/apple/swift/pull/61064#discussion_r1493108941
2024-02-20 14:39:48 -08:00
Slava Pestov
70c9f8a47e RequirementMachine: Leave behind conflicting requirements in the minimized signature
Requirement lowering only expects that it won't see two requirements
of the same kind (except for conformance requirements). So only mark
those as conflicting.

This addresses a crash-on-invalid and improves diagnostics for
move-only generics, because a conflict won't drop the copyability
of a generic parameter and expose a move-only-naive user to
confusing error messages.

Fixes #61031.
Fixes #63997.
Fixes rdar://problem/111991454.
2024-02-15 14:32:31 -05:00
Alex Hoppen
32eff21977 [IDE] Remove "Begin completions" and "End completions" from test cases
These test lines weren't actually providing any value and were annoying to write. Let's jut remove them.
2023-03-22 09:07:17 -07:00
Alex Hoppen
a35f1856c0 [CodeCompletion] Offer suggestions if a nested type is followed by an equal type requirement
If the first type has a code completion token, don't record a same type constraint because otherwise if we have
```swift
  K.#^COMPLETE^# == Foo
```
we parse this as
```
  K == Foo
```
and thus simplify `K` to `Foo`. But we didn't want to state that `K` is `Foo` but that `K` has a member of type `Foo`.

rdar://77458518
2022-05-03 09:36:51 +02:00
Ted Kremenek
00534aa02a Revert "[CodeCompletion] Migrate some tests to batch completion test #4" 2021-04-03 09:20:45 -07:00
Rintaro Ishizaki
b810bb7bbd [CodeCompletion] Migrate some tests to batch completion test 2021-04-02 11:50:13 -07:00
Alex Hoppen
943d7ee621 [CodeComplete] In where clauses, suggest Self and the current type
Fixes rdar://70058225
2021-03-26 17:43:35 +01: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
Rintaro Ishizaki
62d8eed570 [Parse] Don't drop parsed error types in where clause from AST
Code completion requires the source range of the 'where' clause to
correctly lookup member of types in where clause.

rdar://problem/61911134
2020-04-23 08:54:38 -07: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
Slava Pestov
f7e39447a7 LookupVisibleDecls: Find generic parameters in methods inside extensions
The logic here had diverged from UnqualifiedLookup. One day we'll merge
the two, for now clean it up a bit to match.

Note that all generic parameters now have 'Reason' reported as 'Local'.
I don't believe this really matters.

Fixes <rdar://problem/20530021>.
2019-01-08 16:51:20 -05:00
Slava Pestov
7d33177b84 LookupVisibleDecls: Don't use getReasonForSuper() for members of protocols and superclass constraints on an archetype
Semantically, these are not superclass/refined-protocol members.
If I have a generic parameter <T : P & Q>, then when looking at
a value of type T, members of P and Q are at the same "level" as
if I had a value of type (P & Q).
2019-01-08 00:14:52 -05:00
Slava Pestov
7626eb1571 AST: Use getSelfTypeInContext() consistently in typo correction
We actually want to not use types at all here and instead refactor
this code to use the various decl-level requests instead... but for
now lets be consistent between typo corrections inside function
and type context.
2018-10-15 20:34:08 -07:00
Slava Pestov
4051246932 Merge pull request #16811 from AnthonyLatsis/code-compl-dup-restated-requirements
[CodeCompletion] Duplicate existential requirements when restated
2018-06-15 14:46:26 -07:00
fischertony
f3fed2e5b8 remove self completion from new test on type identifier 2018-06-12 18:07:04 +03:00
fischertony
9d5302e1eb [CodeCompletion] Remove 'self' from type identifier completions 2018-06-03 18:28:25 +03:00
fischertony
ede3ba207b [CodeCompletion] Duplicate existential requirements when restated 2018-05-24 03:54:05 +03:00
fischertony
ee4587f6cb added tests for failures & fixed the issue for subscript decls 2018-05-14 07:26:20 +03:00
fischertony
561ad16c22 [CodeCompletion][SR-7670] Duplicate generic param completions
fixed duplicate completions for generic parameters in non-generic members
this also fixed the SemanticContextKind for some tests
2018-05-13 13:00:46 +03:00
Ben Langmuir
46504db7a7 [code-completion] Partly fix completion of associatedtypes in where clauses
This gets us to the point where we will complete 'T' here:
    associatedtype T where #^A^#
And when completing here, we now at least find the correct declaration:
    associatedtype T: P where T.#^A^#

There is a remaining issue that in the second example we will not find
members of `P`; we seem to be missing the conformance from the archetype
we get for `T`.

rdar://problem/20582394
2017-08-01 14:16:03 -07:00
Ben Langmuir
534c0cc2cb [code-completion] Generic where clauses
Complete generic parameters and their members inside generic where
clauses on structs, classes, enums, extensions, typealiases, funcs,
subscripts and inits.

Still not handled correctly are associatedtypes.

rdar://problem/20582394
2017-07-31 09:57:00 -07:00
Dmitri Gribenko
d175b3b66d Migrate FileCheck to %FileCheck in tests 2016-08-10 23:52:02 -07:00
Xi Ge
0f4e7a5ea5 [CodeCompletion] Add code completion for where clauses. rdar://24245022
When completing at "extension A where #^HERE^#", we suggest the generic params of A to users.
2016-01-19 14:17:15 -08:00