work save
This commit is contained in:
parent
2eeea0eb6d
commit
7b59e6a9ea
|
@ -64,25 +64,25 @@ void CppParser::addHardDefineByLine(const QString &line)
|
|||
void CppParser::addIncludePath(const QString &value)
|
||||
{
|
||||
QMutexLocker locker(&mMutex);
|
||||
mIncludePaths.insert(value);
|
||||
mPreprocessor.includePaths().insert(value);
|
||||
}
|
||||
|
||||
void CppParser::addProjectIncludePath(const QString &value)
|
||||
{
|
||||
QMutexLocker locker(&mMutex);
|
||||
mProjectIncludePaths.insert(value);
|
||||
mPreprocessor.projectIncludePaths().insert(value);
|
||||
}
|
||||
|
||||
void CppParser::clearIncludePaths()
|
||||
{
|
||||
QMutexLocker locker(&mMutex);
|
||||
mIncludePaths.clear();
|
||||
mPreprocessor.includePaths().clear();
|
||||
}
|
||||
|
||||
void CppParser::clearProjectIncludePaths()
|
||||
{
|
||||
QMutexLocker locker(&mMutex);
|
||||
mProjectIncludePaths.clear();
|
||||
mPreprocessor.projectIncludePaths().clear();
|
||||
}
|
||||
|
||||
void CppParser::clearProjectFiles()
|
||||
|
@ -91,6 +91,25 @@ void CppParser::clearProjectFiles()
|
|||
mProjectFiles.clear();
|
||||
}
|
||||
|
||||
void CppParser::fillListOfFunctions(const QString &fileName, const QString &phrase, int line, QStringList &list)
|
||||
{
|
||||
QMutexLocker locker(&mMutex);
|
||||
list.clear();
|
||||
PStatement statement = findStatementOf(fileName,phrase, line);
|
||||
if (!statement)
|
||||
return;
|
||||
PStatement parentScope = statement->parentScope.lock();
|
||||
if (parentScope && parentScope->kind == StatementKind::skNamespace) {
|
||||
PStatementList namespaceStatementsList = findNamespace(parentScope->command);
|
||||
if (namespaceStatementsList) {
|
||||
for (PStatement namespaceStatement : *namespaceStatementsList) {
|
||||
fillListOfFunctions(fileName,line,statement,namespaceStatement,list);
|
||||
}
|
||||
}
|
||||
} else
|
||||
fillListOfFunctions(fileName,line,statement,parentScope,list);
|
||||
}
|
||||
|
||||
void CppParser::addFileToScan(QString value, bool inProject)
|
||||
{
|
||||
QMutexLocker locker(&mMutex);
|
||||
|
@ -2104,10 +2123,10 @@ void CppParser::internalParse(const QString &fileName)
|
|||
mTokenizer.reset();
|
||||
});
|
||||
// Let the preprocessor augment the include records
|
||||
mPreprocessor.setIncludesList(mIncludesList);
|
||||
mPreprocessor.setIncludePaths(mIncludePaths);
|
||||
mPreprocessor.setProjectIncludePaths(mProjectIncludePaths);
|
||||
mPreprocessor.setScannedFileList(mScannedFiles);
|
||||
// mPreprocessor.setIncludesList(mIncludesList);
|
||||
// mPreprocessor.setIncludePaths(mIncludePaths);
|
||||
// mPreprocessor.setProjectIncludePaths(mProjectIncludePaths);
|
||||
// mPreprocessor.setScannedFileList(mScannedFiles);
|
||||
mPreprocessor.setScanOptions(mParseGlobalHeaders, mParseLocalHeaders);
|
||||
mPreprocessor.preprocess(fileName, tempStream);
|
||||
|
||||
|
@ -2190,6 +2209,23 @@ QString CppParser::expandMacroType(const QString &name)
|
|||
return name;
|
||||
}
|
||||
|
||||
void CppParser::fillListOfFunctions(const QString& fileName, int line,PStatement statement, PStatement scopeStatement, QStringList &list)
|
||||
{
|
||||
StatementMap children = mStatementList.childrenStatements(scopeStatement);
|
||||
for (PStatement child:children) {
|
||||
if ((statement->command == child->command)
|
||||
#ifdef Q_OS_WIN
|
||||
|| (statement->command +'A' == child->command)
|
||||
|| (statement->command +'W' == child->command)
|
||||
#endif
|
||||
) {
|
||||
if (line < child->line && (child->fileName == fileName))
|
||||
continue;
|
||||
list.append(prettyPrintStatement(child));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PStatement CppParser::findMemberOfStatement(const QString &phrase, PStatement scopeStatement)
|
||||
{
|
||||
const StatementMap& statementMap =mStatementList.childrenStatements(scopeStatement);
|
||||
|
@ -2690,3 +2726,23 @@ void CppParser::updateSerialId()
|
|||
{
|
||||
mSerialId = QString("%1 %2").arg(mParserId).arg(mSerialCount);
|
||||
}
|
||||
|
||||
const QSet<QString> &CppParser::filesToScan() const
|
||||
{
|
||||
return mFilesToScan;
|
||||
}
|
||||
|
||||
void CppParser::setFilesToScan(const QSet<QString> &newFilesToScan)
|
||||
{
|
||||
mFilesToScan = newFilesToScan;
|
||||
}
|
||||
|
||||
bool CppParser::enabled() const
|
||||
{
|
||||
return mEnabled;
|
||||
}
|
||||
|
||||
void CppParser::setEnabled(bool newEnabled)
|
||||
{
|
||||
mEnabled = newEnabled;
|
||||
}
|
||||
|
|
|
@ -98,6 +98,12 @@ public:
|
|||
int line,
|
||||
QStringList& params,
|
||||
bool &isVoid);
|
||||
bool enabled() const;
|
||||
void setEnabled(bool newEnabled);
|
||||
|
||||
const QSet<QString> &filesToScan() const;
|
||||
void setFilesToScan(const QSet<QString> &newFilesToScan);
|
||||
|
||||
signals:
|
||||
void onProgress(const QString& fileName, int total, int current);
|
||||
void onBusy();
|
||||
|
@ -162,6 +168,7 @@ private:
|
|||
bool checkForVar();
|
||||
QString expandMacroType(const QString& name);
|
||||
//{procedure ResetDefines;}
|
||||
void fillListOfFunctions(const QString& fileName, int line,PStatement statement, PStatement scopeStatement, QStringList& list);
|
||||
PStatement findMemberOfStatement(
|
||||
const QString& phrase,
|
||||
PStatement scopeStatement);
|
||||
|
@ -303,11 +310,7 @@ private:
|
|||
std::shared_ptr<QSet<QString>> mScannedFiles; // List of scaned file names
|
||||
CppTokenizer mTokenizer;
|
||||
CppPreprocessor mPreprocessor;
|
||||
//{ List of current compiler set's include path}
|
||||
QSet<QString> mIncludePaths;
|
||||
//{ List of current project's include path }
|
||||
QSet<QString> mProjectIncludePaths;
|
||||
//{ List of current project's include path }
|
||||
//{ List of current project's file }
|
||||
QSet<QString> mProjectFiles;
|
||||
QVector<int> mBlockBeginSkips; //list of for/catch block begin token index;
|
||||
QVector<int> mBlockEndSkips; //list of for/catch block end token index;
|
||||
|
|
|
@ -18,7 +18,6 @@ void CppPreprocessor::clear()
|
|||
mBranchResults.clear();
|
||||
mResult.clear();
|
||||
mCurrentIncludes.reset();
|
||||
mScannedFiles.reset();
|
||||
}
|
||||
|
||||
void CppPreprocessor::addDefineByParts(const QString &name, const QString &args, const QString &value, bool hardCoded)
|
||||
|
@ -139,26 +138,6 @@ void CppPreprocessor::setScanOptions(bool parseSystem, bool parseLocal)
|
|||
mParseLocal=parseLocal;
|
||||
}
|
||||
|
||||
void CppPreprocessor::setIncludePaths(QSet<QString> list)
|
||||
{
|
||||
mIncludePaths = list;
|
||||
}
|
||||
|
||||
void CppPreprocessor::setProjectIncludePaths(QSet<QString> list)
|
||||
{
|
||||
mProjectIncludePaths = list;
|
||||
}
|
||||
|
||||
void CppPreprocessor::setScannedFileList(std::shared_ptr<QSet<QString> > list)
|
||||
{
|
||||
mScannedFiles = list;
|
||||
}
|
||||
|
||||
void CppPreprocessor::setIncludesList(std::shared_ptr<QHash<QString, PFileIncludes> > list)
|
||||
{
|
||||
mIncludesList = list;
|
||||
}
|
||||
|
||||
void CppPreprocessor::preprocess(const QString &fileName, QStringList buffer)
|
||||
{
|
||||
mFileName = fileName;
|
||||
|
@ -184,7 +163,7 @@ void CppPreprocessor::invalidDefinesInFile(const QString &fileName)
|
|||
}
|
||||
}
|
||||
|
||||
void CppPreprocessor::dumpDefinesTo(const QString &fileName)
|
||||
void CppPreprocessor::dumpDefinesTo(const QString &fileName) const
|
||||
{
|
||||
QFile file(fileName);
|
||||
if (file.open(QIODevice::WriteOnly|QIODevice::Truncate)) {
|
||||
|
@ -197,12 +176,12 @@ void CppPreprocessor::dumpDefinesTo(const QString &fileName)
|
|||
}
|
||||
}
|
||||
|
||||
void CppPreprocessor::dumpIncludesListTo(const QString &fileName)
|
||||
void CppPreprocessor::dumpIncludesListTo(const QString &fileName) const
|
||||
{
|
||||
QFile file(fileName);
|
||||
if (file.open(QIODevice::WriteOnly|QIODevice::Truncate)) {
|
||||
QTextStream stream(&file);
|
||||
for (PFileIncludes fileIncludes:*mIncludesList) {
|
||||
for (PFileIncludes fileIncludes:mIncludesList) {
|
||||
stream<<fileIncludes->baseFile<<" : "<<Qt::endl;
|
||||
stream<<"\t**includes:**"<<Qt::endl;
|
||||
for (QString s:fileIncludes->includeFiles.keys()) {
|
||||
|
@ -604,16 +583,16 @@ void CppPreprocessor::openInclude(const QString &fileName, QStringList bufferedT
|
|||
//mCurrentIncludes->scopes;
|
||||
//mCurrentIncludes->dependedFiles;
|
||||
//mCurrentIncludes->dependingFiles;
|
||||
mIncludesList->insert(fileName,mCurrentIncludes);
|
||||
mIncludesList.insert(fileName,mCurrentIncludes);
|
||||
}
|
||||
|
||||
parsedFile->fileIncludes = mCurrentIncludes;
|
||||
|
||||
// Don't parse stuff we have already parsed
|
||||
if ((!bufferedText.isEmpty()) || !mScannedFiles->contains(fileName)) {
|
||||
if ((!bufferedText.isEmpty()) || !mScannedFiles.contains(fileName)) {
|
||||
// Parse ONCE
|
||||
//if not Assigned(Stream) then
|
||||
mScannedFiles->insert(fileName);
|
||||
mScannedFiles.insert(fileName);
|
||||
|
||||
// Only load up the file if we are allowed to parse it
|
||||
bool isSystemFile = isSystemHeaderFile(fileName, mIncludePaths);
|
||||
|
@ -703,14 +682,14 @@ void CppPreprocessor::removeCurrentBranch()
|
|||
mBranchResults.pop_back();
|
||||
}
|
||||
|
||||
QStringList CppPreprocessor::result()
|
||||
QStringList CppPreprocessor::result() const
|
||||
{
|
||||
return mResult;
|
||||
}
|
||||
|
||||
PFileIncludes CppPreprocessor::getFileIncludesEntry(const QString &fileName)
|
||||
{
|
||||
return mIncludesList->value(fileName,PFileIncludes());
|
||||
return mIncludesList.value(fileName,PFileIncludes());
|
||||
}
|
||||
|
||||
void CppPreprocessor::addDefinesInFile(const QString &fileName)
|
||||
|
@ -720,7 +699,7 @@ void CppPreprocessor::addDefinesInFile(const QString &fileName)
|
|||
mProcessed.insert(fileName);
|
||||
|
||||
//todo: why test this?
|
||||
if (!mScannedFiles->contains(fileName))
|
||||
if (!mScannedFiles.contains(fileName))
|
||||
return;
|
||||
|
||||
//May be redefined, so order is important
|
||||
|
@ -1601,3 +1580,23 @@ int CppPreprocessor::evaluateExpression(QString line)
|
|||
return result;
|
||||
}
|
||||
|
||||
QSet<QString> &CppPreprocessor::projectIncludePaths()
|
||||
{
|
||||
return mProjectIncludePaths;
|
||||
}
|
||||
|
||||
QSet<QString> &CppPreprocessor::includePaths()
|
||||
{
|
||||
return mIncludePaths;
|
||||
}
|
||||
|
||||
QSet<QString> &CppPreprocessor::scannedFiles()
|
||||
{
|
||||
return mScannedFiles;
|
||||
}
|
||||
|
||||
QHash<QString, PFileIncludes> &CppPreprocessor::includesList()
|
||||
{
|
||||
return mIncludesList;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,16 +42,21 @@ public:
|
|||
void reset(); //reset but don't clear generated defines
|
||||
void resetDefines();
|
||||
void setScanOptions(bool parseSystem, bool parseLocal);
|
||||
void setIncludePaths(QSet<QString> list);
|
||||
void setProjectIncludePaths(QSet<QString> list);
|
||||
void setScannedFileList(std::shared_ptr<QSet<QString>> list);
|
||||
void setIncludesList(std::shared_ptr<QHash<QString,PFileIncludes>> list);
|
||||
void preprocess(const QString& fileName, QStringList buffer = QStringList());
|
||||
void invalidDefinesInFile(const QString& fileName);
|
||||
|
||||
void dumpDefinesTo(const QString& fileName);
|
||||
void dumpIncludesListTo(const QString& fileName);
|
||||
QStringList result();
|
||||
void dumpDefinesTo(const QString& fileName) const;
|
||||
void dumpIncludesListTo(const QString& fileName) const;
|
||||
QStringList result() const;
|
||||
|
||||
QHash<QString, PFileIncludes> &includesList();
|
||||
|
||||
QSet<QString> &scannedFiles();
|
||||
|
||||
QSet<QString> &includePaths();
|
||||
|
||||
QSet<QString> &projectIncludePaths();
|
||||
|
||||
signals:
|
||||
|
||||
private:
|
||||
|
@ -153,17 +158,20 @@ private:
|
|||
QStringList mResult;
|
||||
PFileIncludes mCurrentIncludes;
|
||||
int mPreProcIndex;
|
||||
std::shared_ptr<QHash<QString,PFileIncludes>> mIncludesList;
|
||||
QHash<QString,PFileIncludes> mIncludesList;
|
||||
DefineMap mHardDefines; // set by "cpp -dM -E -xc NUL"
|
||||
DefineMap mDefines; // working set, editable
|
||||
QHash<QString, PDefineMap> mFileDefines; //dictionary to save defines for each headerfile;
|
||||
QList<PParsedFile> mIncludes; // stack of files we've stepped into. last one is current file, first one is source file
|
||||
QList<bool> mBranchResults;// stack of branch results (boolean). last one is current branch, first one is outermost branch
|
||||
QSet<QString> mIncludePaths; // path to include folders
|
||||
//{ List of current compiler set's include path}
|
||||
QSet<QString> mIncludePaths;
|
||||
//{ List of current project's include path }
|
||||
QSet<QString> mProjectIncludePaths;
|
||||
|
||||
bool mParseSystem;
|
||||
bool mParseLocal;
|
||||
std::shared_ptr<QSet<QString>> mScannedFiles;
|
||||
QSet<QString> mScannedFiles;
|
||||
QSet<QString> mProcessed; // dictionary to save filename already processed
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue