Commit Graph

9 Commits

Author SHA1 Message Date
Slava Pestov
892dd4594d SymbolGraph: Fixes for noncopyable generics and some small cleanups 2024-03-01 12:55:08 -05:00
Evan Wilde
41d59b215a Update Triple.h location
Triple moved from ADT to TargetParser. Updating includes to reflect
that.
2023-07-17 10:53:42 -07:00
Slava Pestov
8afff61699 AST: Replace TypeArrayView<GenericTypeParamType> with ArrayRef<GenericTypeParamType *>
This basically undoes 3da6fe9c0d, which in hindsight was wrong.

There were no other usages of TypeArrayView anywhere else except for
GenericSignature::getGenericParams(), and it was almost never what
you want, so callers had to convert back and forth to an ArrayRef.
Remove it.
2023-06-29 19:23:44 -04: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
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
Ashley Garland
a9d692c1fb [SymbolGraph] Only include where clause constraints in swiftExtension
Otherwise, this creates noise in conditional conformance phrasings.

rdar://64425199
2020-06-17 09:51:59 -07:00
Ashley Garland
06d1d502a1 [SymbolGraph] Ignore some Self requirements
To ease the burden on the client, ignore some generic requirements involving
Self. For example, `Self: P` where we already know that `Self` conforms to `P`.

An example case:

```
public struct S: Equatable {
  public static func ==(lhs: S, rhs: S) -> Bool { ... }
}
```

`!=` is defined in terms of `Self` and the default implementation has a `Self:
Equatable`. For the purposes of documentation, it's not necessary to specify
that again on the page of documentation for `!=`.

rdar://60963924
2020-04-13 13:17:33 -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
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