clang-tools  14.0.0git
DumpAST.h
Go to the documentation of this file.
1 //===--- DumpAST.h - Serialize clang AST to LSP -----------------*- C++-*--===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 //
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.
13 //
14 // It's also useful to developers who work with the clang AST specifically,
15 // and want to know how certain constructs are represented.
16 //
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
24 // e.g. as a tooltip.
25 //
26 // The textDocument/ast method implemented here is a clangd extension.
27 //
28 //===----------------------------------------------------------------------===//
29 
30 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_DUMPAST_H
31 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_DUMPAST_H
32 
33 #include "Protocol.h"
34 #include "clang/AST/ASTContext.h"
35 
36 namespace clang {
37 namespace syntax {
38 class TokenBuffer;
39 } // namespace syntax
40 namespace clangd {
41 
42 // Note: It's safe for the node to be a TranslationUnitDecl, as this function
43 // does not deserialize the preamble.
44 ASTNode dumpAST(const DynTypedNode &, const syntax::TokenBuffer &Tokens,
45  const ASTContext &);
46 
47 } // namespace clangd
48 } // namespace clang
49 
50 #endif
Protocol.h
clang::clangd::dumpAST
ASTNode dumpAST(const DynTypedNode &N, const syntax::TokenBuffer &Tokens, const ASTContext &Ctx)
Definition: DumpAST.cpp:401
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ApplyReplacements.h:27