clang-tools 10.0.0

Public Types | Public Member Functions | List of all members
clang::clangd::ParsingCallbacks Class Reference

`#include <TUScheduler.h>`

## Public Types
using | PublishFn = llvm::function_ref< void(llvm::function_ref< void()>)>
| The argument function is run under the critical section guarding against races when closing the files. More...

## Public Member Functions
virtual | ~ParsingCallbacks ()=default
virtual void | onPreambleAST (PathRef Path, ASTContext &Ctx, std::shared_ptr< clang::Preprocessor > PP, const CanonicalIncludes &)
| Called on the AST that was built for emitting the preamble. More...
virtual void | onMainAST (PathRef Path, ParsedAST &AST, PublishFn Publish)
| Called on the AST built for the file itself. More...
virtual void | onFailedAST (PathRef Path, std::vector< Diag > Diags, PublishFn Publish)
| Called whenever the AST fails to build. More...
virtual void | onFileUpdated (PathRef File, const TUStatus &Status)
| Called whenever the TU status is updated. More...

## Detailed Description

Definition at line 95 of file TUScheduler.h.

## Member Typedef Documentation

## ◆ PublishFn

using clang::clangd::ParsingCallbacks::PublishFn = llvm::function_ref<void(llvm::function_ref<void()>)>

The argument function is run under the critical section guarding against races when closing the files.

Definition at line 108 of file TUScheduler.h.

## Constructor & Destructor Documentation

## ◆ ~ParsingCallbacks()

virtual clang::clangd::ParsingCallbacks::~ParsingCallbacks | ( |  | ) |
| virtual default

## Member Function Documentation

## ◆ onFailedAST()

virtual void clang::clangd::ParsingCallbacks::onFailedAST | ( | PathRef | Path,
|  | std::vector< Diag > | Diags,
|  | PublishFn | Publish
| ) |  |
| inline virtual

Called whenever the AST fails to build.

`Diags` will have the diagnostics that led to failure.

Definition at line 133 of file TUScheduler.h.

## ◆ onFileUpdated()

virtual void clang::clangd::ParsingCallbacks::onFileUpdated | ( | PathRef | File,
|  | const TUStatus & | Status
| ) |  |
| inline virtual

Called whenever the TU status is updated.

Definition at line 137 of file TUScheduler.h.

## ◆ onMainAST()

virtual void clang::clangd::ParsingCallbacks::onMainAST | ( | PathRef | Path,
|  | ParsedAST & | AST,
|  | PublishFn | Publish
| ) |  |
| inline virtual

Called on the AST built for the file itself.

Note that preamble AST nodes are not deserialized and should be processed in the onPreambleAST call instead. The `AST` always contains all AST nodes for the main file itself, and only a portion of the AST nodes deserialized from the preamble. Note that some nodes from the preamble may have been deserialized and may also be accessed from the main file AST, e.g. redecls of functions from preamble, etc. Clients are expected to process only the AST nodes from the main file in this callback (obtained via ParsedAST::getLocalTopLevelDecls) to obtain optimal performance.

When information about the file (diagnostics, syntax highlighting) is published to clients, this should be wrapped in Publish, e.g. void onMainAST(...) { Highlights = computeHighlights(); Publish([&] { notifyHighlights(Path, Highlights); }); } This guarantees that clients will see results in the correct sequence if the file is concurrently closed and/or reopened. (The lambda passed to Publish() may never run in this case).

Definition at line 129 of file TUScheduler.h.

## ◆ onPreambleAST()

virtual void clang::clangd::ParsingCallbacks::onPreambleAST | ( | PathRef | Path,
|  | ASTContext & | Ctx,
|  | std::shared_ptr< clang::Preprocessor > | PP,
|  | const CanonicalIncludes & |
| ) |  |
| inline virtual

Called on the AST that was built for emitting the preamble.

The built AST contains only AST nodes from the #include directives at the start of the file. AST node in the current file should be observed on onMainAST call.

Definition at line 102 of file TUScheduler.h.

The documentation for this class was generated from the following file:

- TUScheduler.h