Commit Graph

30 Commits

Author SHA1 Message Date
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
Xi Ge
64efa48c65 [SourceKit][DocInfo] When the underlying type of a type alias decl exists, report the conformances of the underlying type. rdar://26408167 (#3394)
Showing only the conforming associated types provides
little information to doc viewers. This patch digs the
underlying type of an associated type to report the
conformance info of those.
2016-07-07 16:24:01 -07:00
Xi Ge
ca93fa6d1b [SourceKit] DocInfo: Explicitly report the optionality of protocol members in response. rdar://25129725 2016-04-01 14:55:11 -07:00
Ben Langmuir
4d9c9f6098 Move SourceEntityWalker into libAST NFC
It fits right in among our other AST walkers and lets us use it lower in
the stack than libIDE.
2016-04-01 14:14:06 -07:00
Xi Ge
adc65bf609 [SourceKit] DocInfo: Simplify the type parameter names inside fully annotated decls. 2016-04-01 11:55:06 -07:00
Xi Ge
8afcf65fa2 [SourceKit] DocInfo: Update the UIdent for synthesized extensions to respect the synthesized targets instead of the original extended types. 2016-03-31 18:12:53 -07:00
Xi Ge
126bc4e942 [SourceKit] DocInfo: For synthesized extension, update their extended fields to the synthesized target instead of their original extended types. rdar://25439820 2016-03-31 17:53:21 -07:00
Xi Ge
16a23d79b4 [SourceKit] DocInfo: Update the printed doc comment for synthesized extensions therefore it reflects the synthesized targets explicitly. rdar://25439820 2016-03-31 17:53:21 -07:00
Xi Ge
61248dec24 [SourceKit] DocInfo: Fixing a paired-callback mismatch issue when merging nominals with extensions. rdar://25431244 2016-03-31 12:43:34 -07:00
Xi Ge
37f5a0390a [SourceKit] DocInfo: Add a new entry to indicate the default implementation of a protocol member in its extensions. rdar://25032869 2016-03-30 14:26:17 -07:00
Xi Ge
760c2f12cf [SourceKit] Update the way of representing USRs for synthesized extensions.
Instead of using 'key.usr' and 'key.synthesizedusr', we start to use 'key.usr' and 'key.original-usr' so
that 'key.usr' is consistently being the unique ID for a code entity.
2016-03-22 15:38:41 -07:00
Xi Ge
f338bdfbb7 [SourceKit] Incorporate synthesized extensions into DocInfo request. rdar://24912860
This commit reuses our code for generating synthesized extensions from module printing to enhance
documentation generation.
2016-03-22 14:49:22 -07:00
Xi Ge
33c53a12eb ASTPrinter: Pass the bracket options to pre and post printing callbacks.
Need this for rdar://24912860
2016-03-22 14:49:22 -07:00
Xi Ge
66fb8062fe ModulePrinting: For decls without doc-comment, we print the doc-comment associated with their conformances, if any.
Inspired by rdar://24409720
2016-03-21 14:35:32 -07:00
Ben Langmuir
1b08d83b6f [SourceKit] Annotate class method dynamic Self return types
Pass through the original Type in addition to the TypeDecl so that we
can distinguish DynamicSelfType with underlying ClassType from just any
old ClassType.

rdar://problem/25158493
2016-03-14 19:43:54 -07:00
Ben Langmuir
1a83912c4e [SourceKit] Add fully annotated declaration to DocInfo requests
Also expose the printing function as a SwiftLangSupport static method.
Ideally we could move this into libIDE, but it currently depends on the
UIdent visitor to get decl-specific tag names and it's not obvious how
we should hoist/abstract that out in a nice way.

rdar://problem/24292226
rdar://problem/24292304
2016-02-25 20:12:13 -08:00
Ben Langmuir
3e9bfa137d [SourceKit] Add decl.var.parameters entries to the fully annotated decl
This is the first part of adding parameter substructure so that clients
can reason about more of the function declaration.

rdar://problem/24292226
2016-02-24 11:39:47 -08:00
Xi Ge
bf1436a367 ASTPrinter: Move the logic for collecting all module groups from SourceKit to an IDE API, NFC. 2016-02-22 11:50:34 -08:00
Xi Ge
329345077b [SourceKit] Add a new query to collect all group names from a module.
Input:
  Request Id: 'source.request.module.groups'
  Required field: 'key.modulename'

