[SymbolGraphGen] allow SourceKit to print declarations for private stdlib symbols (#64556)

Resolves rdar://103112656
Resolves #62457
This commit is contained in:
QuietMisdreavus
2023-03-28 10:30:36 -06:00
committed by GitHub
parent d707dc4d81
commit d9c8dca5d1
4 changed files with 57 additions and 2 deletions

View File

@@ -57,6 +57,12 @@ struct SymbolGraphOptions {
/// along with "extensionTo" relationships instead of directly associating
/// members and conformances with the extended nominal.
bool EmitExtensionBlockSymbols = false;
/// Whether to print information for private symbols in the standard library.
/// This should be left as `false` when printing a full-module symbol graph,
/// but SourceKit should be able to load the information when pulling symbol
/// information for individual queries.
bool PrintPrivateStdlibSymbols = false;
};
} // end namespace symbolgraphgen

View File

@@ -63,8 +63,8 @@ PrintOptions SymbolGraph::getDeclarationFragmentsPrintOptions() const {
Opts.PrintFunctionRepresentationAttrs =
PrintOptions::FunctionRepresentationMode::None;
Opts.PrintUserInaccessibleAttrs = false;
Opts.SkipPrivateStdlibDecls = true;
Opts.SkipUnderscoredStdlibProtocols = true;
Opts.SkipPrivateStdlibDecls = !Walker.Options.PrintPrivateStdlibSymbols;
Opts.SkipUnderscoredStdlibProtocols = !Walker.Options.PrintPrivateStdlibSymbols;
Opts.PrintGenericRequirements = true;
Opts.PrintInherited = false;
Opts.ExplodeEnumCaseDecls = true;

View File

@@ -0,0 +1,48 @@
struct AnyError: Swift.Error {
let error: Swift.Error
}
func test(lhs: AnyError) {
// RUN: %sourcekitd-test -req=cursor -req-opts=retrieve_symbol_graph=1 -pos=%(line + 1):13 %s -- %s | %FileCheck %s
lhs.error._code
}
// CHECK: SYMBOL GRAPH BEGIN
// CHECK: "declarationFragments": [
// CHECK-NEXT: {
// CHECK-NEXT: "kind": "keyword",
// CHECK-NEXT: "spelling": "var"
// CHECK-NEXT: },
// CHECK-NEXT: {
// CHECK-NEXT: "kind": "text",
// CHECK-NEXT: "spelling": " "
// CHECK-NEXT: },
// CHECK-NEXT: {
// CHECK-NEXT: "kind": "identifier",
// CHECK-NEXT: "spelling": "_code"
// CHECK-NEXT: },
// CHECK-NEXT: {
// CHECK-NEXT: "kind": "text",
// CHECK-NEXT: "spelling": ": "
// CHECK-NEXT: },
// CHECK-NEXT: {
// CHECK-NEXT: "kind": "typeIdentifier",
// CHECK-NEXT: "preciseIdentifier": "s:Si",
// CHECK-NEXT: "spelling": "Int"
// CHECK-NEXT: },
// CHECK-NEXT: {
// CHECK-NEXT: "kind": "text",
// CHECK-NEXT: "spelling": " { "
// CHECK-NEXT: },
// CHECK-NEXT: {
// CHECK-NEXT: "kind": "keyword",
// CHECK-NEXT: "spelling": "get"
// CHECK-NEXT: },
// CHECK-NEXT: {
// CHECK-NEXT: "kind": "text",
// CHECK-NEXT: "spelling": " }"
// CHECK-NEXT: }
// CHECK-NEXT: ]
// CHECK: SYMBOL GRAPH END

View File

@@ -1021,6 +1021,7 @@ fillSymbolInfo(CursorSymbolInfo &Symbol, const DeclInfo &DInfo,
Options.MinimumAccessLevel = AccessLevel::Private;
Options.IncludeSPISymbols = true;
Options.IncludeClangDocs = true;
Options.PrintPrivateStdlibSymbols = true;
symbolgraphgen::printSymbolGraphForDecl(DInfo.VD, DInfo.BaseType,
DInfo.InSynthesizedExtension,