| 1 |
#include "CIncludeStatementCollector.h" |
| 2 |
#include "CxxPreProcessor.h" |
| 3 |
#include "CxxScannerTokens.h" |
| 4 |
#include "file_logger.h" |
| 5 |
|
| 6 |
CIncludeStatementCollector::CIncludeStatementCollector(CxxPreProcessor* pp, const wxFileName& filename, |
| 7 |
std::unordered_set<wxString>& visitedFiles) |
| 8 |
: CxxScannerBase(pp, filename) |
| 9 |
, m_visitedFiles(visitedFiles) |
| 10 |
{ |
| 11 |
} |
| 12 |
|
| 13 |
CIncludeStatementCollector::~CIncludeStatementCollector() |
| 14 |
{ |
| 15 |
} |
| 16 |
|
| 17 |
void CIncludeStatementCollector::OnToken(CxxLexerToken& token) |
| 18 |
{ |
| 19 |
// Pre Processor state |
| 20 |
switch(token.GetType()) { |
| 21 |
case T_PP_INCLUDE_FILENAME: { |
| 22 |
// we found an include statement, recurse into it |
| 23 |
wxFileName include; |
| 24 |
if(m_preProcessor->ExpandInclude(m_filename, token.GetWXString(), include)) { |
| 25 |
CIncludeStatementCollector scanner(m_preProcessor, include, m_visitedFiles); |
| 26 |
scanner.Parse(); |
| 27 |
clDEBUG1() << "<== Resuming parser on file:" << m_filename << clEndl; |
| 28 |
} |
| 29 |
break; |
| 30 |
} |
| 31 |
default: |
| 32 |
break; |
| 33 |
} |
| 34 |
} |