clang-tools 20.0.0git
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.
 

Public Member Functions

virtual ~ParsingCallbacks ()=default
 
virtual void onPreambleAST (PathRef Path, llvm::StringRef Version, CapturedASTCtx Ctx, std::shared_ptr< const include_cleaner::PragmaIncludes >)
 Called on the AST that was built for emitting the preamble.
 
virtual void onMainAST (PathRef Path, ParsedAST &AST, PublishFn Publish)
 Called on the AST built for the file itself.
 
virtual void onFailedAST (PathRef Path, llvm::StringRef Version, std::vector< Diag > Diags, PublishFn Publish)
 Called whenever the AST fails to build.
 
virtual void onFileUpdated (PathRef File, const TUStatus &Status)
 Called whenever the TU status is updated.
 
virtual void onPreamblePublished (PathRef File)
 Preamble for the TU have changed.
 

Detailed Description

Definition at line 158 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 170 of file TUScheduler.h.

Constructor & Destructor Documentation

◆ ~ParsingCallbacks()

virtual clang::clangd::ParsingCallbacks::~ParsingCallbacks ( )
virtualdefault

Member Function Documentation

◆ onFailedAST()

virtual void clang::clangd::ParsingCallbacks::onFailedAST ( PathRef  Path,
llvm::StringRef  Version,
std::vector< Diag Diags,
PublishFn  Publish 
)
inlinevirtual

Called whenever the AST fails to build.

Diags will have the diagnostics that led to failure.

Definition at line 195 of file TUScheduler.h.

◆ onFileUpdated()

virtual void clang::clangd::ParsingCallbacks::onFileUpdated ( PathRef  File,
const TUStatus Status 
)
inlinevirtual

Called whenever the TU status is updated.

Definition at line 199 of file TUScheduler.h.

◆ onMainAST()

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

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 (e.g. diagnostics) is published to clients, this should be wrapped in Publish, e.g. void onMainAST(...) { Diags = renderDiagnostics(); Publish([&] { notifyDiagnostics(Path, Diags); }); } 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 191 of file TUScheduler.h.

◆ onPreambleAST()

virtual void clang::clangd::ParsingCallbacks::onPreambleAST ( PathRef  Path,
llvm::StringRef  Version,
CapturedASTCtx  Ctx,
std::shared_ptr< const include_cleaner::PragmaIncludes >   
)
inlinevirtual

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 166 of file TUScheduler.h.

◆ onPreamblePublished()

virtual void clang::clangd::ParsingCallbacks::onPreamblePublished ( PathRef  File)
inlinevirtual

Preamble for the TU have changed.

This might imply new semantics (e.g. different highlightings). Any actions on the file are guranteed to see new preamble after the callback.

Definition at line 204 of file TUScheduler.h.


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