Envision
A visual programming IDE for object-oriented languages
List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
CppImport::CppImportManager Class Reference

This is the core manager of the CppImport plugin. More...

Public Member Functions

 ~CppImportManager ()
 
Model::TreeManagercreateTreeManager (const bool statisticsPerProject=false)
 Creates a clang tool and translates the sourcecode to Envision's AST and returns the root Be sure to have set the sourcePath before calling this method Set statisticsPerProject if you want statistics output for each subproject. More...
 
void setImportPaths (QStringList sourcePaths, const bool subProjects=false)
 Use this function to set sourcePath which you want to import. More...
 
void setupTest ()
 Imports code from a test.cpp file in a subdirectory of ENVISION_ROOT/CppImport/test Specify the directory in the testSelector file. More...
 

Static Public Member Functions

static int & processedTranslationUnits ()
 The amount of translation units that were imported so far. More...
 
static int & totalTranslationUnits ()
 The amount of translation units to be imported in total. More...
 

Private Member Functions

void createCompilationDbForTest (const QString &testPath)
 Creates a compile_commands file inside testPath Use this method only for simple test.cpp files. More...
 
clang::tooling::CompilationDatabase * findCompilationDatabase (const QString &path)
 
void initPath (const QString &sourcePath)
 Prepares everything for the project in sourcePath to get imported. More...
 
QString mainProjectPath (const QString &path)
 Calculates the shortest subpath of subProjectPath containing a CMakeLists.txt file. More...
 
void readInFiles (const QString &sourcePath)
 Collects all source files in sourcPath and sub directories and stores them in the sourcesMap_. More...
 
void setCompilationDbPath (const QString &sourcePath)
 Adds the compilation database to compilationDbMap_. More...
 

Private Attributes

clang::tooling::CompilationDatabase * compilationDb_
 
QStringList cppFilter_ = {"*.cpp", "*.cc", "*.cxx"}
 
QString projectPath_
 the path to the main CMakeLists.txt of the project to import. More...
 
QStringList projects_
 
QHash< QString, std::vector< std::string > * > sourcesMap_
 

Detailed Description

This is the core manager of the CppImport plugin.

To import C++ code you have to specify a path to import with the setImportPath method. After having set the source path you can translate the code with the createTreeManager method.

To experiment/test you may want to use the setupTest method.

Constructor & Destructor Documentation

◆ ~CppImportManager()

CppImport::CppImportManager::~CppImportManager ( )

Member Function Documentation

◆ createCompilationDbForTest()

void CppImport::CppImportManager::createCompilationDbForTest ( const QString &  testPath)
private

Creates a compile_commands file inside testPath Use this method only for simple test.cpp files.

◆ createTreeManager()

Model::TreeManager * CppImport::CppImportManager::createTreeManager ( const bool  statisticsPerProject = false)

Creates a clang tool and translates the sourcecode to Envision's AST and returns the root Be sure to have set the sourcePath before calling this method Set statisticsPerProject if you want statistics output for each subproject.

◆ findCompilationDatabase()

clang::tooling::CompilationDatabase * CppImport::CppImportManager::findCompilationDatabase ( const QString &  path)
private

◆ initPath()

void CppImport::CppImportManager::initPath ( const QString &  sourcePath)
private

Prepares everything for the project in sourcePath to get imported.

◆ mainProjectPath()

QString CppImport::CppImportManager::mainProjectPath ( const QString &  path)
private

Calculates the shortest subpath of subProjectPath containing a CMakeLists.txt file.

◆ processedTranslationUnits()

int & CppImport::CppImportManager::processedTranslationUnits ( )
static

The amount of translation units that were imported so far.

Used to display import progress.

◆ readInFiles()

void CppImport::CppImportManager::readInFiles ( const QString &  sourcePath)
private

Collects all source files in sourcPath and sub directories and stores them in the sourcesMap_.

◆ setCompilationDbPath()

void CppImport::CppImportManager::setCompilationDbPath ( const QString &  sourcePath)
private

Adds the compilation database to compilationDbMap_.

◆ setImportPaths()

void CppImport::CppImportManager::setImportPaths ( QStringList  sourcePaths,
const bool  subProjects = false 
)

Use this function to set sourcePath which you want to import.

If the project has subproject please specify this with setting subProject to true All subprojects that contain a compile_commands file will be translated

◆ setupTest()

void CppImport::CppImportManager::setupTest ( )

Imports code from a test.cpp file in a subdirectory of ENVISION_ROOT/CppImport/test Specify the directory in the testSelector file.

For simple tests inside the test directory you do not have to provide a compile_commands file

◆ totalTranslationUnits()

int & CppImport::CppImportManager::totalTranslationUnits ( )
static

The amount of translation units to be imported in total.

Used to display import progress.

Member Data Documentation

◆ compilationDb_

clang::tooling::CompilationDatabase* CppImport::CppImportManager::compilationDb_
private

◆ cppFilter_

QStringList CppImport::CppImportManager::cppFilter_ = {"*.cpp", "*.cc", "*.cxx"}
private

◆ projectPath_

QString CppImport::CppImportManager::projectPath_
private

the path to the main CMakeLists.txt of the project to import.

◆ projects_

QStringList CppImport::CppImportManager::projects_
private

◆ sourcesMap_

QHash<QString, std::vector<std::string>* > CppImport::CppImportManager::sourcesMap_
private