Commit Graph

71 Commits

Author SHA1 Message Date
QuietMisdreavus
07fc40c522 allow any ValueDecl to take part in picking a best candidate (#65441)
rdar://105099207
2023-04-27 08:03:12 -06:00
Hamish Knight
c1843479f1 Drop SerializedOK parameter from getRawComment
It doesn't seem like there's any client that's
actually taking advantage of setting it to `false`,
and its default value of `false` is more likely
than not going to cause clients to accidentally
miss comments that they may want. In fact, this
was exactly the case for code completion's brief
field. Finally, the parameter wasn't even
consistently applied, as we would attempt to
deserialize swiftdoc comments even if it were
`false`.
2023-04-26 12:38:37 +01:00
QuietMisdreavus
ff5c5312e8 [SymbolGraphGen] move "protocol implementations" check into isImplicitlyPrivate (#64867)
rdar://107432084
2023-04-05 09:53:53 -06:00
QuietMisdreavus
0d74959af6 don't print macro definitions in symbol graphs (#64732)
rdar://106862694
2023-03-29 17:04:00 -06:00
QuietMisdreavus
d9c8dca5d1 [SymbolGraphGen] allow SourceKit to print declarations for private stdlib symbols (#64556)
Resolves rdar://103112656
Resolves #62457
2023-03-28 10:30:36 -06:00
Ellie Shin
7d23db3646 Create PackageUnit class, and Package entries to DeclContext / ASTHierarchy
Previously enum AccessLimitKind was
added to distinguish access scopes b/t package and public while keeping
DeclContext null but it proved to be too limiting. This PR creates package specific entries for DeclContext and
ASTHierarchy. It create a new class PackageUnit that can be set as the parent DeclContext of ModuleDecl. This PR
contains addition of such entries but not the use of them; the actual use of them will be in the upcoming PRs.

Resolves rdar://106155600
2023-03-02 13:20:51 -08:00
Victoria Mitchell
9cca3c1405 allow implementation symbols to remain if they have their own docs 2023-02-17 17:46:50 -07:00
Victoria Mitchell
4ec3e5291f add new flag to skip "protocol implementation" symbols
rdar://59899968
2023-02-16 14:00:04 -07:00
QuietMisdreavus
36ab59629d Merge pull request #63391 from apple/QuietMisdreavus/factory-init-sgf
don't print the "not inherited" mark in SGF declarations
2023-02-07 15:12:37 -07:00
Victoria Mitchell
d208dd9993 don't print the "not inherited" mark in SGF declarations
rdar://104917487
2023-02-02 14:53:03 -07:00
Alex Hoppen
2fb487f4b2 [SymbolGraph] Sort edges to get consistent symbol graph string representations 2023-02-02 22:03:25 +01:00
Max Obermeier
429f15f619 connect memberOf relationship of default implementation targets to extension block symbol if extension block symbol format is used (#61406) 2022-11-15 16:10:59 -07:00
Max Obermeier
ddf5cf944c fix symbol graph bug where enabling extension block format caused inheritsFrom relationships of extended symbols to be emitted in extension graphs (#61951) 2022-11-15 09:18:09 -07:00
Doug Gregor
5ab6b72604 [Macros] Turn Macro into a declaration node.
Although the declaration of macros doesn't appear in Swift source code
that uses macros, they still operate as declarations within the
language. Rework `Macro` as `MacroDecl`, a generic value declaration,
which appropriate models its place in the language.

The vast majority of this change is in extending all of the various
switches on declaration kinds to account for macros.
2022-11-13 12:21:29 -08:00
Ben Barham
1aee0af1d4 [SymbolGraph] Output custom attributes
Custom attributes were being skipped as their attribute name started
with a "_". Underscored attributes are typically unstable and thus
shouldn't be printed, but "_" is not being used for that purpose in the
case of "_custom".

Rather than checking for "_" or "__", just use `UserInaccessible`. This
property is used for attributes that shouldn't be shown to users in eg.
completion/printing/etc.

Resolves rdar://99029554.
2022-10-31 15:16:59 -07:00
Max Obermeier
453fd2231b Allow for emission of swift.extension symbols for extensions to external types in swiftSymbolGraphGen (#59047)
This includes:
 - bumping the SWIFT_SYMBOLGRAPH_FORMAT_MINOR version
 - introduction of the "swift.extension" symbol and "extensionTo" relationship
 - adding support for ExtensionDecl to the Symbol class
 - adding a "typeKind" field to the symbol's extension mixin which indicates what kind
   of symbol was extended
 - intoduction of the -emit-extension-block-symbols flag, which enables the behavior
   outlined below
 - adaptions to SymbolGraphASTWalker that ensure a swift.extension symbol is emitted
   for each extension to a type that does not exist in the local symbol graph
 - adaptions to SymbolGraph and SymbolGraphASTWalker that ensure member and conformance
   relationships are correctly associated with the swift.extension symbol instead of
   the original type declaration's (extended nominal's) symbol where applicable
 - adaptions to SymbolGraphASTWalker that ensure swift.extension symbols are connected
   to their respective extended nominal's symbol using an extensionTo relationship

Testing:
- adds SymbolGraph tests that test behavior only relevant in
  -emit-extension-block-symbols mode
- adapts some SymbolGraph tests to additionally test similar behavior for
  extensions to external types in -emit-extension-block-symbols mode
- adapts some SymbolGraph tests to (additionally or exclusively) test the
  behavior with -emit-extension-block-symbols mode enabled

Bugfixes:
- fixes a bug where some conformsTo relationships implicated by the conformances
  declared on an extension to an external type were not emitted
  (see test/SymbolGraph/Relationships/ConformsTo/Indirect.swift)

Further changes:
- documents the strategy for naming and associating children declared in extensions
  to typealiases (see test/SymbolGraph/Relationships/MemberOf/Typealias.swift,
  test/SymbolGraph/Symbols/Names.swift)
2022-09-16 12:02:40 -06:00
QuietMisdreavus
d043378412 [SymbolGraphGen] Refactor export-import logic (#61049)
rdar://98808363
2022-09-13 10:08:10 -06:00
QuietMisdreavus
f674b473ec introduce a @_documentation(...) attribute to influence SymbolGraphGen (#60242)
* add @_documentation(...) attribute to influence SymbolGraphGen

rdar://79049241
2022-09-06 14:12:42 -06:00
Slava Pestov
eb77da1ca3 SymbolGraph: Stop calling getAllConformances() on protocols 2022-08-23 00:03:37 -04:00
QuietMisdreavus
a83a17c88b Revert "consider requirements of an underscored protocol to also be underscored (take two) (#59531)" (#60096)
This reverts commit ababa79398.
2022-07-20 09:54:03 -06:00
QuietMisdreavus
2d874788f6 [SymbolGraphGen] only include the given symbol for qualified imports (#59852)
* only include the given symbol for qualified imports

rdar://96309088

* re-exporting one type should not allow unrelated types to sneak in

* ensure that children of re-exported types are also re-exported
2022-07-08 09:13:08 -06:00
QuietMisdreavus
ababa79398 consider requirements of an underscored protocol to also be underscored (take two) (#59531)
* Revert "Revert "consider requirements of an underscored protocol to also be underscored""

* make SkipsPublicUnderscore more resilient to non-determinism
2022-06-23 13:26:21 -06:00
QuietMisdreavus
5e065f0c31 Revert "consider requirements of an underscored protocol to also be underscored (#59480)"
This reverts commit a8ecfc94ec.
2022-06-16 20:33:34 -06:00
QuietMisdreavus
a8ecfc94ec consider requirements of an underscored protocol to also be underscored (#59480)
rdar://94336558
2022-06-16 14:20:14 -06:00
QuietMisdreavus
1b5c3d79dd skip underscored implicit Clang decls (#42493)
rdar://92018648
2022-04-22 16:43:31 -06:00
QuietMisdreavus
e24f126165 [SymbolGraph] don't emit symbols for implicit inherited initializers (#41985)
rdar://90401347
2022-04-01 10:02:19 -06:00
Franklin Schrans
9cd44ca5d1 [SymbolGraphGen] Emit symbols from exported modules
When emitting a symbol graph file for a module that import modules via
`@_exported import`, emits those modules' symbols as well.

SR-15753

rdar://89547374
2022-02-28 17:21:25 +00:00
Franklin Schrans
7c5a8fd0a1 [SymbolGraph] Don't emit symbols that are unavailable on all platforms
rdar://88807294
2022-02-16 10:10:02 +00:00
QuietMisdreavus
f0c96b1c97 Merge pull request #41141 from apple/QuietMisdreavus/symgraph-synth-init
[SymbolGraph] don't filter out all implicit decls
2022-02-03 16:25:05 -07:00
Victoria Mitchell
08fe7c2134 [SymbolGraph] don't filter out all implicit decls 2022-02-02 12:57:40 -07:00
Victoria Mitchell
9bd3454566 [SymbolGraph] consider underscored symbols as private if they're internal
rdar://86294802
2022-02-02 09:56:50 -07:00
Victoria Mitchell
3011a3cfca [SymbolGraphGen] don't emit access control attributes in declarations
rdar://85280786
2021-12-22 16:35:12 -07:00
Ben Barham
6aa3e0fd00 [SymbolGraph] Determine optional requirement by presence of OptionalAttr
Rather than checking the underlying ObjectiveC decl, use the presence of
`OptionalAttr` to determine if a requirement is optional instead. This
is already added by the importer when necessary. An added benefit here
is that this also works for optional requirements defined in Swift (ie.
`@objc optional ...`).
2021-09-25 11:50:53 +10:00
Victoria Mitchell
dd39496098 do not synthesize subclass methods
rdar://80091081
2021-07-02 14:43:53 -06:00
Victoria Mitchell
d281722589 add symbol-graph flag to include SPI symbols
rdar://70794131
2021-05-20 15:10:49 -06:00
QuietMisdreavus
08d1c33e6f Merge pull request #37278 from apple/QuietMisdreavus/default-relation
[SymbolGraph] add "memberOf" relations for remote protocol implementations
2021-05-07 16:19:18 -06:00
Victoria Mitchell
633ffece87 compare module names instead of pointers 2021-05-06 10:08:09 -06:00
Victoria Mitchell
4b5045f25a add "memberOf" relations for remote protocol implementations
rdar://75729692
2021-05-05 15:44:28 -06:00
Alex Hoppen
e7d56037e8 Merge pull request #37133 from ahoppen/pr/serialize-text-module-symbolgraph
[SymbolGraph] Fix crasher when retrieving cursor info of method defined in ObjC
2021-04-30 23:13:15 +02:00
Alex Hoppen
5d3fb8f26d [SymbolGraph] Fix crasher when retrieving cursor info of method defined in ObjC
In a mixed Objective-C / Swift module, we have a Clang module overlay that’s a Source file, not a serialized AST as is currently assumed. That assumption caused a crash when retrieving the symbol graph as part of a cursor info request to SourceKit, which was invoked on a method defined in the Objective-C part of the module.

To fix the crash, recursively use the same logic that already exists to serialize a module to also serialize the clang overlay module since that function alreayd correctly handles the distinction between source files and serialized ASTs.

Resolves rdar://76951147
2021-04-29 17:54:18 +02:00
Alex Hoppen
370128e6b6 [SymbolGraph] Fix a crash for member in invalid extension
Don’t record a `memberOf` relationship if we couldn’t look up the target, e.g. because the member is declared in an extension whose extended type doesn’t exist.

Resolves rdar://74063899
2021-04-29 14:21:52 +02:00
Victoria Mitchell
19e6144be4 always print enum elements
in some situations, enum element decls are being skipped when rendering
declaration fragments. this trips an assertion in the declaration
fragment renderer that ensures that it always renders something. by
always rendering enum elements, we can sidestep this issue.
2021-03-19 10:43:52 -06:00
Victoria Mitchell
db3685aa29 don't emit navigator name if it's the same as subHeading 2021-03-01 10:57:54 -07:00
Ashley Garland
69c4fc47cb Add optional -emit-symbol-graph output when emitting modules
rdar://71497047
2021-01-28 09:55:33 -08:00
Varun Gandhi
f9570b2d34 [NFC] Pass full convention printing boolean for types etc.
When -experimental-print-full-convention is set, we should be printing
the full convention in diagnostics, doc comments etc.
2021-01-25 18:47:39 -08:00
Nathan Hawes
388052b6ab [SymbolGraph][CursorInfo] Add option to SourceKit's CursorInfo request to include the SymbolGraph JSON
Adds a new 'key.retrieve_symbol_graph' option to the request. When set to 1 it
includes the JSON for a SymbolGraph containing a single node for the symbol at
the requested position.

This also extends the SymbolGraph library with a new entry point to get a graph
for a single symbol, and to additionally support type substitution to match the
existing CursorInfo behavior (e.g. so that when invoked on `first` in
`Array<Int>().first`, the type is given as `Int?` rather than `Element?`).

Resolves rdar://problem/70551509
2020-12-12 14:38:41 +10:00
Victoria Mitchell
bfb2793e8a include cross-import overlay information in the symbol graph itself 2020-12-10 19:13:37 -07:00
Ashley Garland
ecf8d556e5 [SymbolGraph] Don't link type identifier fragments to private symbols
These links will never resolve because the symbols are never emitted
in the first place.

rdar://64178490
2020-08-07 14:20:28 -07:00
Ashley Garland
dd7a7f7c89 [SymbolGraph] Print non-underscored attributes in declarations
rdar://63338507
2020-06-05 13:36:22 -07:00
Ashley Garland
a72231128e [SymbolGraph] Don't print inherited list in declaration fragments
Add a new `PrintInherited` flag to `PrintOptions` to support this.

rdar://63033669
2020-06-04 11:52:51 -07:00