ACAV f0ba4b7c9529
Abstract Syntax Tree (AST) visualization tool for C, C++, and Objective-C
Loading...
Searching...
No Matches
acav::AstExtractorRunner Class Reference

Qt runner that loads AST from cache and builds ACAV tree. More...

#include <AstExtractorRunner.h>

Inheritance diagram for acav::AstExtractorRunner:
[legend]

Public Types

using AstLoader
 Function type for loading AST from file.

Signals

void started (const QString &astFilePath)
void progress (const QString &message)
void statsUpdated (const AstExtractionStats &stats)
void finished (AstViewNode *root)
void error (const QString &message)
void logMessage (const LogEntry &entry)

Public Member Functions

 AstExtractorRunner (AstContext *context, FileManager &fileManager, QObject *parent=nullptr)
 Construct runner with default AST loader.
 AstExtractorRunner (AstContext *context, FileManager &fileManager, AstLoader loader, QObject *parent=nullptr)
 Construct runner with custom AST loader (for testing).
 AstExtractorRunner (const AstExtractorRunner &)=delete
AstExtractorRunneroperator= (const AstExtractorRunner &)=delete
 AstExtractorRunner (AstExtractorRunner &&)=delete
AstExtractorRunneroperator= (AstExtractorRunner &&)=delete
void run (const QString &astFilePath, const QStringList &tuFilePaths, const QString &compilationDbPath=QString())
 Run extraction pipeline and emit lifecycle signals.
void setCommentExtractionEnabled (bool enabled)
 Enable or disable comment extraction in AST.
bool commentExtractionEnabled () const

Detailed Description

Qt runner that loads AST from cache and builds ACAV tree.

This class handles the complete AST extraction pipeline:

  1. Registers input files with FileManager
  2. Loads Clang ASTUnit from serialized .ast file
  3. Builds ACAV AST tree by traversing Clang AST
  4. Emits Qt signals for lifecycle events and progress

Design: This runner executes synchronously (blocking). For async execution, move it to a QThread and use Qt's signal/slot mechanism.

Testing: Inject a custom AstLoader via constructor to mock AST loading.

Definition at line 80 of file AstExtractorRunner.h.

Member Typedef Documentation

◆ AstLoader

Initial value:
std::function<std::unique_ptr<clang::ASTUnit>(
const std::string &astFilePath, std::string &errorOut,
const std::string &compilationDbPath, const std::string &sourcePath)>

Function type for loading AST from file.

Parameters
astFilePathPath to .ast file
errorOutOutput parameter for error message
compilationDbPathPath to compile_commands.json for module resolution
sourcePathSource file path for module mapping extraction
Returns
Loaded ASTUnit or nullptr on failure

Definition at line 91 of file AstExtractorRunner.h.

Constructor & Destructor Documentation

◆ AstExtractorRunner() [1/2]

acav::AstExtractorRunner::AstExtractorRunner ( AstContext * context,
FileManager & fileManager,
QObject * parent = nullptr )
explicit

Construct runner with default AST loader.

Definition at line 41 of file AstExtractorRunner.cpp.

◆ AstExtractorRunner() [2/2]

acav::AstExtractorRunner::AstExtractorRunner ( AstContext * context,
FileManager & fileManager,
AstLoader loader,
QObject * parent = nullptr )
explicit

Construct runner with custom AST loader (for testing).

Definition at line 91 of file AstExtractorRunner.cpp.

Member Function Documentation

◆ commentExtractionEnabled()

bool acav::AstExtractorRunner::commentExtractionEnabled ( ) const
inline

Definition at line 128 of file AstExtractorRunner.h.

◆ run()

void acav::AstExtractorRunner::run ( const QString & astFilePath,
const QStringList & tuFilePaths,
const QString & compilationDbPath = QString() )

Run extraction pipeline and emit lifecycle signals.

This method is synchronous and will block until extraction completes. For async execution, move this runner to a QThread.

Parameters
astFilePathPath to serialized .ast file
tuFilePathsPaths to register with FileManager
compilationDbPathPath to compilation database (used to determine working directory for loading AST with C++20 module support)

Signals emitted: started -> progress* -> (finished | error)

Definition at line 103 of file AstExtractorRunner.cpp.

References acav::MemoryProfiler::checkpoint(), and acav::SourceLocation::resetCache().

◆ setCommentExtractionEnabled()

void acav::AstExtractorRunner::setCommentExtractionEnabled ( bool enabled)

Enable or disable comment extraction in AST.

Definition at line 99 of file AstExtractorRunner.cpp.


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