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

holds the clang::SourceManager and clang::Preprocessor during macro import. More...

Public Member Functions

 ClangHelpers (OOModel::Project *rootProject, QString rootProjectPath)
 
QList< QString > argumentNames (const clang::MacroDirective *definition) const
 
void associateNodeWithPresumedFileLocation (Model::Node *node, clang::SourceLocation location)
 associate node with the presumed filename at location. More...
 
void associateNodeWithPresumedFileLocation (Model::Node *node, Model::Node *from)
 use the stored filename information of from and copy it to be the filename information of node. More...
 
void attachDeclarationComments (clang::NamedDecl *namedDecl, Model::Node *receiver) const
 
QList< Comment * > & comments ()
 
template<typename NodeType , typename ... ConstructorArgTypes>
NodeType * createNamedNode (clang::NamedDecl *namedDecl, ConstructorArgTypes &&... constructorArgs)
 
template<typename NodeType , typename ... ConstructorArgTypes>
NodeType * createNode (clang::SourceRange sourceRange, ConstructorArgTypes &&... constructorArgs)
 
OOModel::ReferenceExpressioncreateReference (clang::SourceRange sourceRange)
 
void deleteNode (Model::Node *node)
 
EnvisionToClangMapenvisionToClangMap ()
 
void exportMergeMapToJson (QString filename)
 export the node to filename map to a file. More...
 
clang::SourceRange getUnexpandedRange (clang::SourceRange sourceRange) const
 given a source range calculates the source range corresponding to the code expanded there. More...
 
clang::SourceLocation immediateMacroLocation (clang::SourceLocation location) const
 
void immediateSpellingHistory (clang::SourceLocation location, QList< clang::SourceLocation > &result) const
 
void insertDeclarationInFolder (OOModel::Declaration *declaration, clang::SourceLocation location, OOModel::Declaration *parentNonFolderDeclaration)
 
bool isMacroRange (clang::SourceRange range) const
 
const clang::Preprocessor * preprocessor () const
 
QString presumedFilenameWithExtension (clang::SourceLocation location) const
 
QString presumedFilenameWithoutExtension (clang::SourceLocation location) const
 
void printMacroDefinitionForDebug (const clang::MacroDirective *macroDirective) const
 
OOModel::ProjectprojectByName (const QString &name)
 
OOModel::ProjectprojectForLocation (clang::SourceLocation location)
 
QString projectNameFromPath (QString path)
 
OOModel::ProjectrootProject ()
 
const QString & rootProjectPath ()
 
void setPreprocessor (const clang::Preprocessor *preprocessor)
 
void setSourceManager (const clang::SourceManager *sourceManager)
 
const clang::SourceManager * sourceManager () const
 
QString spelling (clang::SourceRange sourceRange) const
 
QString unexpandedSpelling (clang::SourceLocation start, clang::SourceLocation end) const
 
QString unexpandedSpelling (clang::SourceRange range) const
 

Private Member Functions

OOModel::DeclarationfolderForLocation (clang::SourceLocation location, OOModel::Declaration *parentNonFolderDeclaration)
 
QStringList folderNamesFromPath (QString path)
 

Static Private Member Functions

static QString jsonEscape (QString string)
 

Private Attributes

QList< Comment * > comments_
 
EnvisionToClangMap envisionToClangMap_
 
QHash< Model::Node *, QString > nodeToFilenameMap_
 used for exporting an automatically generated merge map More...
 
const clang::Preprocessor * preprocessor_ {}
 
QHash< QString, OOModel::Project * > projects_
 
OOModel::ProjectrootProject_ {}
 
QString rootProjectPath_ {}
 
const clang::SourceManager * sourceManager_ {}
 

Detailed Description

holds the clang::SourceManager and clang::Preprocessor during macro import.

it provides helper methods that only depend on the SourceManager and Preprocessor.

Constructor & Destructor Documentation

◆ ClangHelpers()

CppImport::ClangHelpers::ClangHelpers ( OOModel::Project rootProject,
QString  rootProjectPath 
)

Member Function Documentation

◆ argumentNames()

QList< QString > CppImport::ClangHelpers::argumentNames ( const clang::MacroDirective *  definition) const

◆ associateNodeWithPresumedFileLocation() [1/2]

void CppImport::ClangHelpers::associateNodeWithPresumedFileLocation ( Model::Node node,
clang::SourceLocation  location 
)

associate node with the presumed filename at location.

used to automatically generate a merge map.

◆ associateNodeWithPresumedFileLocation() [2/2]

void CppImport::ClangHelpers::associateNodeWithPresumedFileLocation ( Model::Node node,
Model::Node from 
)

use the stored filename information of from and copy it to be the filename information of node.

used to automatically generate a merge map.

◆ attachDeclarationComments()

void CppImport::ClangHelpers::attachDeclarationComments ( clang::NamedDecl *  namedDecl,
Model::Node receiver 
) const

◆ comments()

QList< Comment * > & CppImport::ClangHelpers::comments ( )
inline

◆ createNamedNode()

template<typename NodeType , typename ... ConstructorArgTypes>
NodeType * CppImport::ClangHelpers::createNamedNode ( clang::NamedDecl *  namedDecl,
ConstructorArgTypes &&...  constructorArgs 
)
inline

◆ createNode()

template<typename NodeType , typename ... ConstructorArgTypes>
NodeType * CppImport::ClangHelpers::createNode ( clang::SourceRange  sourceRange,
ConstructorArgTypes &&...  constructorArgs 
)

