work save
This commit is contained in:
parent
24a22ec264
commit
9f3d50d6a2
|
@ -2,12 +2,53 @@
|
||||||
#include "parserutils.h"
|
#include "parserutils.h"
|
||||||
#include "../utils.h"
|
#include "../utils.h"
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QQueue>
|
#include <QQueue>
|
||||||
|
#include <QThread>
|
||||||
|
|
||||||
|
static QAtomicInt cppParserCount(0);
|
||||||
CppParser::CppParser(QObject *parent) : QObject(parent)
|
CppParser::CppParser(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
|
mParserId = cppParserCount.fetchAndAddRelaxed(1);
|
||||||
|
mSerialCount = 0;
|
||||||
|
updateSerialId();
|
||||||
|
mUniqId = 0;
|
||||||
|
mParsing = false;
|
||||||
|
//mStatementList ; // owns the objects
|
||||||
|
mIncludesList = std::make_shared<QHash<QString,PFileIncludes>>();
|
||||||
|
//mFilesToScan;
|
||||||
|
mScannedFiles = std::make_shared<QSet<QString>>();
|
||||||
|
//mIncludePaths;
|
||||||
|
//mProjectIncludePaths;
|
||||||
|
//mProjectFiles;
|
||||||
|
// mCurrentScope;
|
||||||
|
//mCurrentClassScope;
|
||||||
|
//mSkipList;
|
||||||
|
mParseLocalHeaders = true;
|
||||||
|
mParseGlobalHeaders = true;
|
||||||
|
mLockCount = 0;
|
||||||
|
//mNamespaces;
|
||||||
|
//mBlockBeginSkips;
|
||||||
|
//mBlockEndSkips;
|
||||||
|
//mInlineNamespaceEndSkips;
|
||||||
|
}
|
||||||
|
|
||||||
|
CppParser::~CppParser()
|
||||||
|
{
|
||||||
|
while (true) {
|
||||||
|
//wait for all methods finishes running
|
||||||
|
{
|
||||||
|
QMutexLocker locker(&mMutex);
|
||||||
|
if (!mParsing && (mLockCount == 0)) {
|
||||||
|
mParsing = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QThread::msleep(50);
|
||||||
|
QCoreApplication* app = QApplication::instance();
|
||||||
|
app->processEvents();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppParser::addHardDefineByLine(const QString &line)
|
void CppParser::addHardDefineByLine(const QString &line)
|
||||||
|
@ -22,14 +63,34 @@ void CppParser::addHardDefineByLine(const QString &line)
|
||||||
|
|
||||||
void CppParser::addIncludePath(const QString &value)
|
void CppParser::addIncludePath(const QString &value)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker(&mMutex);
|
||||||
mIncludePaths.insert(value);
|
mIncludePaths.insert(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppParser::addProjectIncludePath(const QString &value)
|
void CppParser::addProjectIncludePath(const QString &value)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker(&mMutex);
|
||||||
mProjectIncludePaths.insert(value);
|
mProjectIncludePaths.insert(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CppParser::clearIncludePaths()
|
||||||
|
{
|
||||||
|
QMutexLocker locker(&mMutex);
|
||||||
|
mIncludePaths.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CppParser::clearProjectIncludePaths()
|
||||||
|
{
|
||||||
|
QMutexLocker locker(&mMutex);
|
||||||
|
mProjectIncludePaths.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CppParser::clearProjectFiles()
|
||||||
|
{
|
||||||
|
QMutexLocker locker(&mMutex);
|
||||||
|
mProjectFiles.clear();
|
||||||
|
}
|
||||||
|
|
||||||
void CppParser::addFileToScan(QString value, bool inProject)
|
void CppParser::addFileToScan(QString value, bool inProject)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&mMutex);
|
QMutexLocker locker(&mMutex);
|
||||||
|
|
|
@ -14,10 +14,17 @@ class CppParser : public QObject
|
||||||
using GetFileStreamCallBack = std::function<bool (const QString&, QStringList&)>;
|
using GetFileStreamCallBack = std::function<bool (const QString&, QStringList&)>;
|
||||||
public:
|
public:
|
||||||
explicit CppParser(QObject *parent = nullptr);
|
explicit CppParser(QObject *parent = nullptr);
|
||||||
|
~CppParser();
|
||||||
|
|
||||||
|
void addHardDefineByLine(const QString& line);
|
||||||
|
void addFileToScan(QString value, bool inProject = false);
|
||||||
|
void addIncludePath(const QString& value);
|
||||||
|
void addProjectIncludePath(const QString& value);
|
||||||
|
void clearIncludePaths();
|
||||||
|
void clearProjectIncludePaths();
|
||||||
|
void clearProjectFiles();
|
||||||
void parseHardDefines();
|
void parseHardDefines();
|
||||||
PFileIncludes findFileIncludes(const QString &filename, bool deleteIt = false);
|
PFileIncludes findFileIncludes(const QString &filename, bool deleteIt = false);
|
||||||
void addHardDefineByLine(const QString& line);
|
|
||||||
void invalidateFile(const QString& fileName);
|
void invalidateFile(const QString& fileName);
|
||||||
QStringList getFileDirectIncludes(const QString& filename) const;
|
QStringList getFileDirectIncludes(const QString& filename) const;
|
||||||
const QList<QString>& getFileIncludes(const QString& filename) const;
|
const QList<QString>& getFileIncludes(const QString& filename) const;
|
||||||
|
@ -43,12 +50,7 @@ public:
|
||||||
QString statementKindStr(StatementKind value);
|
QString statementKindStr(StatementKind value);
|
||||||
QString statementClassScopeStr(StatementClassScope value);
|
QString statementClassScopeStr(StatementClassScope value);
|
||||||
void reset();
|
void reset();
|
||||||
void clearIncludePaths();
|
|
||||||
void clearProjectIncludePaths();
|
|
||||||
void clearProjectFiles();
|
|
||||||
void addIncludePath(const QString& value);
|
|
||||||
void addProjectIncludePath(const QString& value);
|
|
||||||
void addFileToScan(QString value, bool inProject = false);
|
|
||||||
QString prettyPrintStatement(PStatement statement, int line = -1);
|
QString prettyPrintStatement(PStatement statement, int line = -1);
|
||||||
void fillListOfFunctions(const QString& fileName,
|
void fillListOfFunctions(const QString& fileName,
|
||||||
const QString& phrase,
|
const QString& phrase,
|
||||||
|
|
Loading…
Reference in New Issue