Commit Graph

24 Commits

Author SHA1 Message Date
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
Ashley Garland
975d2520e8 [SymbolGraph] Print where clause in full declaration fragments
rdar://63233737
2020-06-02 11:33:42 -07:00
Ashley Garland
51ce1f2b0f [SymbolGraph] Look for @_spi on extensions
Consider declarations inside `@_spi` extensions to be internal.

Clean up the "implicitly private" check to work for `Decl` and not just
`ValueDecl`, allowing it to be used directly on extensions instead of having to
look for extensions everywhere.

rdar://63361634
2020-05-27 16:00:15 -07:00
Ashley Garland
720d3d2f2a [SymbolGraph] Show get/set on property/subscript full declarations
But don't show them in subheading contexts.

rdar://63233897
2020-05-20 14:16:45 -07:00
Ashley Garland
f2c10d2ed4 [SymbolGraph] Use identifier for type name fragments
In the cases where we specialize the presentation of type declarations in a
subheading or navigator setting, make sure to use the `identifier` fragment
kind instead of `typeIdentifier` to keep it consistent with the normal or
"full" setting.

rdar://62953144
2020-05-06 17:28:28 -07:00
Varun Gandhi
65577940d0 [NFC] Get rid of -Wrange-loop-analysis warnings. (#31324) 2020-04-27 09:47:52 -07:00
Ashley Garland
d4e5c6f438 [SymbolGraph] Add navigator declaration fragments
Only print the type name for a type's navigator fragments.

Don't print where clauses for navigator or subHeading fragments.

rdar://62353465
2020-04-24 20:20:19 -07:00
Ashley Garland
d5aa0d0543 [SymbolGraph] Pick best synthesized member when possible
A type can have multiple overloads available from different protocols from
which it inherits. Ask the type checker to pick the best one where possible.

rdar://60193198
2020-04-24 18:24:54 -07:00
Anthony Latsis
74252028ca AST: Rename getFullName -> getName on ValueDecl & MissingMemberDecl 2020-04-23 05:16:55 +03:00
Ashley Garland
9d6ec078c2 [SymbolGraph] Filter @_spi declarations
These definitely shouldn't be showing up in symbol graphs with a minimum access
level of `public`, and it's not clear whether another minimum access level
should show these. For now, filter them unconditionally.

rdar://62081711
2020-04-21 14:01:58 -07:00
Ashley Garland
115a8de9ae [SymbolGraph] Type subheadings: don't print generics/inheritance
Subheadings for types are treated more as a title element and can't be
overloaded in the same way that other declarations can be. Abridge these
fragments to only contain the keyword and identifier.

rdar://62040714
2020-04-20 14:25:19 -07:00
AG
4e56349399 Merge pull request #31032 from bitjammer/acgarland/rdar-61459287-no-members-for-defaultimplementations-of-requirements
[SymbolGraph] Don't emit memberOf for default implementations or requ…
2020-04-15 14:03:18 -07:00
Ashley Garland
8316157c5e [SymbolGraph] Don't emit memberOf for default implementations or requirements
To differentiate between freestanding extensions of protocols and matching
default implementations with their requirements. Otherwise, it's difficult to
filter out "duplicate" entries for protocols.

rdar://61459287
2020-04-14 20:13:00 -07:00
Ashley Garland
9611047d4a [SymbolGraph] Add internal/externalParam declaration fragment
These were previously mapped to identifier. Some clients may wish to render
these differently in their declaration blocks.

rdar://61782916
2020-04-14 16:06:56 -07:00
Ashley Garland
72dbdb097d [SymbolGraph] Look at inherited protocols for default implementations
rdar://61178480
2020-04-13 15:47:46 -07:00
Dan Zheng
c834696bfa Add SynthesizedFileUnit.
`SynthesizedFileUnit` is a container for synthesized declarations. Currently, it
only supports module-level declarations.

It is used by the SIL differentiation transform, which generates implicit struct
and enum declarations.
2020-04-07 18:29:26 -07:00
Ashley Garland
7ce6753231 [SymbolGraph] Track conditional conformance
Requirements on extensions were only being gathered indirectly. This adds a new
optional field to `conformsTo` relationship edges, `swiftConstraints`, which
provides the requirements there.

rdar://60091161
2020-03-09 20:06:49 -07:00
Ashley Garland
f0887fa245 [SymbolGraph] Emit synthesized members
Emit copies of default implementations in protocol extensions and superclass declarations in conforming types and subclasses respectively using a virtual USR, i.e. `${REAL_USR}::SYNTHESIZED::${CONFORMING_OR_SUBCLASS_TYPE_USR}`.

- Add a -skip-synthesized-members option to skip these synthesized members.

- Create a new wrapping `Symbol` type that can also contain a base type declaration as well as the inherited declaration for those synthesized cases. Move some symbol-specific APIs there.

- Doc comments can “cascade” down to protocol extensions or refinements in concrete types. When emitting the doc comment for a symbol, look up through to superclasses or protocol requirements for where a doc comment is actually written.

- Clean up filtering of implicitly private (e.g. “public underscored”) types

rdar://problem/59128787
2020-03-04 16:04:21 -08:00
Ashley Garland
58bbe1ec04 SymbolGraph: Don't unconditionally add edge targets to the graph
Edge targets might point outside the module, so don't include them
unconditionally.

rdar://58876107
2020-02-11 13:23:16 -08:00
Ashley Garland
7190073a85 Serialize symbol graphs for extended modules separately
When a module extends a type from another module, serialize those symbols into
separated files dedicated to those extended modules. This makes it easier to
ingest and categorize those symbols under the extended module if desired.

rdar://58941718
2020-02-11 13:23:16 -08:00
Ashley Garland
be68f864e0 Move Symbol logic into SymbolGraph
Up to now, the `SymbolGraphASTWalker` was only concerned with one module. This
change prepares for emitting multiple symbol graph files, for each module that
the module of interest extended. There is only one walker, so extract the
symbol logic into `SymbolGraph`, where it can be reused.

rdar://58941718
2020-02-11 13:23:04 -08:00
Ashley Garland
7a3a0a9e23 Symbol graph support
Adds a tool `swift-symbolgraph-extract` that reads an existing Swift
module and prints a platform- and language-agnostic JSON description of
the module, primarly for documentation.

Adds a small sub-library `SymbolGraphGen` which houses the core
implementation for collecting relevant information about declarations.
The main entry point is integrated directly into the driver as a mode:
the tool is meant to be run outside of the normal edit-compile-run/test
workflow to avoid impacting build times.

Along with common options for other tools, unique options include
`pretty-print` for debugging, and a `minimum-access-level` options for
including internal documentation.

A symbol graph is a directed graph where the nodes are symbols in a
module and the edges are relationships between them. For example, a
`struct S` may have a member `var x`. The graph would have two nodes for
`S` and `x`, and one "member-of" relationship edge. Other relationship
kinds include "inherits-from" or "conforms to". The data format for a
symbol graph is still under development and may change without notice
until a specificiation and versioning scheme is published.

Various aspects about a symbol are recorded in the nodes, such as
availability, documentation comments, or data needed for printing the
shapes of declarations without having to understand specifics about the
langauge.

Implicit and public-underscored stdlib declarations are not included by
default.

rdar://problem/55346798
2020-01-10 09:53:37 -08:00