Commit Graph

37 Commits

Author SHA1 Message Date
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
Alexander Cyon
a80b8ae06f [test/IDE] Fix typos 2024-08-08 19:35:00 +02: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
3ad1ac75b9 [IDE] Change -NEXT to -DAG in test cases
We don’t actually care about the order of the results here. Change `-NEXT` to `-DAG` to make the test cases more robust to changes  in code completion.
2023-02-16 09:39:01 +01:00
Alex Hoppen
c03addb1e0 [CodeCompletion] Insert code completion token into build block call to retrieve contextual type
rdar://94224692
2022-12-21 10:31:46 -08:00
Alex Hoppen
310ec6eb8d [CodeCompletion] Only include results from other modules once
In case of ambigous expression/global completions, we call `getValueCompletionsInDeclContext` multiple times for the amigous solutions to the constraint system. This can cause modules to be included multiple times in `RequestedCachedResults` and thus global results from these modules are reported multiple times. Make `RequestedCachedResults` a set so we don’t get duplicate results.

rdar://92048610
2022-04-21 10:48:40 +02:00
Rintaro Ishizaki
18dc9c1c27 [CodeCompletion] Remove CodeComletionString::getName()
`CodeCompletioString::getName()` was used only as the sorting keys in
`CodeCompletionContext::sortCompletionResults()` which is effectively
deprecated. There's no reason to check them in `swift-ide-test`. Instead,
check `printCodeCompletionResultFilterName()` that is actually used for
filtering.
2021-07-16 13:24:19 -07:00
Rintaro Ishizaki
154cd88c86 [CodeCompletion] Use 'Flair' to describe "is argument labels" 2021-06-07 17:25:01 -07: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
Nathan Hawes
eabb561994 [code-completion] Give Modules a SemanticContextKind of None
This seems more correct than OtherModule, and means they're treated as
low-priority results for the session-based completion APIs. With default
options that means won't be shown in global completion results but will be
once there's some matching filter text. It also sorts them below any symbols
that actually come from other modules, which is desirable, since most symbols
don't need to be module qualified.

The SemanticContextKind change doesn't seem to affect Xcode's handling of the
results.
2019-11-01 11:11:52 -07:00
Nathan Hawes
b871454b8f [code-completion] Suggest module names in type and expression position
They can be used to qualify both.
2019-10-30 11:28:56 -07:00
Nathan Hawes
7350917c22 [code-completion] Complete after qualifying module names in type position
Previously we would just return if the parsed type loc didn't type check as a
type.
2019-10-29 10:48:53 -07: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
01b8fbc1bf [CodeCompletion] Implement .Type completion in expression context
rdar://problem/22072865
2019-02-12 10:40:08 -08:00
fischertony
7b41a41fb6 updated tests & added completions for postfixExpr 2018-05-12 09:05:57 +03:00
Pavel Yaskevich
c0f5711ee5 [ConstraintSystem] Don't apply types to expressions until solution is found
Resolves: rdar://problem/36744895
2018-02-13 00:08:45 -08:00
Dmitri Gribenko
984210aa53 tests: replace '// RUN: rm -rf' '// RUN: mkdir' pairs with '%empty-directory(...)'
These changes were made using a script.
2017-06-04 11:08:39 -07:00
Pavel Yaskevich
f09d2ad397 [ConstraintSolver] Forbid forming solutions with free generic type parameters
`FreeTypeVariableBinding::GenericParameters` mode allowed to bind
all free type variables with fresh generic parameter types, which
is incorrect (at least) if there are multiple generic solutions
present, because such parameters couldn't be compared.

This mode was used for code completion, which is now switched to use
`FreeTypeVariableBinding::UnresolvedType` instead.
2017-06-01 14:05:05 -07:00
Slava Pestov
cde493de0d Sema: Support member types in preCheckExpression()
This folds member access on types to a TypeExpr if the member
resolves to a nested type.

This allows [Foo.Bar]() to become an ApplyExpr of a TypeExpr,
rather than an ApplyExpr of an array literal; previously,
only [Foo]() worked.

Two cases that are still unsupported:

1) If G is a generic type and T is a generic typealias, then
   G.T<X> cannot be folded to a TypeExpr, because we cannot
   represent a generic typealias with an unbound generic
   parent type. Such lookups remain member lookups, where
   Sema first opens the base type to produce a bound generic
   type G<$T0>, and then resolves the generic typealias
   member on that.

2) If T is a generic parameter and X is an associated type,
   T.X is not folded down to a TypeExpr either.

Fixes <rdar://problem/16849958>.
2017-05-21 18:12:12 -07:00
Slava Pestov
cfe9e6a3de IDE: Use GenericSignatures and interface types (mostly)
There was a ton of complicated logic here to work around
two problems:

- Same-type constraints were not represented properly in
  RequirementReprs, requiring us to store them in strong form
  and parse them out when printing type interfaces.

- The TypeBase::getAllGenericArgs() method did not do the
  right thing for members of protocols and protocol extensions,
  and so instead of simple calls to Type::subst(), we had
  an elaborate 'ArchetypeTransformer' abstraction repeated
  in two places.

Rewrite this code to use GenericSignatures and
GenericFunctionType instead of old-school GenericParamLists
and PolymorphicFunctionType.

This changes the code completion and AST printer output
slightly. A few of the changes are actually fixes for cases
where the old code didn't handle substitutions properly.
A few others are subjective, for example a generic parameter
list of the form <T : Proto> now prints as <T where T : Proto>.

