clang 17.0.0git
Public Types | Public Member Functions | Static Public Member Functions | List of all members
clang::extractapi::SymbolGraphSerializer Class Reference

The serializer that organizes API information in the Symbol Graph format. More...

#include "clang/ExtractAPI/Serialization/SymbolGraphSerializer.h"

Inheritance diagram for clang::extractapi::SymbolGraphSerializer:
Inheritance graph
Collaboration diagram for clang::extractapi::SymbolGraphSerializer:
Collaboration graph

Public Types

enum  RelationshipKind { MemberOf , InheritsFrom , ConformsTo }
 The kind of a relationship between two symbols. More...

Public Member Functions

Object serialize ()
 Serialize the APIs in APISet in the Symbol Graph format.
void serialize (raw_ostream &os) override
 Implement the APISerializer::serialize interface.
 SymbolGraphSerializer (const APISet &API, const APIIgnoresList &IgnoresList, APISerializerOption Options={}, bool ShouldRecurse=true)
- Public Member Functions inherited from clang::extractapi::APISerializer
virtual void serialize (raw_ostream &os)=0
 Serialize the API information to os.
 APISerializer ()=delete
 APISerializer (const APISerializer &)=delete
 APISerializer (APISerializer &&)=delete
APISerializeroperator= (const APISerializer &)=delete
APISerializeroperator= (APISerializer &&)=delete

Static Public Member Functions

static std::optional< Object > serializeSingleSymbolSGF (StringRef USR, const APISet &API)
 Serialize a single symbol SGF.
static StringRef getRelationshipString (RelationshipKind Kind)
 Get the string representation of the relationship kind.

Additional Inherited Members

- Protected Member Functions inherited from clang::extractapi::APISerializer
 APISerializer (const APISet &API, const APIIgnoresList &IgnoresList, APISerializerOption Options={})
virtual ~APISerializer ()=default
- Protected Attributes inherited from clang::extractapi::APISerializer
const APISetAPI
const APIIgnoresListIgnoresList
 The list of symbols to ignore.
APISerializerOption Options

Detailed Description

The serializer that organizes API information in the Symbol Graph format.

The Symbol Graph format ( models an API set as a directed graph, where nodes are symbol declarations, and edges are relationships between the connected symbols.

Definition at line 39 of file SymbolGraphSerializer.h.

Member Enumeration Documentation

◆ RelationshipKind

The kind of a relationship between two symbols.


The source symbol is a member of the target symbol.

For example enum constants are members of the enum, class/instance methods are members of the class, etc.


The source symbol is inherited from the target symbol.


The source symbol conforms to the target symbol.

For example Objective-C protocol conformances.

Definition at line 75 of file SymbolGraphSerializer.h.

Constructor & Destructor Documentation

◆ SymbolGraphSerializer()

clang::extractapi::SymbolGraphSerializer::SymbolGraphSerializer ( const APISet API,
const APIIgnoresList IgnoresList,
APISerializerOption  Options = {},
bool  ShouldRecurse = true 

Definition at line 163 of file SymbolGraphSerializer.h.

Member Function Documentation

◆ getRelationshipString()

StringRef SymbolGraphSerializer::getRelationshipString ( RelationshipKind  Kind)

Get the string representation of the relationship kind.

Definition at line 653 of file SymbolGraphSerializer.cpp.

References ConformsTo, InheritsFrom, and MemberOf.

◆ serialize() [1/2]

Object SymbolGraphSerializer::serialize ( )

◆ serialize() [2/2]

void SymbolGraphSerializer::serialize ( raw_ostream &  os)

Implement the APISerializer::serialize interface.

Wrap serialize(void) and write out the serialized JSON object to os.

Implements clang::extractapi::APISerializer.

Definition at line 864 of file SymbolGraphSerializer.cpp.

References clang::extractapi::APISerializerOption::Compact, clang::extractapi::APISerializer::Options, and serialize().

◆ serializeSingleSymbolSGF()

std::optional< Object > SymbolGraphSerializer::serializeSingleSymbolSGF ( StringRef  USR,
const APISet API 

Serialize a single symbol SGF.

This is primarily used for libclang.

an optional JSON Object representing the payload that libclang expects for providing symbol information for a single symbol. If this is not a known symbol returns None.

Definition at line 873 of file SymbolGraphSerializer.cpp.

References clang::extractapi::APISerializer::API, clang::extractapi::APISet::findRecordForUSR(), clang::PresumedLoc::getFilename(), clang::extractapi::APISet::getLanguage(), clang::extractapi::APIRecord::IsFromSystemHeader, clang::extractapi::APIRecord::Location, clang::extractapi::APISet::ProductName, and clang::extractapi::APIRecord::USR.

The documentation for this class was generated from the following files: