1 //===--- DumpAST.h - Serialize clang AST to LSP -----------------*- C++-*--===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // Exposing clang's AST can give insight into the precise meaning of code.
10 // (C++ is a complicated language, and very few people know all its rules).
11 // Despite the name, clang's AST describes *semantics* and so includes nodes
12 // for implicit behavior like conversions.
14 // It's also useful to developers who work with the clang AST specifically,
15 // and want to know how certain constructs are represented.
17 // The main representation is not based on the familiar -ast-dump output,
18 // which is heavy on internal details.
19 // It also does not use the -ast-dump=json output, which captures the same
20 // detail in a machine-friendly way, but requires client-side logic to present.
21 // Instead, the key information is bundled into a few fields (role/kind/detail)
22 // with weakly-defined semantics, optimized for easy presentation.
23 // The -ast-dump output is preserved in the 'arcana' field, and may be shown
26 // The textDocument/ast method implemented here is a clangd extension.
28 //===----------------------------------------------------------------------===//
30 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_DUMPAST_H
31 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_DUMPAST_H
34 #include "clang/AST/ASTContext.h"
43 // Note: It's safe for the node to be a TranslationUnitDecl, as this function
44 // does not deserialize the preamble.
45 ASTNode
dumpAST(const DynTypedNode
&, const syntax::TokenBuffer
&Tokens
,