• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 ASTNode dumpAST(const DynTypedNode &, const syntax::TokenBuffer &Tokens,
43                 const ASTContext &);
44 
45 } // namespace clangd
46 } // namespace clang
47 
48 #endif
49