Envision
A visual programming IDE for object-oriented languages
|
This is the core visitor of the CppImport plugin it translates declarations and statements from clang's AST to Envision's AST. More...
Public Member Functions | |
ClangAstVisitor (OOModel::Project *project, const QString &projectPath, CppImportLogger *logger) | |
~ClangAstVisitor () | |
void | beforeTranslationUnit (clang::ASTContext &astContext) |
void | endEntireImport () |
void | endTranslationUnit () |
Model::Node * | ooStackTop () |
Model::Node * | popOOStack () |
void | pushOOStack (Model::Node *node) |
void | setSourceManagerAndPreprocessor (const clang::SourceManager *sourceManager, const clang::Preprocessor *preprocessor) |
bool | shouldUseDataRecursionfor (clang::Stmt *S) |
A helper function called by RecursiveASTVisitor parent class. More... | |
bool | TraverseBreakStmt (clang::BreakStmt *breakStmt) |
bool | TraverseCaseStmt (clang::CaseStmt *caseStmt) |
bool | TraverseClassTemplateDecl (clang::ClassTemplateDecl *classTemplate) |
bool | TraverseClassTemplateSpecializationDecl (clang::ClassTemplateSpecializationDecl *specializationDecl) |
bool | TraverseCompoundStmt (clang::CompoundStmt *compoundStmt) |
bool | TraverseContinueStmt (clang::ContinueStmt *continueStmt) |
bool | TraverseCXXCatchStmt (clang::CXXCatchStmt *catchStmt) |
bool | TraverseCXXConstructorDecl (clang::CXXConstructorDecl *constructorDecl) |
bool | TraverseCXXConversionDecl (clang::CXXConversionDecl *conversionDecl) |
bool | TraverseCXXDestructorDecl (clang::CXXDestructorDecl *destructorDecl) |
bool | TraverseCXXForRangeStmt (clang::CXXForRangeStmt *forRangeStmt) |
bool | TraverseCXXMethodDecl (clang::CXXMethodDecl *methodDecl) |
bool | TraverseCXXRecordDecl (clang::CXXRecordDecl *recordDecl) |
bool | TraverseCXXTryStmt (clang::CXXTryStmt *tryStmt) |
bool | TraverseDecl (clang::Decl *decl) |
bool | TraverseDeclStmt (clang::DeclStmt *declStmt) |
bool | TraverseDefaultStmt (clang::DefaultStmt *defaultStmt) |
bool | TraverseDoStmt (clang::DoStmt *doStmt) |
bool | TraverseEnumDecl (clang::EnumDecl *enumDecl) |
bool | TraverseFieldDecl (clang::FieldDecl *fieldDecl) |
bool | TraverseForStmt (clang::ForStmt *forStmt) |
bool | TraverseFunctionDecl (clang::FunctionDecl *functionDecl) |
bool | TraverseFunctionTemplateDecl (clang::FunctionTemplateDecl *functionDecl) |
bool | TraverseIfStmt (clang::IfStmt *ifStmt) |
bool | TraverseNamespaceAliasDecl (clang::NamespaceAliasDecl *namespaceAlias) |
bool | TraverseNamespaceDecl (clang::NamespaceDecl *namespaceDecl) |
bool | TraverseReturnStmt (clang::ReturnStmt *returnStmt) |
bool | TraverseStaticAssertDecl (clang::StaticAssertDecl *staticAssertDecl) |
bool | TraverseStmt (clang::Stmt *S) |
Traverses the stmt S and if it is an expression dispatches to the expression visitor. More... | |
bool | TraverseSwitchStmt (clang::SwitchStmt *switchStmt) |
bool | TraverseTypeAliasTemplateDecl (clang::TypeAliasTemplateDecl *typeAliasTemplate) |
bool | TraverseUnresolvedUsingValueDecl (clang::UnresolvedUsingValueDecl *unresolvedUsing) |
bool | TraverseUsingDecl (clang::UsingDecl *usingDecl) |
bool | TraverseUsingDirectiveDecl (clang::UsingDirectiveDecl *usingDirectiveDecl) |
bool | TraverseVarDecl (clang::VarDecl *varDecl) |
bool | TraverseWhileStmt (clang::WhileStmt *whileStmt) |
bool | VisitDecl (clang::Decl *decl) |
bool | VisitStmt (clang::Stmt *S) |
bool | WalkUpFromTypedefNameDecl (clang::TypedefNameDecl *typedefDecl) |
Private Types | |
using | Base = clang::RecursiveASTVisitor< ClangAstVisitor > |
Private Member Functions | |
void | addFunctionModifiers (clang::FunctionDecl *functionDecl, OOModel::Method *method) |
void | insertFriendClass (clang::FriendDecl *friendDecl, OOModel::Class *ooClass) |
Inserts a friend class with the typeInfo in ooClass. More... | |
void | insertFriendFunction (clang::FriendDecl *friendDecl, OOModel::Class *ooClass) |
Inserts the friend function friendFunction in ooClass. More... | |
void | insertUsingDirectiveDeclarations () |
bool | shouldImport (const clang::SourceLocation &location) |
Returns if it is intended to import the code at the location. More... | |
void | TraverseClass (clang::CXXRecordDecl *recordDecl, OOModel::Class *ooClass) |
Insert the class in the tree and will visit the body and insert base classes. More... | |
void | TraverseFunction (clang::FunctionDecl *functionDecl, OOModel::Method *ooFunction) |
Abstract function to handle common parts between FunctionDecl and its subclasses. More... | |
bool | TraverseMethodDecl (clang::CXXMethodDecl *methodDecl, OOModel::Method::MethodKind kind) |
Abstract function to handle normal member functions, constructors, destructors and conversion functions. More... | |
Private Attributes | |
ClangHelpers | clang_ |
const QString | className_ {"ClangAstVisitor"} |
CommentParser * | commentParser_ {} |
ExpressionVisitor * | exprVisitor_ {} |
bool | importSysHeader_ {false} |
bool | inBody_ {true} |
CppImportLogger * | log_ {} |
MacroImporter | macroImporter_ |
QStack< OOModel::Expression * > | ooExprStack_ |
QStack< Model::Node * > | ooStack_ |
TemplateArgumentVisitor * | templArgVisitor_ {} |
TranslateManager * | trMngr_ {} |
QList< clang::UsingDirectiveDecl * > | usingDirectiveDeclarations_ |
CppImportUtilities * | utils_ {} |
This is the core visitor of the CppImport plugin it translates declarations and statements from clang's AST to Envision's AST.
One can specify to also import system headers with the importSysHeader_ variable.
|
private |
CppImport::ClangAstVisitor::ClangAstVisitor | ( | OOModel::Project * | project, |
const QString & | projectPath, | ||
CppImportLogger * | logger | ||
) |
CppImport::ClangAstVisitor::~ClangAstVisitor | ( | ) |
|
private |
void CppImport::ClangAstVisitor::beforeTranslationUnit | ( | clang::ASTContext & | astContext | ) |
void CppImport::ClangAstVisitor::endEntireImport | ( | ) |
void CppImport::ClangAstVisitor::endTranslationUnit | ( | ) |
|
private |
Inserts a friend class with the typeInfo in ooClass.
|
private |
Inserts the friend function friendFunction in ooClass.
|
private |
Model::Node * CppImport::ClangAstVisitor::ooStackTop | ( | ) |
Model::Node * CppImport::ClangAstVisitor::popOOStack | ( | ) |
void CppImport::ClangAstVisitor::pushOOStack | ( | Model::Node * | node | ) |
void CppImport::ClangAstVisitor::setSourceManagerAndPreprocessor | ( | const clang::SourceManager * | sourceManager, |
const clang::Preprocessor * | preprocessor | ||
) |
|
private |
Returns if it is intended to import the code at the location.
The decision is based on wheter the location is valid and on the value of importSysHeader_
bool CppImport::ClangAstVisitor::shouldUseDataRecursionfor | ( | clang::Stmt * | S | ) |
A helper function called by RecursiveASTVisitor parent class.
In our case this function should return false because we use a custom traversal strategy.
bool CppImport::ClangAstVisitor::TraverseBreakStmt | ( | clang::BreakStmt * | breakStmt | ) |
bool CppImport::ClangAstVisitor::TraverseCaseStmt | ( | clang::CaseStmt * | caseStmt | ) |
|
private |
Insert the class in the tree and will visit the body and insert base classes.
It does not visit type arguments they should be handled on the caller site.
bool CppImport::ClangAstVisitor::TraverseClassTemplateDecl | ( | clang::ClassTemplateDecl * | classTemplate | ) |
bool CppImport::ClangAstVisitor::TraverseClassTemplateSpecializationDecl | ( | clang::ClassTemplateSpecializationDecl * | specializationDecl | ) |
bool CppImport::ClangAstVisitor::TraverseCompoundStmt | ( | clang::CompoundStmt * | compoundStmt | ) |
bool CppImport::ClangAstVisitor::TraverseContinueStmt | ( | clang::ContinueStmt * | continueStmt | ) |
bool CppImport::ClangAstVisitor::TraverseCXXCatchStmt | ( | clang::CXXCatchStmt * | catchStmt | ) |
|
inline |
|
inline |
|
inline |
bool CppImport::ClangAstVisitor::TraverseCXXForRangeStmt | ( | clang::CXXForRangeStmt * | forRangeStmt | ) |
|
inline |
bool CppImport::ClangAstVisitor::TraverseCXXRecordDecl | ( | clang::CXXRecordDecl * | recordDecl | ) |
bool CppImport::ClangAstVisitor::TraverseCXXTryStmt | ( | clang::CXXTryStmt * | tryStmt | ) |
bool CppImport::ClangAstVisitor::TraverseDecl | ( | clang::Decl * | decl | ) |
bool CppImport::ClangAstVisitor::TraverseDeclStmt | ( | clang::DeclStmt * | declStmt | ) |
bool CppImport::ClangAstVisitor::TraverseDefaultStmt | ( | clang::DefaultStmt * | defaultStmt | ) |
bool CppImport::ClangAstVisitor::TraverseDoStmt | ( | clang::DoStmt * | doStmt | ) |
bool CppImport::ClangAstVisitor::TraverseEnumDecl | ( | clang::EnumDecl * | enumDecl | ) |
bool CppImport::ClangAstVisitor::TraverseFieldDecl | ( | clang::FieldDecl * | fieldDecl | ) |
bool CppImport::ClangAstVisitor::TraverseForStmt | ( | clang::ForStmt * | forStmt | ) |
|
private |
Abstract function to handle common parts between FunctionDecl and its subclasses.
This includes traversing the body.
bool CppImport::ClangAstVisitor::TraverseFunctionDecl | ( | clang::FunctionDecl * | functionDecl | ) |
bool CppImport::ClangAstVisitor::TraverseFunctionTemplateDecl | ( | clang::FunctionTemplateDecl * | functionDecl | ) |
bool CppImport::ClangAstVisitor::TraverseIfStmt | ( | clang::IfStmt * | ifStmt | ) |
|
private |
Abstract function to handle normal member functions, constructors, destructors and conversion functions.
This method will translate the complete method if methodDecl is a definition
bool CppImport::ClangAstVisitor::TraverseNamespaceAliasDecl | ( | clang::NamespaceAliasDecl * | namespaceAlias | ) |
bool CppImport::ClangAstVisitor::TraverseNamespaceDecl | ( | clang::NamespaceDecl * | namespaceDecl | ) |
bool CppImport::ClangAstVisitor::TraverseReturnStmt | ( | clang::ReturnStmt * | returnStmt | ) |
bool CppImport::ClangAstVisitor::TraverseStaticAssertDecl | ( | clang::StaticAssertDecl * | staticAssertDecl | ) |
bool CppImport::ClangAstVisitor::TraverseStmt | ( | clang::Stmt * | S | ) |
Traverses the stmt S and if it is an expression dispatches to the expression visitor.
bool CppImport::ClangAstVisitor::TraverseSwitchStmt | ( | clang::SwitchStmt * | switchStmt | ) |
bool CppImport::ClangAstVisitor::TraverseTypeAliasTemplateDecl | ( | clang::TypeAliasTemplateDecl * | typeAliasTemplate | ) |
bool CppImport::ClangAstVisitor::TraverseUnresolvedUsingValueDecl | ( | clang::UnresolvedUsingValueDecl * | unresolvedUsing | ) |
bool CppImport::ClangAstVisitor::TraverseUsingDecl | ( | clang::UsingDecl * | usingDecl | ) |
bool CppImport::ClangAstVisitor::TraverseUsingDirectiveDecl | ( | clang::UsingDirectiveDecl * | usingDirectiveDecl | ) |
bool CppImport::ClangAstVisitor::TraverseVarDecl | ( | clang::VarDecl * | varDecl | ) |
bool CppImport::ClangAstVisitor::TraverseWhileStmt | ( | clang::WhileStmt * | whileStmt | ) |
bool CppImport::ClangAstVisitor::VisitDecl | ( | clang::Decl * | decl | ) |
bool CppImport::ClangAstVisitor::VisitStmt | ( | clang::Stmt * | S | ) |
bool CppImport::ClangAstVisitor::WalkUpFromTypedefNameDecl | ( | clang::TypedefNameDecl * | typedefDecl | ) |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |