data: Added CxxParser, currently only detecting classes
This change adds CxxParser a class for parsing cxx files. It holds basic functionality to detect classes using the clang libTooling classes. CxxParser is derived from a common Parser interface, which can later be used for other language parsers. The Parser forwards detected elements to a ParserClient interface, which is implemented by the Storage class. The detected classes only get logged so far. review id = 6 * bd3c63a - (HEAD, origin/class, class) applied second review <Eberhard Graether> (4 minutes ago) * 3db7d93 - added missing files <Eberhard Graether> (4 days ago) * 6d09f4e - applied review <Eberhard Graether> (4 days ago) * d9d3e64 - fixed CMake files <Eberhard Graether> (4 days ago) * f22a771 - only one Storage class <Eberhard Graether> (4 days ago) * 6ee9553 - added tests <Eberhard Graether> (4 days ago) * 0a525e8 - fixed includes <Eberhard Graether> (4 days ago) * ca3fbb8 - added StorageManager as ParserClient <Eberhard Graether> (4 days ago) * fa185a5 - renamed ParseLocation to ParseObject <Eberhard Graether> (4 days ago) * 8b89808 - pass location with ParseLocation object <Eberhard Graether> (4 days ago) * 548ae3c - renamed clang AST classes <Eberhard Graether> (4 days ago) * d3b2caf - cleaned includes <Eberhard Graether> (4 days ago) * f7fdf33 - removed using namespace stmts <Eberhard Graether> (4 days ago) * 5378ef6 - using ParserClient <Eberhard Graether> (4 days ago) * b9ce2f6 - working with test file <Eberhard Graether> (4 days ago) * 5585abc - added CxxParser and ParserClient <Eberhard Graether> (4 days ago)
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
#include "data/parser/cxx/ASTVisitor.h"
|
||||
|
||||
ASTVisitor::ASTVisitor(clang::ASTContext* context, std::shared_ptr<ParserClient> client)
|
||||
: m_context(context)
|
||||
, m_client(client)
|
||||
{
|
||||
}
|
||||
|
||||
ASTVisitor::~ASTVisitor()
|
||||
{
|
||||
}
|
||||
|
||||
bool ASTVisitor::VisitCXXRecordDecl(clang::CXXRecordDecl *declaration)
|
||||
{
|
||||
clang::FullSourceLoc location = m_context->getFullLoc(declaration->getLocStart());
|
||||
|
||||
if (location.isValid() && m_context->getSourceManager().isWrittenInMainFile(location))
|
||||
{
|
||||
ParseObject parseObject(
|
||||
declaration->getQualifiedNameAsString(),
|
||||
m_context->getSourceManager().getFilename(location),
|
||||
location.getSpellingLineNumber(),
|
||||
location.getSpellingColumnNumber()
|
||||
);
|
||||
|
||||
m_client->addClass(parseObject);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user