- enhancement: support #include_next (and clang libc++)
This commit is contained in:
parent
5180387ec7
commit
77e8eda8a3
1
NEWS.md
1
NEWS.md
|
@ -17,6 +17,7 @@ Version 0.6.0
|
|||
- implement: when startup , open file provided by command line options
|
||||
- implement: open files pasted by clipboard
|
||||
- fix: code fold parsing not correct
|
||||
- enhancement: support #include_next (and clang libc++)
|
||||
|
||||
Version 0.5.0
|
||||
- enhancement: support C++ using type alias;
|
||||
|
|
|
@ -68,25 +68,25 @@ void CppParser::addHardDefineByLine(const QString &line)
|
|||
void CppParser::addIncludePath(const QString &value)
|
||||
{
|
||||
QMutexLocker locker(&mMutex);
|
||||
mPreprocessor.includePaths().insert(includeTrailingPathDelimiter(value));
|
||||
mPreprocessor.addIncludePath(includeTrailingPathDelimiter(value));
|
||||
}
|
||||
|
||||
void CppParser::addProjectIncludePath(const QString &value)
|
||||
{
|
||||
QMutexLocker locker(&mMutex);
|
||||
mPreprocessor.projectIncludePaths().insert(includeTrailingPathDelimiter(value));
|
||||
mPreprocessor.addProjectIncludePath(includeTrailingPathDelimiter(value));
|
||||
}
|
||||
|
||||
void CppParser::clearIncludePaths()
|
||||
{
|
||||
QMutexLocker locker(&mMutex);
|
||||
mPreprocessor.includePaths().clear();
|
||||
mPreprocessor.clearIncludePaths();
|
||||
}
|
||||
|
||||
void CppParser::clearProjectIncludePaths()
|
||||
{
|
||||
QMutexLocker locker(&mMutex);
|
||||
mPreprocessor.projectIncludePaths().clear();
|
||||
mPreprocessor.clearProjectIncludePaths();
|
||||
}
|
||||
|
||||
void CppParser::clearProjectFiles()
|
||||
|
@ -819,8 +819,8 @@ void CppParser::reset()
|
|||
mNamespaces.clear();
|
||||
mInlineNamespaces.clear();
|
||||
|
||||
mPreprocessor.projectIncludePaths().clear();
|
||||
mPreprocessor.includePaths().clear();
|
||||
mPreprocessor.clearProjectIncludePaths();
|
||||
mPreprocessor.clearIncludePaths();
|
||||
mProjectFiles.clear();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -212,6 +212,30 @@ void CppPreprocessor::dumpIncludesListTo(const QString &fileName) const
|
|||
}
|
||||
}
|
||||
|
||||
void CppPreprocessor::addIncludePath(const QString &fileName)
|
||||
{
|
||||
mIncludePaths.insert(fileName);
|
||||
mIncludePathList.append(fileName);
|
||||
}
|
||||
|
||||
void CppPreprocessor::addProjectIncludePath(const QString &fileName)
|
||||
{
|
||||
mProjectIncludePaths.insert(fileName);
|
||||
mProjectIncludeList.append(fileName);
|
||||
}
|
||||
|
||||
void CppPreprocessor::clearIncludePaths()
|
||||
{
|
||||
mIncludePaths.clear();
|
||||
mIncludePathList.clear();
|
||||
}
|
||||
|
||||
void CppPreprocessor::clearProjectIncludePaths()
|
||||
{
|
||||
mProjectIncludePaths.clear();
|
||||
mProjectIncludeList.clear();
|
||||
}
|
||||
|
||||
QString CppPreprocessor::getNextPreprocessor()
|
||||
{
|
||||
skipToPreprocessor(); // skip until # at start of line
|
||||
|
@ -323,15 +347,42 @@ void CppPreprocessor::handleDefine(const QString &line)
|
|||
}
|
||||
}
|
||||
|
||||
void CppPreprocessor::handleInclude(const QString &line)
|
||||
void CppPreprocessor::handleInclude(const QString &line, bool fromNext)
|
||||
{
|
||||
if (!getCurrentBranch()) // we're skipping due to a branch failure
|
||||
return;
|
||||
|
||||
PParsedFile file = mIncludes.back();
|
||||
QString fileName;
|
||||
// Get full header file name
|
||||
QString fileName = getHeaderFilename(file->fileName, line,mIncludePaths,
|
||||
mProjectIncludePaths);
|
||||
QString currentDir = includeTrailingPathDelimiter(extractFileDir(file->fileName));
|
||||
QSet<QString> includes;
|
||||
QSet<QString> projectIncludes;
|
||||
if (fromNext && mIncludePaths.contains(currentDir)) {
|
||||
bool found = false;
|
||||
foreach(const QString& s, mIncludePathList) {
|
||||
if (found)
|
||||
includes.insert(s);
|
||||
if (s == currentDir)
|
||||
found = true;
|
||||
}
|
||||
} else
|
||||
includes = mIncludePaths;
|
||||
if (fromNext && mProjectIncludePaths.contains(currentDir)) {
|
||||
bool found = false;
|
||||
foreach(const QString& s, mProjectIncludeList) {
|
||||
if (found)
|
||||
projectIncludes.insert(s);
|
||||
if (s == currentDir)
|
||||
found = true;
|
||||
}
|
||||
} else
|
||||
projectIncludes = mProjectIncludePaths;
|
||||
fileName = getHeaderFilename(
|
||||
file->fileName,
|
||||
line,
|
||||
includes,
|
||||
projectIncludes);
|
||||
|
||||
if (fileName.isEmpty())
|
||||
return;
|
||||
|
@ -354,6 +405,8 @@ void CppPreprocessor::handlePreprocessor(const QString &value)
|
|||
handleBranch(value);
|
||||
else if (value.startsWith("include"))
|
||||
handleInclude(value);
|
||||
else if (value.startsWith("include_next"))
|
||||
handleInclude(value,true);
|
||||
}
|
||||
|
||||
void CppPreprocessor::handleUndefine(const QString &line)
|
||||
|
@ -1662,12 +1715,12 @@ const DefineMap &CppPreprocessor::hardDefines() const
|
|||
return mHardDefines;
|
||||
}
|
||||
|
||||
QSet<QString> &CppPreprocessor::projectIncludePaths()
|
||||
const QSet<QString> &CppPreprocessor::projectIncludePaths()
|
||||
{
|
||||
return mProjectIncludePaths;
|
||||
}
|
||||
|
||||
QSet<QString> &CppPreprocessor::includePaths()
|
||||
const QSet<QString> &CppPreprocessor::includePaths()
|
||||
{
|
||||
return mIncludePaths;
|
||||
}
|
||||
|
|
|
@ -60,15 +60,19 @@ public:
|
|||
|
||||
void dumpDefinesTo(const QString& fileName) const;
|
||||
void dumpIncludesListTo(const QString& fileName) const;
|
||||
void addIncludePath(const QString& fileName);
|
||||
void addProjectIncludePath(const QString& fileName);
|
||||
void clearIncludePaths();
|
||||
void clearProjectIncludePaths();
|
||||
QStringList result() const;
|
||||
|
||||
QHash<QString, PFileIncludes> &includesList();
|
||||
|
||||
QSet<QString> &scannedFiles();
|
||||
|
||||
QSet<QString> &includePaths();
|
||||
const QSet<QString> &includePaths();
|
||||
|
||||
QSet<QString> &projectIncludePaths();
|
||||
const QSet<QString> &projectIncludePaths();
|
||||
|
||||
const DefineMap &hardDefines() const;
|
||||
|
||||
|
@ -82,7 +86,7 @@ private:
|
|||
void simplify(QString& output);
|
||||
void handleBranch(const QString& line);
|
||||
void handleDefine(const QString& line);
|
||||
void handleInclude(const QString& line);
|
||||
void handleInclude(const QString& line, bool fromNext=false);
|
||||
void handlePreprocessor(const QString& value);
|
||||
void handleUndefine(const QString& line);
|
||||
QString expandMacros(const QString& line, int depth);
|
||||
|
@ -183,6 +187,9 @@ private:
|
|||
QSet<QString> mIncludePaths;
|
||||
//{ List of current project's include path }
|
||||
QSet<QString> mProjectIncludePaths;
|
||||
//we also need include paths in order (for #include_next)
|
||||
QList<QString> mIncludePathList;
|
||||
QList<QString> mProjectIncludeList;
|
||||
|
||||
bool mParseSystem;
|
||||
bool mParseLocal;
|
||||
|
|
|
@ -70,6 +70,10 @@ void FunctionTooltipWidget::setParamPos(int newParamPos)
|
|||
|
||||
void FunctionTooltipWidget::nextTip()
|
||||
{
|
||||
if (mInfoIndex>=mInfos.length()-1) {
|
||||
hide();
|
||||
return;
|
||||
}
|
||||
if (mInfos.length()>0)
|
||||
mInfoIndex = std::min(mInfoIndex+1,mInfos.length()-1);
|
||||
updateTip();
|
||||
|
@ -77,6 +81,10 @@ void FunctionTooltipWidget::nextTip()
|
|||
|
||||
void FunctionTooltipWidget::previousTip()
|
||||
{
|
||||
if (mInfoIndex==0) {
|
||||
hide();
|
||||
return ;
|
||||
}
|
||||
if (mInfos.length()>0)
|
||||
mInfoIndex = std::max(mInfoIndex-1,0);
|
||||
updateTip();
|
||||
|
|
Loading…
Reference in New Issue