◆ createReference()

OOModel::ReferenceExpression * CppImport::ClangHelpers::createReference ( clang::SourceRange  sourceRange)
inline

◆ deleteNode()

void CppImport::ClangHelpers::deleteNode ( Model::Node node)

◆ envisionToClangMap()

EnvisionToClangMap & CppImport::ClangHelpers::envisionToClangMap ( )
inline

◆ exportMergeMapToJson()

void CppImport::ClangHelpers::exportMergeMapToJson ( QString  filename)

export the node to filename map to a file.

◆ folderForLocation()

OOModel::Declaration * CppImport::ClangHelpers::folderForLocation ( clang::SourceLocation  location,
OOModel::Declaration parentNonFolderDeclaration 
)
private

◆ folderNamesFromPath()

QStringList CppImport::ClangHelpers::folderNamesFromPath ( QString  path)
private

◆ getUnexpandedRange()

clang::SourceRange CppImport::ClangHelpers::getUnexpandedRange ( clang::SourceRange  sourceRange) const

given a source range calculates the source range corresponding to the code expanded there.

Example: Macro argument:

                start|        |end
                      1+2 == 3
                     |        |
                     |         \
                      Condition
            out_start|         |out_end

Example: Concatenated tokens:

               start|          |end    (start != end)
                     Door::open
                    /          \
                   /            \
                   Do##or::##open
                  |out_start     |out_end

                 start||end            (start == end)
                       Door
                      /\___
                     |     \
                      Do##or
            out_start|     |out_end

◆ immediateMacroLocation()

clang::SourceLocation CppImport::ClangHelpers::immediateMacroLocation ( clang::SourceLocation  location) const

◆ immediateSpellingHistory()

void CppImport::ClangHelpers::immediateSpellingHistory ( clang::SourceLocation  location,
QList< clang::SourceLocation > &  result 
) const

◆ insertDeclarationInFolder()

void CppImport::ClangHelpers::insertDeclarationInFolder ( OOModel::Declaration declaration,
clang::SourceLocation  location,
OOModel::Declaration parentNonFolderDeclaration 
)

◆ isMacroRange()

bool CppImport::ClangHelpers::isMacroRange ( clang::SourceRange  range) const
inline

◆ jsonEscape()

QString CppImport::ClangHelpers::jsonEscape ( QString  string)
staticprivate

◆ preprocessor()

const clang::Preprocessor * CppImport::ClangHelpers::preprocessor ( ) const
inline

◆ presumedFilenameWithExtension()

QString CppImport::ClangHelpers::presumedFilenameWithExtension ( clang::SourceLocation  location) const

◆ presumedFilenameWithoutExtension()

QString CppImport::ClangHelpers::presumedFilenameWithoutExtension ( clang::SourceLocation  location) const

◆ printMacroDefinitionForDebug()

void CppImport::ClangHelpers::printMacroDefinitionForDebug ( const clang::MacroDirective *  macroDirective) const

◆ projectByName()

OOModel::Project * CppImport::ClangHelpers::projectByName ( const QString &  name)
inline

◆ projectForLocation()

OOModel::Project * CppImport::ClangHelpers::projectForLocation ( clang::SourceLocation  location)

◆ projectNameFromPath()

QString CppImport::ClangHelpers::projectNameFromPath ( QString  path)

◆ rootProject()

OOModel::Project * CppImport::ClangHelpers::rootProject ( )
inline

◆ rootProjectPath()

const QString & CppImport::ClangHelpers::rootProjectPath ( )
inline

◆ setPreprocessor()

void CppImport::ClangHelpers::setPreprocessor ( const clang::Preprocessor *  preprocessor)
inline

◆ setSourceManager()

void CppImport::ClangHelpers::setSourceManager ( const clang::SourceManager *  sourceManager)
inline

◆ sourceManager()

const clang::SourceManager * CppImport::ClangHelpers::sourceManager ( ) const
inline

◆ spelling()

QString CppImport::ClangHelpers::spelling ( clang::SourceRange  sourceRange) const

◆ unexpandedSpelling() [1/2]

QString CppImport::ClangHelpers::unexpandedSpelling ( clang::SourceLocation  start,
clang::SourceLocation  end 
) const
inline

◆ unexpandedSpelling() [2/2]

QString CppImport::ClangHelpers::unexpandedSpelling ( clang::SourceRange  range) const

Member Data Documentation

◆ comments_

QList<Comment*> CppImport::ClangHelpers::comments_
private

◆ envisionToClangMap_

EnvisionToClangMap CppImport::ClangHelpers::envisionToClangMap_
private

◆ nodeToFilenameMap_

QHash<Model::Node*, QString> CppImport::ClangHelpers::nodeToFilenameMap_
private

used for exporting an automatically generated merge map

◆ preprocessor_

const clang::Preprocessor* CppImport::ClangHelpers::preprocessor_ {}
private

◆ projects_

QHash<QString, OOModel::Project*> CppImport::ClangHelpers::projects_
private

◆ rootProject_

OOModel::Project* CppImport::ClangHelpers::rootProject_ {}
private

◆ rootProjectPath_

QString CppImport::ClangHelpers::rootProjectPath_ {}
private

◆ sourceManager_

const clang::SourceManager* CppImport::ClangHelpers::sourceManager_ {}
private