clang-tools  14.0.0git
ASTSignals.h
Go to the documentation of this file.
1 //===--- ASTSignals.h --------------------------------------------*- 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 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_ASTSIGNALS_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_ASTSIGNALS_H
11 
12 #include "ParsedAST.h"
13 #include "index/SymbolID.h"
14 #include "llvm/ADT/DenseMap.h"
15 #include "llvm/ADT/StringMap.h"
16 
17 namespace clang {
18 namespace clangd {
19 
20 /// Signals derived from a valid AST of a file.
21 /// Provides information that can only be extracted from the AST to actions that
22 /// can't access an AST. The signals are computed and updated asynchronously by
23 /// the ASTWorker and thus they are always stale and also can be absent.
24 /// Example usage: Information about the declarations used in a file affects
25 /// code-completion ranking in that file.
26 struct ASTSignals {
27  /// Number of occurrences of each symbol present in the file.
28  llvm::DenseMap<SymbolID, unsigned> ReferencedSymbols;
29  /// Namespaces whose symbols are used in the file, and the number of such
30  /// distinct symbols.
31  llvm::StringMap<unsigned> RelatedNamespaces;
32 
33  static ASTSignals derive(const ParsedAST &AST);
34 };
35 
36 } // namespace clangd
37 } // namespace clang
38 
39 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_ASTSIGNALS_H
SymbolID.h
clang::clangd::ASTSignals::RelatedNamespaces
llvm::StringMap< unsigned > RelatedNamespaces
Namespaces whose symbols are used in the file, and the number of such distinct symbols.
Definition: ASTSignals.h:31
clang::clangd::ASTSignals
Signals derived from a valid AST of a file.
Definition: ASTSignals.h:26
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ApplyReplacements.h:27
clang::clangd::ParsedAST
Stores and provides access to parsed AST.
Definition: ParsedAST.h:49
clang::clangd::ASTSignals::ReferencedSymbols
llvm::DenseMap< SymbolID, unsigned > ReferencedSymbols
Number of occurrences of each symbol present in the file.
Definition: ASTSignals.h:28
ParsedAST.h
clang::clangd::ASTSignals::derive
static ASTSignals derive(const ParsedAST &AST)
Definition: ASTSignals.cpp:15