Skip to content

Commit 134539f

Browse files
authored
Merge pull request swiftlang#79131 from allevato/6.1-json-ast-followups
🍒 [6.1] [ASTDumper] Some followups from the initial JSON PR and macro dumping improvements.
2 parents 7aa8910 + 272a577 commit 134539f

21 files changed

+312
-124
lines changed

include/swift/AST/ASTDumper.h

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//===--- ASTDumper.h - Swift AST Dumper flags -------------------*- C++ -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
//
13+
// This file defines types that are used to control the level of detail printed
14+
// by the AST dumper.
15+
//
16+
//===----------------------------------------------------------------------===//
17+
18+
#ifndef SWIFT_AST_AST_DUMPER_H
19+
#define SWIFT_AST_AST_DUMPER_H
20+
21+
namespace swift {
22+
23+
/// Describes the nature of requests that should be kicked off, if any, to
24+
/// compute members and top-level decls when dumping an AST.
25+
enum class ASTDumpMemberLoading {
26+
/// Dump cached members if available; if they are not, do not kick off any
27+
/// parsing or type-checking requests.
28+
None,
29+
30+
/// Dump parsed members, kicking off a parsing request if necessary to compute
31+
/// them, but not performing additional type-checking.
32+
Parsed,
33+
34+
/// Dump all fully-type checked members, kicking off any requests necessary to
35+
/// compute them.
36+
TypeChecked,
37+
};
38+
39+
} // namespace swift
40+
41+
#endif // SWIFT_AST_AST_DUMPER_H

include/swift/AST/SourceFile.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,17 @@
1313
#ifndef SWIFT_AST_SOURCEFILE_H
1414
#define SWIFT_AST_SOURCEFILE_H
1515

16+
#include "swift/AST/ASTDumper.h"
1617
#include "swift/AST/ASTNode.h"
1718
#include "swift/AST/FileUnit.h"
1819
#include "swift/AST/IfConfigClauseRangeInfo.h"
1920
#include "swift/AST/Import.h"
2021
#include "swift/AST/SynthesizedFileUnit.h"
2122
#include "swift/Basic/Debug.h"
2223
#include "llvm/ADT/Hashing.h"
24+
#include "llvm/ADT/STLExtras.h"
2325
#include "llvm/ADT/SetVector.h"
2426
#include "llvm/ADT/SmallPtrSet.h"
25-
#include "llvm/ADT/STLExtras.h"
2627

2728
namespace swift {
2829

@@ -678,10 +679,12 @@ class SourceFile final : public FileUnit {
678679
}
679680

680681
SWIFT_DEBUG_DUMP;
681-
void dump(raw_ostream &os, bool parseIfNeeded = false) const;
682+
void
683+
dump(raw_ostream &os,
684+
ASTDumpMemberLoading memberLoading = ASTDumpMemberLoading::None) const;
682685

683686
/// Dumps this source file's AST in JSON format to the given output stream.
684-
void dumpJSON(raw_ostream &os) const;
687+
void dumpJSON(raw_ostream &os, ASTDumpMemberLoading memberLoading) const;
685688

686689
/// Pretty-print the contents of this source file.
687690
///

0 commit comments

Comments
 (0)