Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions include/swift/AST/ASTDumper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//===--- ASTDumper.h - Swift AST Dumper flags -------------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This file defines types that are used to control the level of detail printed
// by the AST dumper.
//
//===----------------------------------------------------------------------===//

#ifndef SWIFT_AST_AST_DUMPER_H
#define SWIFT_AST_AST_DUMPER_H

namespace swift {

/// Describes the nature of requests that should be kicked off, if any, to
/// compute members and top-level decls when dumping an AST.
enum class ASTDumpMemberLoading {
/// Dump cached members if available; if they are not, do not kick off any
/// parsing or type-checking requests.
None,

/// Dump parsed members, kicking off a parsing request if necessary to compute
/// them, but not performing additional type-checking.
Parsed,

/// Dump all fully-type checked members, kicking off any requests necessary to
/// compute them.
TypeChecked,
};

} // namespace swift

#endif // SWIFT_AST_AST_DUMPER_H
9 changes: 6 additions & 3 deletions include/swift/AST/SourceFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@
#ifndef SWIFT_AST_SOURCEFILE_H
#define SWIFT_AST_SOURCEFILE_H

#include "swift/AST/ASTDumper.h"
#include "swift/AST/ASTNode.h"
#include "swift/AST/FileUnit.h"
#include "swift/AST/IfConfigClauseRangeInfo.h"
#include "swift/AST/Import.h"
#include "swift/AST/SynthesizedFileUnit.h"
#include "swift/Basic/Debug.h"
#include "llvm/ADT/Hashing.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/STLExtras.h"

namespace swift {

Expand Down Expand Up @@ -684,10 +685,12 @@ class SourceFile final : public FileUnit {
}

SWIFT_DEBUG_DUMP;
void dump(raw_ostream &os, bool parseIfNeeded = false) const;
void
dump(raw_ostream &os,
ASTDumpMemberLoading memberLoading = ASTDumpMemberLoading::None) const;

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

/// Pretty-print the contents of this source file.
///
Expand Down
Loading