Commit Graph

61 Commits

Author SHA1 Message Date
Max Moiseev
0a69646df4 [test] Address the sourcekit test failures 2017-09-29 11:26:56 -07:00
Marcelo Fabri
09ede06f80 [ASTPrinter] Add trailing space after operator declaration (SR-3891) 2017-09-17 16:09:48 -03:00
Slava Pestov
696694b61d Update some IDE tests 2017-09-14 01:15:31 -07:00
Alex Hoppen
1c7e289b96 [Mangling] Adjust subscript mangling to not include "subscript"
Change the mangling of accessors to have a variable or subscript node
as their only child node, while subscript nodes no longer contain a decl
name.
2017-09-10 19:44:07 +02:00
Xi Ge
34e2aec662 Parser: use parser to generate a refined token stream to help syntax coloring. (#11809)
This patch allows Parser to generate a refined token stream to satisfy tooling's need. For syntax coloring, token stream from lexer is insufficient because (1) we have contextual keywords like get and set; (2) we may allow keywords to be used as argument labels and names; and (3) we need to split tokens like "==<". In this patch, these refinements are directly fulfilled through parsing without additional heuristics. The refined token vector is optionally saved in SourceFile instance.
2017-09-08 10:28:19 -07:00
Arnold Schwaighofer
f442dd93bd CompilerInvocation: If no optimization flag is set default to Onone
I noticed in a follow-up patch that if you just swiftc without passing Onone
these flags are not set and sometimes happen to default to right thing ... or
not; as can be seen by the test cases modified. For example, at Onone we are
supposed to include an extra swift module "SwiftOnoneSupport".
2017-08-04 11:49:16 -07:00
Doug Gregor
be5bc3fd07 [GSB] Eliminate two more uses of ArchetypeResolutionKind::AlwaysPartial.
We don't need to force the creation of potential archetypes when
finding anchors, because new potential archetypes will only be created
by this process in ill-formed generic signatures. Tolerate failure
whenever this happens (for now) and the failure paths will become dead
once AlwaysPartial is eliminated fully.
2017-06-28 06:23:52 -07:00
Doug Gregor
9ff7ff73ef Fix up order-dependent test cases 2017-05-15 22:17:19 -07:00
Argyrios Kyrtzidis
9b9c84a708 Merge pull request #8972 from akyrtzi/index-external-symbol-namespacing
[index] Use a #pragma to apply module namespacing for exported ObjC header and match Swift namespaced USRs with the clang side
2017-04-24 21:13:12 -07:00
Argyrios Kyrtzidis
792d7c06a5 [test/SourceKit/DocSupport] Fix test for @objc USR change 2017-04-24 14:13:37 -07:00
Jordan Rose
129fd372d5 ASTPrinter: Qualify names when printing nested declarations.
That is, if you have this declaration:

    struct Outer {
      struct Inner {
        // ...
      }
    }

and you're just printing 'Inner', print it like this:

    struct Outer.Inner {
      // ...
    }

This comes up with the ClangImporter's import-as-member feature, and
is also about to affect how error code enums are imported as well.

This is currently only enabled in certain contexts: always when
printing interfaces, and for types (but not other members) when
printing declarations for Quick Help.

rdar://problem/28208090
2017-04-24 09:57:40 -07:00
Max Moiseev
8ca814cc8c Merge remote-tracking branch 'origin/master' into new-integer-protocols 2017-04-17 14:40:20 -07:00
Jordan Rose
2d84981fc2 Improve the mangling of typealiases.
- Allow them to use substitutions.
- Consistently use 'a' as a mangling operator.
- For generic typealiases, include the alias as context for any generic
  parameters.

Typealiases don't show up in symbol names, which always refer to
canonical types, but they are mangled for debug info and for USRs
(unique identifiers used by SourceKit), so it's good to get this
right.
2017-04-17 11:31:15 -07:00
Max Moiseev
835b8809d2 Merge branch 'master' into new-integer-protocols 2017-03-07 16:18:54 -08:00
Erik Eckstein
a04a29af4f mangling: efficient mangling of repeated substitutions
Instead of appending a character for each substitution, we now prefix the substitution with the repeat count, e.g.
AbbbbB -> A5B

The same is done for known-type substitutions, e.g.
SiSiSi -> S3i

This significantly shrinks mangled names which contain large lists of the same type, like
  func foo(_ x: (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int))

rdar://problem/30707433
2017-03-05 17:41:43 -08:00
Erik Eckstein
7995d3d35a SourceKit: Use new mangling for USR generation. 2017-02-23 12:47:10 -08:00
Nathan Hawes
444775f58a Merge pull request #7670 from nathawes/rdar16271632
Use clang-style USRs for swift decls that are exposed to Objective C
2017-02-21 17:00:28 -08:00
David Farler
450028fbe8 [ASTPrinter] Restore printing generic requirement contexts
cfe9e6a3de removed calls to pre/post
printing of PrintStructureKind::GenericRequirement, so SourceKit DocInfo
requests started droping the markers for generic requirements, causing
some weirdness with documentation rendering and post-processing.

Restore the calls to printStructPre/Post when printing generic
requirements.

rdar://problem/30561880
2017-02-21 12:46:08 -08:00
Nathan Hawes
c9758c2c0f Use clang-style USRs for swift decls that are exposed to Objective C 2017-02-21 09:42:33 -08:00
Doug Gregor
90f021485d [Serialization] Serialize archetypes as generic environment + interface type.
Rather than serializing the complete structure of all archetypes
(which is completely redundant), serialize a reference to their owning
generic environment as well as their interface type. The archetype
itself will be reconsituted by mapping the interface type into that
generic environment.
2017-02-09 23:50:17 -08:00
Max Moiseev
aecccc7e48 Merge remote-tracking branch 'origin/master' into new-integer-protocols 2017-01-09 17:38:04 -08:00
Max Moiseev
6a06b667da Fixing some and XFAILing other failing tests 2017-01-06 17:56:20 -08:00
Xi Ge
264057dc04 [DocSupport] Ensure synthesized target is correct for enclosed nominal decls inside extension declarations. rdar://29857103 2017-01-06 15:40:14 -08:00
Xi Ge
6c115a4d0a [ASTPrinter] Properly limit the decl context of synthesized extensions to avoid crash. rdar://29857103 2017-01-04 17:34:19 -08:00
Slava Pestov
0948506cc2 ASTPrinter: Refactor usages of ArchetypeType::getSelfProtocol()
This fixes an issue where a 'Self' return type from a protocol
extension prints the USR of the protocol and not the extension.
2016-11-19 00:27:44 -08:00
Xi Ge
be3910d5a7 [AST] Put DeclKind::Subscript to the value decl bucket because it is one. rdar://28780008 2016-10-25 11:26:23 -07:00
Xi Ge
64082e122f SourceKit: checking context match before calling TypeBase::getMemberSubstitutions(const DeclContext *dc). rdar://28780008
TypeBase::getMemberSubstitutions(const DeclContext *dc) collects type
substitution information when a decl context can be treated as part of the
type definition. However, we call it without checking whether the
part-of-whole relationship really holds. This patch checks the
pre-condition before calling it to fix a crash.
2016-10-24 13:28:13 -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
Rintaro Ishizaki
229beac813 [SE-0081][ASTPrinter] Move where clause to the end of declaration 2016-09-04 02:42:56 +09: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
Jorge Bernal
0a3f913b20 SE-0070: Make Optional Requirements Objective-C-only.
Optional protocol requirements now require an explicit @objc attribute.

Fixes SR-1395
2016-05-06 11:05:52 +02:00
Xi Ge
c4d7b1a185 ASTPrinter: never synthesize extensions for raw types of enum decls.
Even thought raw types are specified in inheritance clauses, their
members are not usable through an enum instance. Thus, there is no
point to synthesize their members.
2016-04-22 22:52:46 -07:00
Jordan Rose
7ad6a8bd61 [test] Fix SourceKit tests for 2e38280.
Also filed <rdar://problem/25858559> "SourceKit response info for
enum shouldn't include members of the raw type" to keep it from
happening again.
2016-04-21 11:50:27 -07:00
Michael Buckley
daa4714864 Merge branch 'master' into int-from-unsafepointer 2016-04-13 20:44:08 -07:00
Michael Buckley
8e8e61b0bc Add inititializers to Int and UInt which take UnsafePointers and UnsafeMutablePointers 2016-04-12 20:03:11 -07:00
David Farler
fbc220a036 Revert "Revert "Enable cmark smart punctuation in doc comments""
This reverts commit f723b86614 and
updates the IDE tests that incidentally included some punctuation.
No new tests are necessary - the character level tests are exercised
in cmark itself.
2016-04-10 13:32:43 -07:00
Manav Gabhawala
7928140f79 [SE-0046] Implements consistent function parameter labels by discarding extraneous parameter names and adding _ where necessary 2016-04-06 20:21:58 -04: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
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
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
b4d0cb4ffe ModulePrinting: Avoid printing duplicated members in synthesized extensions. 2016-03-23 15:19:16 -07:00
Xi Ge
b3cde464dd [SourceKit] For consistency, using underscore instead of hyphen in recently introduced key names. NFC 2016-03-22 22:21:56 -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
5168083bf3 ModulePrinting: Print new lines between members of a decl. 2016-03-11 12:26:04 -08:00
Ben Langmuir
65f0e7eb94 [SourceKit] Add annotation tags for generic type requirements
Each requirement gets tagged. We could also tag the whole where clause
if we need to, but so far it hasn't been interesting.

rdar://problem/24292226
2016-03-03 16:11:07 -08:00
Ben Langmuir
c934315315 [SourceKit] Update terminology in generic parameter tag names
And add a test that does cursor info on the generic parameter itself,
not just on the parent decl context.

rdar://problem/24292226
2016-03-03 13:34:16 -08:00
Ben Langmuir
1182e41e01 [SourceKit] Add tags for generic parameters to annotated decl
Like typerefs, we want to show the USR in the tag.

rdar://problem/24292226
2016-03-03 12:47:09 -08:00