Output:
  Array of group names in that module, if any.
2016-02-08 17:22:10 -08:00
Xi Ge
77b7180f1a Rename CodeCompletionTypeChecking.h to IDETypeChecking.h since it's used by more clients now. NFC 2016-02-04 11:09:21 -08:00
Xi Ge
ae60159816 [ModulePrint] Add the initial implementation for printing synthesized extensions.
For a concrete type, members from its conforming protocols' extensions can be hard
to manually surface. In this commit, when printing Swift modules, we start to replicate these
extensions and synthesize them as if they are the concrete type's native extensions.

Credit to Doug for suggesting this practice.
2016-02-02 14:53:21 -08:00
Chris Lattner
6afe77d597 Eliminate the Parameter type completely - now ParameterList is just
an overblown array of ParamDecl*'s that also keeps track of parenlocs
and has helper methods.
2016-01-03 14:45:38 -08:00
Mark Lacey
0d2195ba6c Fixup SourceKit now that TypeLoc is in ParamDecl.
That change was introduced in 4479b46, but SourceKit wasn't updated at
the same time.
2016-01-01 15:15:56 -08:00
Chris Lattner
a30ae2bf55 Merge pull request #836 from zachpanz88/new-year
Update copyright date
2015-12-31 19:36:14 -08:00
Chris Lattner
7daaa22d93 Completely reimplement/redesign the AST representation of parameters.
Parameters (to methods, initializers, accessors, subscripts, etc) have always been represented
as Pattern's (of a particular sort), stemming from an early design direction that was abandoned.
Being built on top of patterns leads to patterns being overly complicated (e.g. tuple patterns
have to have varargs and default parameters) and make working on parameter lists complicated
and error prone.  This might have been ok in 2015, but there is no way we can live like this in
2016.

Instead of using Patterns, carve out a new ParameterList and Parameter type to represent all the
parameter specific stuff.  This simplifies many things and allows a lot of simplifications.
Unfortunately, I wasn't able to do this very incrementally, so this is a huge patch.  The good
news is that it erases a ton of code, and the technical debt that went with it.  Ignoring test
suite changes, we have:
   77 files changed, 2359 insertions(+), 3221 deletions(-)

This patch also makes a bunch of wierd things dead, but I'll sweep those out in follow-on
patches.

Fixes <rdar://problem/22846558> No code completions in Foo( when Foo has error type
Fixes <rdar://problem/24026538> Slight regression in generated header, which I filed to go with 3a23d75.

Fixes an overloading bug involving default arguments and curried functions (see the diff to
Constraints/diagnostics.swift, which we now correctly accept).

Fixes cases where problems with parameters would get emitted multiple times, e.g. in the
test/Parse/subscripting.swift testcase.

The source range for ParamDecl now includes its type, which permutes some of the IDE / SourceModel tests
(for the better, I think).

Eliminates the bogus "type annotation missing in pattern" error message when a type isn't
specified for a parameter (see test/decl/func/functions.swift).

This now consistently parenthesizes argument lists in function types, which leads to many diffs in the
SILGen tests among others.

This does break the "sibling indentation" test in SourceKit/CodeFormat/indent-sibling.swift, and
I haven't been able to figure it out.  Given that this is experimental functionality anyway,
I'm just XFAILing the test for now.  i'll look at it separately from this mongo diff.
2015-12-31 19:24:46 -08:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Dmitri Gribenko
4324e7c903 Remove conditional compilation of tvOS 2015-12-01 14:43:45 -07:00
Argyrios Kyrtzidis
a11b5628e3 [SourceKit] Use the correct macro, 'SWIFT_ENABLE_TARGET_TVOS'. 2015-11-05 18:34:42 -08:00
Argyrios Kyrtzidis
d19e4ae026 [SourceKit] Add license notices to all the source files. 2015-11-05 12:01:14 -08:00
Argyrios Kyrtzidis
8ff6a98a99 [sourcekit] Merge SourceKit into the Swift repo.
The code goes into its own sub-tree under 'tools' but tests go under 'test',
so that running 'check-swift' will also run all the SourceKit tests.

SourceKit is disabled on non-darwin platforms.
2015-11-05 01:09:08 -08:00