optimization: make parser methods inline
This commit is contained in:
parent
262ca6536c
commit
a9295caff2
|
@ -138,11 +138,6 @@ void CppPreprocessor::getDefineParts(const QString &input, QString &name, QStrin
|
||||||
args.squeeze();
|
args.squeeze();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppPreprocessor::addHardDefineByLine(const QString &line)
|
|
||||||
{
|
|
||||||
addDefineByLine(line,true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CppPreprocessor::addDefineByLine(const QString &line, bool hardCoded)
|
void CppPreprocessor::addDefineByLine(const QString &line, bool hardCoded)
|
||||||
{
|
{
|
||||||
// Remove define
|
// Remove define
|
||||||
|
@ -157,22 +152,13 @@ void CppPreprocessor::addDefineByLine(const QString &line, bool hardCoded)
|
||||||
addDefineByParts(name, args, value, hardCoded);
|
addDefineByParts(name, args, value, hardCoded);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppPreprocessor::setScanOptions(bool parseSystem, bool parseLocal)
|
|
||||||
{
|
|
||||||
mParseSystem = parseSystem;
|
|
||||||
mParseLocal=parseLocal;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CppPreprocessor::preprocess(const QString &fileName)
|
void CppPreprocessor::preprocess(const QString &fileName)
|
||||||
{
|
{
|
||||||
clearTempResults();
|
clearTempResults();
|
||||||
mFileName = fileName;
|
mFileName = fileName;
|
||||||
//mDefines = mHardDefines;
|
|
||||||
openInclude(fileName);
|
openInclude(fileName);
|
||||||
// StringsToFile(mBuffer,"f:\\buffer.txt");
|
|
||||||
preprocessBuffer();
|
preprocessBuffer();
|
||||||
// StringsToFile(mBuffer,"f:\\buffer.txt");
|
|
||||||
// StringsToFile(mResult,"f:\\log.txt");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppPreprocessor::invalidDefinesInFile(const QString &fileName)
|
void CppPreprocessor::invalidDefinesInFile(const QString &fileName)
|
||||||
|
@ -265,18 +251,6 @@ void CppPreprocessor::addProjectIncludePath(const QString &fileName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppPreprocessor::clearIncludePaths()
|
|
||||||
{
|
|
||||||
mIncludePaths.clear();
|
|
||||||
mIncludePathList.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CppPreprocessor::clearProjectIncludePaths()
|
|
||||||
{
|
|
||||||
mProjectIncludePaths.clear();
|
|
||||||
mProjectIncludePathList.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CppPreprocessor::removeScannedFile(const QString &filename)
|
void CppPreprocessor::removeScannedFile(const QString &filename)
|
||||||
{
|
{
|
||||||
invalidDefinesInFile(filename);
|
invalidDefinesInFile(filename);
|
||||||
|
@ -1204,71 +1178,6 @@ void CppPreprocessor::skipToPreprocessor()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CppPreprocessor::isWordChar(const QChar &ch)
|
|
||||||
{
|
|
||||||
if (ch=='_'
|
|
||||||
// || (ch>='a' && ch<='z') || (ch>='A' && ch<='Z')
|
|
||||||
|| ch.isLetter()
|
|
||||||
|| (ch>='0' && ch<='9')) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CppPreprocessor::isIdentChar(const QChar &ch)
|
|
||||||
{
|
|
||||||
if (ch=='_' || ch == '*' || ch == '&' || ch == '~' ||
|
|
||||||
ch.isLetter()
|
|
||||||
//(ch>='a' && ch<='z') || (ch>='A' && ch<='Z')
|
|
||||||
|| (ch>='0' && ch<='9')) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CppPreprocessor::isLineChar(const QChar &ch)
|
|
||||||
{
|
|
||||||
return ch=='\r' || ch == '\n';
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CppPreprocessor::isSpaceChar(const QChar &ch)
|
|
||||||
{
|
|
||||||
return ch == ' ' || ch == '\t';
|
|
||||||
}
|
|
||||||
|
|
||||||
//bool CppPreprocessor::isOperatorChar(const QChar &ch)
|
|
||||||
//{
|
|
||||||
|
|
||||||
// switch(ch.unicode()) {
|
|
||||||
// case '+':
|
|
||||||
// case '-':
|
|
||||||
// case '*':
|
|
||||||
// case '/':
|
|
||||||
// case '!':
|
|
||||||
// case '=':
|
|
||||||
// case '<':
|
|
||||||
// case '>':
|
|
||||||
// case '&':
|
|
||||||
// case '|':
|
|
||||||
// case '^':
|
|
||||||
// return true;
|
|
||||||
// default:
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
bool CppPreprocessor::isMacroIdentChar(const QChar &ch)
|
|
||||||
{
|
|
||||||
//return (ch>='A' && ch<='Z') || (ch>='a' && ch<='z')
|
|
||||||
return ch.isLetter()
|
|
||||||
|| ch == '_';
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CppPreprocessor::isDigit(const QChar &ch)
|
|
||||||
{
|
|
||||||
return (ch>='0' && ch<='9');
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CppPreprocessor::isNumberChar(const QChar &ch)
|
bool CppPreprocessor::isNumberChar(const QChar &ch)
|
||||||
{
|
{
|
||||||
if (ch>='0' && ch<='9')
|
if (ch>='0' && ch<='9')
|
||||||
|
@ -1290,11 +1199,6 @@ bool CppPreprocessor::isNumberChar(const QChar &ch)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CppPreprocessor::lineBreak()
|
|
||||||
{
|
|
||||||
return "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CppPreprocessor::evaluateIf(const QString &line)
|
bool CppPreprocessor::evaluateIf(const QString &line)
|
||||||
{
|
{
|
||||||
QString newLine = expandDefines(line); // replace FOO by numerical value of FOO
|
QString newLine = expandDefines(line); // replace FOO by numerical value of FOO
|
||||||
|
@ -1961,22 +1865,4 @@ int CppPreprocessor::evaluateExpression(QString line)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppPreprocessor::setOnGetFileStream(const GetFileStreamCallBack &newOnGetFileStream)
|
|
||||||
{
|
|
||||||
mOnGetFileStream = newOnGetFileStream;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QList<QString> &CppPreprocessor::projectIncludePathList() const
|
|
||||||
{
|
|
||||||
return mProjectIncludePathList;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QList<QString> &CppPreprocessor::includePathList() const
|
|
||||||
{
|
|
||||||
return mIncludePathList;
|
|
||||||
}
|
|
||||||
|
|
||||||
const DefineMap &CppPreprocessor::hardDefines() const
|
|
||||||
{
|
|
||||||
return mHardDefines;
|
|
||||||
}
|
|
||||||
|
|
|
@ -69,16 +69,25 @@ public:
|
||||||
|
|
||||||
void clearTempResults();
|
void clearTempResults();
|
||||||
void getDefineParts(const QString& input, QString &name, QString &args, QString &value);
|
void getDefineParts(const QString& input, QString &name, QString &args, QString &value);
|
||||||
void addHardDefineByLine(const QString& line);
|
void addHardDefineByLine(const QString& line) { addDefineByLine(line,true); }
|
||||||
void setScanOptions(bool parseSystem, bool parseLocal);
|
void setScanOptions(bool parseSystem, bool parseLocal) {
|
||||||
|
mParseSystem = parseSystem;
|
||||||
|
mParseLocal=parseLocal;
|
||||||
|
}
|
||||||
void preprocess(const QString& fileName);
|
void preprocess(const QString& fileName);
|
||||||
|
|
||||||
void dumpDefinesTo(const QString& fileName) const;
|
void dumpDefinesTo(const QString& fileName) const;
|
||||||
void dumpIncludesListTo(const QString& fileName) const;
|
void dumpIncludesListTo(const QString& fileName) const;
|
||||||
void addIncludePath(const QString& fileName);
|
void addIncludePath(const QString& fileName);
|
||||||
void addProjectIncludePath(const QString& fileName);
|
void addProjectIncludePath(const QString& fileName);
|
||||||
void clearIncludePaths();
|
void clearIncludePaths() {
|
||||||
void clearProjectIncludePaths();
|
mIncludePaths.clear();
|
||||||
|
mIncludePathList.clear();
|
||||||
|
}
|
||||||
|
void clearProjectIncludePaths() {
|
||||||
|
mProjectIncludePaths.clear();
|
||||||
|
mProjectIncludePathList.clear();
|
||||||
|
}
|
||||||
void removeScannedFile(const QString& filename);
|
void removeScannedFile(const QString& filename);
|
||||||
|
|
||||||
PDefine getDefine(const QString& name) const{
|
PDefine getDefine(const QString& name) const{
|
||||||
|
@ -116,12 +125,12 @@ public:
|
||||||
return mProjectIncludePaths;
|
return mProjectIncludePaths;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DefineMap &hardDefines() const;
|
const DefineMap &hardDefines() const { return mHardDefines; }
|
||||||
|
|
||||||
const QList<QString> &includePathList() const;
|
const QList<QString> &includePathList() const { return mIncludePathList; }
|
||||||
|
|
||||||
const QList<QString> &projectIncludePathList() const;
|
const QList<QString> &projectIncludePathList() const { return mProjectIncludePathList; }
|
||||||
void setOnGetFileStream(const GetFileStreamCallBack &newOnGetFileStream);
|
void setOnGetFileStream(const GetFileStreamCallBack &newOnGetFileStream) { mOnGetFileStream = newOnGetFileStream; }
|
||||||
|
|
||||||
static QList<PDefineArgToken> tokenizeValue(const QString& value);
|
static QList<PDefineArgToken> tokenizeValue(const QString& value);
|
||||||
|
|
||||||
|
@ -198,40 +207,46 @@ private:
|
||||||
/*
|
/*
|
||||||
* '_','a'..'z','A'..'Z','0'..'9'
|
* '_','a'..'z','A'..'Z','0'..'9'
|
||||||
*/
|
*/
|
||||||
static bool isWordChar(const QChar& ch);
|
static bool isWordChar(const QChar& ch) {
|
||||||
|
return (ch=='_'
|
||||||
|
|| ch.isLetter()
|
||||||
|
|| (ch>='0' && ch<='9'));
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 'A'..'Z', '0'..'9', 'a'..'z', '_', '*', '&', '~'
|
* 'A'..'Z', '0'..'9', 'a'..'z', '_', '*', '&', '~'
|
||||||
*/
|
*/
|
||||||
static bool isIdentChar(const QChar& ch);
|
static bool isIdentChar(const QChar& ch) {
|
||||||
|
return (ch=='_' || ch == '*' || ch == '&' || ch == '~' ||
|
||||||
|
ch.isLetter()
|
||||||
|
|| (ch>='0' && ch<='9'));
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* '\r','\n'
|
* '\r','\n'
|
||||||
*/
|
*/
|
||||||
static bool isLineChar(const QChar& ch);
|
static bool isLineChar(const QChar& ch) { return ch=='\r' || ch == '\n'; }
|
||||||
/*
|
/*
|
||||||
* '\t' ' '
|
* '\t' ' '
|
||||||
*/
|
*/
|
||||||
static bool isSpaceChar(const QChar& ch);
|
static bool isSpaceChar(const QChar& ch) { return ch == ' ' || ch == '\t'; }
|
||||||
/*
|
|
||||||
* '+', '-', '*', '/', '!', '=', '<', '>', '&', '|', '^'
|
|
||||||
*/
|
|
||||||
//static bool isOperatorChar(const QChar& ch);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 'A'..'Z', 'a'..'z', '_'
|
* 'A'..'Z', 'a'..'z', '_'
|
||||||
*/
|
*/
|
||||||
static bool isMacroIdentChar(const QChar& ch);
|
static bool isMacroIdentChar(const QChar& ch) { return ch.isLetter() || ch == '_'; }
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* '0'..'9'
|
* '0'..'9'
|
||||||
*/
|
*/
|
||||||
static bool isDigit(const QChar& ch);
|
static bool isDigit(const QChar& ch) { return (ch>='0' && ch<='9'); }
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* '0'..'9','x',X','a'..'f','A'..'F','u','U','l','L'
|
* '0'..'9','x',X','a'..'f','A'..'F','u','U','l','L'
|
||||||
*/
|
*/
|
||||||
static bool isNumberChar(const QChar& ch);
|
static bool isNumberChar(const QChar& ch);
|
||||||
|
|
||||||
QString lineBreak();
|
QString lineBreak() { return "\n"; }
|
||||||
|
|
||||||
bool evaluateIf(const QString& line);
|
bool evaluateIf(const QString& line);
|
||||||
QString expandDefines(QString line);
|
QString expandDefines(QString line);
|
||||||
|
|
|
@ -529,7 +529,6 @@ bool isHFile(const QString& filename)
|
||||||
{
|
{
|
||||||
if (filename.isEmpty())
|
if (filename.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
QFileInfo fileInfo(filename);
|
QFileInfo fileInfo(filename);
|
||||||
return CppHeaderExts->contains(fileInfo.suffix().toLower());
|
return CppHeaderExts->contains(fileInfo.suffix().toLower());
|
||||||
|
|
||||||
|
@ -576,28 +575,12 @@ void CppScopes::addScope(int line, PStatement scopeStatement)
|
||||||
scope->startLine = line;
|
scope->startLine = line;
|
||||||
scope->statement = scopeStatement;
|
scope->statement = scopeStatement;
|
||||||
mScopes.append(scope);
|
mScopes.append(scope);
|
||||||
|
#ifdef QT_DEBUG
|
||||||
if (!mScopes.isEmpty() && mScopes.back()->startLine>line) {
|
if (!mScopes.isEmpty() && mScopes.back()->startLine>line) {
|
||||||
qDebug()<<QString("Error: new scope %1 at %2 which is less that last scope %3")
|
qDebug()<<QString("Error: new scope %1 at %2 which is less that last scope %3")
|
||||||
.arg(scopeStatement->fullName, line,mScopes.back()->startLine>line);
|
.arg(scopeStatement->fullName, line,mScopes.back()->startLine>line);
|
||||||
}
|
}
|
||||||
}
|
#endif
|
||||||
|
|
||||||
PStatement CppScopes::lastScope() const
|
|
||||||
{
|
|
||||||
if (mScopes.isEmpty())
|
|
||||||
return PStatement();
|
|
||||||
return mScopes.back()->statement;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CppScopes::removeLastScope()
|
|
||||||
{
|
|
||||||
if (!mScopes.isEmpty())
|
|
||||||
mScopes.pop_back();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CppScopes::clear()
|
|
||||||
{
|
|
||||||
mScopes.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MemberOperatorType getOperatorType(const QString &phrase, int index)
|
MemberOperatorType getOperatorType(const QString &phrase, int index)
|
||||||
|
@ -767,17 +750,6 @@ bool isTypeKind(StatementKind kind)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ParsedFileInfo::ParsedFileInfo(const QString &fileName):
|
|
||||||
mFileName { fileName }
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParsedFileInfo::insertBranch(int level, bool branchTrue)
|
|
||||||
{
|
|
||||||
mBranches.insert(level, branchTrue);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ParsedFileInfo::isLineVisible(int line) const
|
bool ParsedFileInfo::isLineVisible(int line) const
|
||||||
{
|
{
|
||||||
int lastI=-1;
|
int lastI=-1;
|
||||||
|
@ -789,93 +761,3 @@ bool ParsedFileInfo::isLineVisible(int line) const
|
||||||
}
|
}
|
||||||
return lastI<0?true:mBranches[lastI];
|
return lastI<0?true:mBranches[lastI];
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParsedFileInfo::addInclude(const QString &fileName)
|
|
||||||
{
|
|
||||||
mIncludes.insert(fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParsedFileInfo::addDirectInclude(const QString &fileName)
|
|
||||||
{
|
|
||||||
mDirectIncludes.append(fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ParsedFileInfo::including(const QString &fileName) const
|
|
||||||
{
|
|
||||||
return mIncludes.contains(fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
const QSet<QString>& ParsedFileInfo::includes() const
|
|
||||||
{
|
|
||||||
return mIncludes;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QList<std::weak_ptr<ClassInheritanceInfo> >& ParsedFileInfo::handledInheritances() const
|
|
||||||
{
|
|
||||||
return mHandledInheritances;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ParsedFileInfo::fileName() const
|
|
||||||
{
|
|
||||||
return mFileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
PStatement ParsedFileInfo::findScopeAtLine(int line) const
|
|
||||||
{
|
|
||||||
return mScopes.findScopeAtLine(line);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParsedFileInfo::addStatement(const PStatement &statement)
|
|
||||||
{
|
|
||||||
mStatements.insert(statement->fullName,statement);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParsedFileInfo::clearStatements()
|
|
||||||
{
|
|
||||||
mStatements.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParsedFileInfo::addScope(int line, const PStatement &scope)
|
|
||||||
{
|
|
||||||
mScopes.addScope(line,scope);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParsedFileInfo::removeLastScope()
|
|
||||||
{
|
|
||||||
mScopes.removeLastScope();
|
|
||||||
}
|
|
||||||
|
|
||||||
PStatement ParsedFileInfo::lastScope() const
|
|
||||||
{
|
|
||||||
return mScopes.lastScope();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParsedFileInfo::addUsing(const QString &usingSymbol)
|
|
||||||
{
|
|
||||||
mUsings.insert(usingSymbol);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParsedFileInfo::addHandledInheritances(std::weak_ptr<ClassInheritanceInfo> classInheritanceInfo)
|
|
||||||
{
|
|
||||||
mHandledInheritances.append(classInheritanceInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParsedFileInfo::clearHandledInheritances()
|
|
||||||
{
|
|
||||||
mHandledInheritances.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
const StatementMap& ParsedFileInfo::statements() const
|
|
||||||
{
|
|
||||||
return mStatements;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QSet<QString>& ParsedFileInfo::usings() const
|
|
||||||
{
|
|
||||||
return mUsings;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QStringList& ParsedFileInfo::directIncludes() const
|
|
||||||
{
|
|
||||||
return mDirectIncludes;
|
|
||||||
}
|
|
||||||
|
|
|
@ -174,8 +174,6 @@ Q_DECLARE_FLAGS(StatementProperties, StatementProperty)
|
||||||
|
|
||||||
Q_DECLARE_OPERATORS_FOR_FLAGS(StatementProperties)
|
Q_DECLARE_OPERATORS_FOR_FLAGS(StatementProperties)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
using PStatementMathPosition = std::shared_ptr<StatementMatchPosition>;
|
using PStatementMathPosition = std::shared_ptr<StatementMatchPosition>;
|
||||||
|
|
||||||
struct Statement;
|
struct Statement;
|
||||||
|
@ -184,8 +182,6 @@ using StatementList = QList<PStatement>;
|
||||||
using PStatementList = std::shared_ptr<StatementList>;
|
using PStatementList = std::shared_ptr<StatementList>;
|
||||||
using StatementMap = QMultiMap<QString, PStatement>;
|
using StatementMap = QMultiMap<QString, PStatement>;
|
||||||
struct Statement {
|
struct Statement {
|
||||||
// Statement();
|
|
||||||
// ~Statement();
|
|
||||||
std::weak_ptr<Statement> parentScope; // parent class/struct/namespace scope, use weak pointer to prevent circular reference
|
std::weak_ptr<Statement> parentScope; // parent class/struct/namespace scope, use weak pointer to prevent circular reference
|
||||||
QString type; // type "int"
|
QString type; // type "int"
|
||||||
QString command; // identifier/name of statement "foo"
|
QString command; // identifier/name of statement "foo"
|
||||||
|
@ -293,13 +289,19 @@ struct CppScope {
|
||||||
|
|
||||||
using PCppScope = std::shared_ptr<CppScope>;
|
using PCppScope = std::shared_ptr<CppScope>;
|
||||||
class CppScopes {
|
class CppScopes {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PStatement findScopeAtLine(int line) const;
|
PStatement findScopeAtLine(int line) const;
|
||||||
void addScope(int line, PStatement scopeStatement);
|
void addScope(int line, PStatement scopeStatement);
|
||||||
PStatement lastScope() const;
|
PStatement lastScope() const {
|
||||||
void removeLastScope();
|
if (mScopes.isEmpty())
|
||||||
void clear();
|
return PStatement();
|
||||||
|
return mScopes.back()->statement;
|
||||||
|
}
|
||||||
|
void removeLastScope() {
|
||||||
|
if (!mScopes.isEmpty())
|
||||||
|
mScopes.pop_back();
|
||||||
|
}
|
||||||
|
void clear() { mScopes.clear(); }
|
||||||
private:
|
private:
|
||||||
QVector<PCppScope> mScopes;
|
QVector<PCppScope> mScopes;
|
||||||
};
|
};
|
||||||
|
@ -319,32 +321,30 @@ using PClassInheritanceInfo = std::shared_ptr<ClassInheritanceInfo>;
|
||||||
|
|
||||||
class ParsedFileInfo {
|
class ParsedFileInfo {
|
||||||
public:
|
public:
|
||||||
ParsedFileInfo(const QString& fileName);
|
ParsedFileInfo(const QString& fileName): mFileName {fileName} { }
|
||||||
ParsedFileInfo(const ParsedFileInfo&)=delete;
|
ParsedFileInfo(const ParsedFileInfo&)=delete;
|
||||||
ParsedFileInfo& operator=(const ParsedFileInfo&)=delete;
|
ParsedFileInfo& operator=(const ParsedFileInfo&)=delete;
|
||||||
void insertBranch(int level, bool branchTrue);
|
void insertBranch(int level, bool branchTrue) { mBranches.insert(level, branchTrue); }
|
||||||
bool isLineVisible(int line) const;
|
bool isLineVisible(int line) const;
|
||||||
void addInclude(const QString &fileName);
|
void addInclude(const QString &fileName) { mIncludes.insert(fileName); }
|
||||||
void addDirectInclude(const QString &fileName);
|
void addDirectInclude(const QString &fileName) { mDirectIncludes.append(fileName); }
|
||||||
bool including(const QString &fileName) const;
|
bool including(const QString &fileName) const { return mIncludes.contains(fileName); }
|
||||||
PStatement findScopeAtLine(int line) const;
|
PStatement findScopeAtLine(int line) const { return mScopes.findScopeAtLine(line); }
|
||||||
void addStatement(const PStatement &statement);
|
void addStatement(const PStatement &statement) { mStatements.insert(statement->fullName,statement); }
|
||||||
void clearStatements();
|
void clearStatements() { mStatements.clear(); }
|
||||||
void addScope(int line, const PStatement &scope);
|
void addScope(int line, const PStatement &scope) { mScopes.addScope(line,scope); }
|
||||||
void removeLastScope();
|
void removeLastScope() { mScopes.removeLastScope(); }
|
||||||
PStatement lastScope() const;
|
PStatement lastScope() const { return mScopes.lastScope(); }
|
||||||
void addUsing(const QString &usingSymbol);
|
void addUsing(const QString &usingSymbol) { mUsings.insert(usingSymbol); }
|
||||||
void addHandledInheritances(std::weak_ptr<ClassInheritanceInfo> classInheritanceInfo);
|
void addHandledInheritances(std::weak_ptr<ClassInheritanceInfo> classInheritanceInfo) { mHandledInheritances.append(classInheritanceInfo); }
|
||||||
void clearHandledInheritances();
|
void clearHandledInheritances() { mHandledInheritances.clear(); }
|
||||||
|
|
||||||
QString fileName() const;
|
QString fileName() const { return mFileName; }
|
||||||
const StatementMap& statements() const;
|
const StatementMap& statements() const { return mStatements; }
|
||||||
const QSet<QString>& usings() const;
|
const QSet<QString>& usings() const { return mUsings; }
|
||||||
const QStringList& directIncludes() const;
|
const QStringList& directIncludes() const { return mDirectIncludes; }
|
||||||
const QSet<QString>& includes() const;
|
const QSet<QString>& includes() const { return mIncludes; }
|
||||||
const QList<std::weak_ptr<ClassInheritanceInfo> >& handledInheritances() const;
|
const QList<std::weak_ptr<ClassInheritanceInfo> >& handledInheritances() const { return mHandledInheritances; }
|
||||||
const QSet<QString> &includedBySet() const;
|
|
||||||
int includedByCount(const QString &fileName) const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString mFileName;
|
QString mFileName;
|
||||||
|
|
|
@ -39,7 +39,6 @@ void StatementModel::add(const PStatement& statement)
|
||||||
#ifdef QT_DEBUG
|
#ifdef QT_DEBUG
|
||||||
mAllStatements.append(statement);
|
mAllStatements.append(statement);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatementModel::deleteStatement(const PStatement& statement)
|
void StatementModel::deleteStatement(const PStatement& statement)
|
||||||
|
@ -61,29 +60,6 @@ void StatementModel::deleteStatement(const PStatement& statement)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const StatementMap &StatementModel::childrenStatements(const PStatement& statement) const
|
|
||||||
{
|
|
||||||
if (!statement) {
|
|
||||||
return mGlobalStatements;
|
|
||||||
} else {
|
|
||||||
return statement->children;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const StatementMap &StatementModel::childrenStatements(std::weak_ptr<Statement> statement) const
|
|
||||||
{
|
|
||||||
PStatement s = statement.lock();
|
|
||||||
return childrenStatements(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
void StatementModel::clear() {
|
|
||||||
mCount=0;
|
|
||||||
mGlobalStatements.clear();
|
|
||||||
#ifdef QT_DEBUG
|
|
||||||
mAllStatements.clear();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef QT_DEBUG
|
#ifdef QT_DEBUG
|
||||||
void StatementModel::dump(const QString &logFile)
|
void StatementModel::dump(const QString &logFile)
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,12 +30,22 @@ public:
|
||||||
StatementModel& operator=(const StatementModel&)=delete;
|
StatementModel& operator=(const StatementModel&)=delete;
|
||||||
|
|
||||||
void add(const PStatement& statement);
|
void add(const PStatement& statement);
|
||||||
// function DeleteFirst: Integer;
|
|
||||||
// function DeleteLast: Integer;
|
|
||||||
void deleteStatement(const PStatement& statement);
|
void deleteStatement(const PStatement& statement);
|
||||||
const StatementMap& childrenStatements(const PStatement& statement = PStatement()) const;
|
const StatementMap& childrenStatements(const PStatement& statement = PStatement()) const {
|
||||||
const StatementMap& childrenStatements(std::weak_ptr<Statement> statement) const;
|
if (!statement) {
|
||||||
void clear();
|
return mGlobalStatements;
|
||||||
|
} else {
|
||||||
|
return statement->children;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const StatementMap& childrenStatements(std::weak_ptr<Statement> statement) const { return childrenStatements(statement.lock()); }
|
||||||
|
void clear() {
|
||||||
|
mCount=0;
|
||||||
|
mGlobalStatements.clear();
|
||||||
|
#ifdef QT_DEBUG
|
||||||
|
mAllStatements.clear();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
int count() const { return mCount; }
|
int count() const { return mCount; }
|
||||||
#ifdef QT_DEBUG
|
#ifdef QT_DEBUG
|
||||||
void dump(const QString& logFile);
|
void dump(const QString& logFile);
|
||||||
|
|
Loading…
Reference in New Issue