We can add heuristics to make the output whatever we want
here; the important thing is that now we're using modern
abstractions.
2016-10-02 23:49:15 -04:00
Dmitri Gribenko
d175b3b66d Migrate FileCheck to %FileCheck in tests 2016-08-10 23:52:02 -07:00
Joe
3938d5682a [SE-0095] [Runtime], [Demangler], & AST printer updated to new composition syntax
- All parts of the compiler now use ‘P1 & P2’ syntax
- The demangler and AST printer wrap the composition in parens if it is
in a metatype lookup
- IRGen mangles compositions differently
    - “protocol<>” is now “swift.Any”
    - “protocol<_TP1P,_TP1Q>” is now “_TP1P&_TP1Q”
- Tests cases are updated and added to test the new syntax and mangling
2016-07-19 12:01:37 -07:00
Joe
a6dad0091b [SE-0095] Initial parsing implementation for '&' composition syntax
This commit defines the ‘Any’ keyword, implements parsing for composing
types with an infix ‘&’, and provides a fixit to convert ‘protocol<>’

- Updated tests & stdlib for new composition syntax
- Provide errors when compositions used in inheritance.
Any is treated as a contextual keyword. The name ‘Any’
is used emit the empty composition type. We have to
stop user declaring top level types spelled ‘Any’ too.
2016-07-19 12:01:02 -07:00
Ben Langmuir
d1fd8adbc4 [CodeCompletion] Workaround a bunch of issues with ErrorType in completion
The brief explanation is that we are using the type-checker in a
questionable way where for various reasons we can type-check the same
"context" expression more than once. Until we figure out how to stop
doing that, at least avoid this obvious source of issues with ErrorType
showing up during the initial (poor) typecheck and then blocking
progress when we do a more specific check later.

rdar://problem/26462306
rdar://problem/25248190
2016-06-27 16:50:30 -07:00
Saleem Abdulrasool
4984c96caa fix tests for FileCheck behaviour (DAG edition)
FileCheck does not support the combination negation.  These tests were incorrect
and silently passing rather than checking what they intended.
2016-03-12 20:12:23 -08:00
Ben Langmuir
d871c9a529 [CodeCompletion] Split code completion operator kind out
...into separate prefix, postfix and infix operators. Also incidentally
make the whitespace around operators special so we can decide when to
skip over it. Tested in SourceKit.

Swift SVN r32468
2015-10-06 22:52:16 +00:00
Ben Langmuir
9448df6fae [CodeCompletion] Add initial support for completing infix operators
This allows us to start code-completing infix operators in postfix
expressions.  As a first step, this patch only handles completing
against the immediate LHS (so for example 1 == 1 <here> doesn't suggest
boolean operators yet).

The next step is to feed the leading sequence expression from the parser
in so we can consider how the operator being completed fits into the
whole sequence expression.

For rdar://problem/22460167

Swift SVN r32465
2015-10-06 20:48:03 +00:00
Ben Langmuir
f819eb01eb [CodeCompletion] Add initial support for completing postfix operators
This allows us to start code-completing postfix operators (generally !,
++, and --), which lays some of the groundwork for completing the much
more interesting infix operators.

These only show up when in postfix position
  x<here>

For  rdar://problem/22460167

Swift SVN r32355
2015-09-30 23:48:17 +00:00
Ben Langmuir
64b1cd6fd3 [CodeCompletion] Treat top-level variables as local in top-level completion
Global variables from the same source file are more like locals when
writing top-level code, particularly in Playgrounds. Other declarations
(types, global functions, etc.) are unaffected.

rdar://problem/22329905

Swift SVN r31992
2015-09-16 16:35:27 +00:00
Xi Ge
7b6b26a46d [CodeCompletion] Only filter out non-required inits for class type.
Swift SVN r30893
2015-08-01 00:05:03 +00:00
Xi Ge
29fcee3f0b [CodeCompletion] Show only required init() as members of dynamic metatype.
rdar://22074073

Swift SVN r30888
2015-07-31 22:49:55 +00:00
Xi Ge
5a1946eb53 [CodeCompletion] Add init() to the code completion results after metatype + dot.
rdar://21474100

Swift SVN r30781
2015-07-30 00:10:43 +00:00
Ben Langmuir
5f2bcba8ba Update tests for code-completion modulename change
Add module name to OtherModule result output and update the tests
accordingly.

Swift SVN r26262
2015-03-18 16:40:28 +00:00
Denis Vnukov
152df92966 [CodeCompletion] Code Completion String getName should always return non-empty string value for
valid code completions. Code completion tests call and validate getName’s result. 

A minor fix for code completion fro subscripts.



Swift SVN r25101
2015-02-09 22:32:05 +00:00
Dmitri Hrybenko
3b04d1b013 tests: reorganize tests so that they actually use the target platform
Most tests were using %swift or similar substitutions, which did not
include the target triple and SDK.  The driver was defaulting to the
host OS.  Thus, we could not run the tests when the standard library was
not built for OS X.

Swift SVN r24504
2015-01-19 06:52:49 +00:00
Ted Kremenek
fad874708e Adjust test cases.
Swift SVN r17964
2014-05-12 22:01:52 +00:00
Argyrios Kyrtzidis
df86c54874 [IDE] Rename test/CodeCompletion -> test/IDE
Swift SVN r6842
2013-08-02 17:03:21 +00:00