fix: #include_next processing
This commit is contained in:
parent
2f76aa42a8
commit
3ed5701621
1
NEWS.md
1
NEWS.md
|
@ -18,6 +18,7 @@ Version 0.6.0
|
||||||
- implement: open files pasted by clipboard
|
- implement: open files pasted by clipboard
|
||||||
- fix: code fold parsing not correct
|
- fix: code fold parsing not correct
|
||||||
- enhancement: support #include_next (and clang libc++)
|
- enhancement: support #include_next (and clang libc++)
|
||||||
|
- fix: hide popup windows when the editor is closed
|
||||||
|
|
||||||
Version 0.5.0
|
Version 0.5.0
|
||||||
- enhancement: support C++ using type alias;
|
- enhancement: support C++ using type alias;
|
||||||
|
|
|
@ -472,12 +472,6 @@ void Editor::focusOutEvent(QFocusEvent *event)
|
||||||
this,
|
this,
|
||||||
&SynEdit::invalidate);
|
&SynEdit::invalidate);
|
||||||
}
|
}
|
||||||
if (mHeaderCompletionPopup)
|
|
||||||
mHeaderCompletionPopup->hide();
|
|
||||||
if (mCompletionPopup)
|
|
||||||
mCompletionPopup->hide();
|
|
||||||
if (pMainWindow->functionTip())
|
|
||||||
pMainWindow->functionTip()->hide();
|
|
||||||
//pMainWindow->updateClassBrowserForEditor(nullptr);
|
//pMainWindow->updateClassBrowserForEditor(nullptr);
|
||||||
pMainWindow->updateEditorActions();
|
pMainWindow->updateEditorActions();
|
||||||
pMainWindow->updateStatusbarForLineCol();
|
pMainWindow->updateStatusbarForLineCol();
|
||||||
|
@ -1074,6 +1068,16 @@ void Editor::inputMethodEvent(QInputMethodEvent *event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Editor::closeEvent(QCloseEvent *)
|
||||||
|
{
|
||||||
|
if (mHeaderCompletionPopup)
|
||||||
|
mHeaderCompletionPopup->hide();
|
||||||
|
if (mCompletionPopup)
|
||||||
|
mCompletionPopup->hide();
|
||||||
|
if (pMainWindow->functionTip())
|
||||||
|
pMainWindow->functionTip()->hide();
|
||||||
|
}
|
||||||
|
|
||||||
void Editor::copyToClipboard()
|
void Editor::copyToClipboard()
|
||||||
{
|
{
|
||||||
if (pSettings->editor().copySizeLimit()) {
|
if (pSettings->editor().copySizeLimit()) {
|
||||||
|
|
|
@ -289,6 +289,10 @@ protected:
|
||||||
// QWidget interface
|
// QWidget interface
|
||||||
protected:
|
protected:
|
||||||
void inputMethodEvent(QInputMethodEvent *) override;
|
void inputMethodEvent(QInputMethodEvent *) override;
|
||||||
|
|
||||||
|
// QWidget interface
|
||||||
|
protected:
|
||||||
|
void closeEvent(QCloseEvent *event) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
QString getWordAtPosition(SynEdit* editor,
|
QString getWordAtPosition(SynEdit* editor,
|
||||||
|
|
|
@ -558,8 +558,8 @@ QSet<QString> CppParser::getFileUsings(const QString &filename)
|
||||||
QString CppParser::getHeaderFileName(const QString &relativeTo, const QString &line)
|
QString CppParser::getHeaderFileName(const QString &relativeTo, const QString &line)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&mMutex);
|
QMutexLocker locker(&mMutex);
|
||||||
return ::getHeaderFilename(relativeTo, line, mPreprocessor.includePaths(),
|
return ::getHeaderFilename(relativeTo, line, mPreprocessor.includePathList(),
|
||||||
mPreprocessor.projectIncludePaths());
|
mPreprocessor.projectIncludePathList());
|
||||||
}
|
}
|
||||||
|
|
||||||
StatementKind CppParser::getKindOfStatement(const PStatement& statement)
|
StatementKind CppParser::getKindOfStatement(const PStatement& statement)
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
CppPreprocessor::CppPreprocessor()
|
CppPreprocessor::CppPreprocessor()
|
||||||
{
|
{
|
||||||
|
@ -214,14 +215,18 @@ void CppPreprocessor::dumpIncludesListTo(const QString &fileName) const
|
||||||
|
|
||||||
void CppPreprocessor::addIncludePath(const QString &fileName)
|
void CppPreprocessor::addIncludePath(const QString &fileName)
|
||||||
{
|
{
|
||||||
mIncludePaths.insert(fileName);
|
if (!mIncludePaths.contains(fileName)) {
|
||||||
mIncludePathList.append(fileName);
|
mIncludePaths.insert(fileName);
|
||||||
|
mIncludePathList.append(fileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppPreprocessor::addProjectIncludePath(const QString &fileName)
|
void CppPreprocessor::addProjectIncludePath(const QString &fileName)
|
||||||
{
|
{
|
||||||
mProjectIncludePaths.insert(fileName);
|
if (!mProjectIncludePaths.contains(fileName)) {
|
||||||
mProjectIncludeList.append(fileName);
|
mProjectIncludePaths.insert(fileName);
|
||||||
|
mProjectIncludePathList.append(fileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppPreprocessor::clearIncludePaths()
|
void CppPreprocessor::clearIncludePaths()
|
||||||
|
@ -233,7 +238,7 @@ void CppPreprocessor::clearIncludePaths()
|
||||||
void CppPreprocessor::clearProjectIncludePaths()
|
void CppPreprocessor::clearProjectIncludePaths()
|
||||||
{
|
{
|
||||||
mProjectIncludePaths.clear();
|
mProjectIncludePaths.clear();
|
||||||
mProjectIncludeList.clear();
|
mProjectIncludePathList.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CppPreprocessor::getNextPreprocessor()
|
QString CppPreprocessor::getNextPreprocessor()
|
||||||
|
@ -356,28 +361,30 @@ void CppPreprocessor::handleInclude(const QString &line, bool fromNext)
|
||||||
QString fileName;
|
QString fileName;
|
||||||
// Get full header file name
|
// Get full header file name
|
||||||
QString currentDir = includeTrailingPathDelimiter(extractFileDir(file->fileName));
|
QString currentDir = includeTrailingPathDelimiter(extractFileDir(file->fileName));
|
||||||
QSet<QString> includes;
|
QStringList includes;
|
||||||
QSet<QString> projectIncludes;
|
QStringList projectIncludes;
|
||||||
if (fromNext && mIncludePaths.contains(currentDir)) {
|
bool found;
|
||||||
bool found = false;
|
if (fromNext && mIncludePaths.contains(currentDir))
|
||||||
foreach(const QString& s, mIncludePathList) {
|
found = false;
|
||||||
if (found)
|
else
|
||||||
includes.insert(s);
|
found = true;
|
||||||
if (s == currentDir)
|
foreach(const QString& s, mIncludePathList) {
|
||||||
found = true;
|
if (found) {
|
||||||
|
includes.append(s);
|
||||||
}
|
}
|
||||||
} else
|
if (s == currentDir)
|
||||||
includes = mIncludePaths;
|
found = true;
|
||||||
if (fromNext && mProjectIncludePaths.contains(currentDir)) {
|
}
|
||||||
bool found = false;
|
if (fromNext && mProjectIncludePaths.contains(currentDir))
|
||||||
foreach(const QString& s, mProjectIncludeList) {
|
found = false;
|
||||||
if (found)
|
else
|
||||||
projectIncludes.insert(s);
|
found = true;
|
||||||
if (s == currentDir)
|
foreach(const QString& s, mProjectIncludePathList) {
|
||||||
found = true;
|
if (found)
|
||||||
}
|
projectIncludes.append(s);
|
||||||
} else
|
if (s == currentDir)
|
||||||
projectIncludes = mProjectIncludePaths;
|
found = true;
|
||||||
|
}
|
||||||
fileName = getHeaderFilename(
|
fileName = getHeaderFilename(
|
||||||
file->fileName,
|
file->fileName,
|
||||||
line,
|
line,
|
||||||
|
@ -403,10 +410,10 @@ void CppPreprocessor::handlePreprocessor(const QString &value)
|
||||||
|| value.startsWith("else") || value.startsWith("elif")
|
|| value.startsWith("else") || value.startsWith("elif")
|
||||||
|| value.startsWith("endif"))
|
|| value.startsWith("endif"))
|
||||||
handleBranch(value);
|
handleBranch(value);
|
||||||
else if (value.startsWith("include"))
|
|
||||||
handleInclude(value);
|
|
||||||
else if (value.startsWith("include_next"))
|
else if (value.startsWith("include_next"))
|
||||||
handleInclude(value,true);
|
handleInclude(value,true);
|
||||||
|
else if (value.startsWith("include"))
|
||||||
|
handleInclude(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppPreprocessor::handleUndefine(const QString &line)
|
void CppPreprocessor::handleUndefine(const QString &line)
|
||||||
|
@ -1710,6 +1717,16 @@ int CppPreprocessor::evaluateExpression(QString line)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QList<QString> &CppPreprocessor::projectIncludePathList() const
|
||||||
|
{
|
||||||
|
return mProjectIncludePathList;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QList<QString> &CppPreprocessor::includePathList() const
|
||||||
|
{
|
||||||
|
return mIncludePathList;
|
||||||
|
}
|
||||||
|
|
||||||
const DefineMap &CppPreprocessor::hardDefines() const
|
const DefineMap &CppPreprocessor::hardDefines() const
|
||||||
{
|
{
|
||||||
return mHardDefines;
|
return mHardDefines;
|
||||||
|
|
|
@ -76,6 +76,10 @@ public:
|
||||||
|
|
||||||
const DefineMap &hardDefines() const;
|
const DefineMap &hardDefines() const;
|
||||||
|
|
||||||
|
const QList<QString> &includePathList() const;
|
||||||
|
|
||||||
|
const QList<QString> &projectIncludePathList() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -189,7 +193,7 @@ private:
|
||||||
QSet<QString> mProjectIncludePaths;
|
QSet<QString> mProjectIncludePaths;
|
||||||
//we also need include paths in order (for #include_next)
|
//we also need include paths in order (for #include_next)
|
||||||
QList<QString> mIncludePathList;
|
QList<QString> mIncludePathList;
|
||||||
QList<QString> mProjectIncludeList;
|
QList<QString> mProjectIncludePathList;
|
||||||
|
|
||||||
bool mParseSystem;
|
bool mParseSystem;
|
||||||
bool mParseLocal;
|
bool mParseLocal;
|
||||||
|
|
|
@ -294,7 +294,7 @@ void initParser()
|
||||||
}
|
}
|
||||||
|
|
||||||
QString getHeaderFilename(const QString &relativeTo, const QString &line,
|
QString getHeaderFilename(const QString &relativeTo, const QString &line,
|
||||||
const QSet<QString>& includePaths, const QSet<QString>& projectIncludePaths) {
|
const QStringList& includePaths, const QStringList& projectIncludePaths) {
|
||||||
QString result = "";
|
QString result = "";
|
||||||
|
|
||||||
// Handle <>
|
// Handle <>
|
||||||
|
@ -341,7 +341,7 @@ QString getLocalHeaderFilename(const QString &relativeTo, const QString &fileNam
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
QString getSystemHeaderFilename(const QString &fileName, const QSet<QString>& includePaths)
|
QString getSystemHeaderFilename(const QString &fileName, const QStringList& includePaths)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Search compiler include directories
|
// Search compiler include directories
|
||||||
|
|
|
@ -196,11 +196,11 @@ extern QSet<QString> STLElementMethods;
|
||||||
void initParser();
|
void initParser();
|
||||||
|
|
||||||
QString getHeaderFilename(const QString& relativeTo, const QString& line,
|
QString getHeaderFilename(const QString& relativeTo, const QString& line,
|
||||||
const QSet<QString>& includePaths, const QSet<QString>& projectIncludePaths);
|
const QStringList& includePaths, const QStringList& projectIncludePaths);
|
||||||
|
|
||||||
QString getLocalHeaderFilename(const QString& relativeTo, const QString& fileName);
|
QString getLocalHeaderFilename(const QString& relativeTo, const QString& fileName);
|
||||||
|
|
||||||
QString getSystemHeaderFilename(const QString& fileName, const QSet<QString>& includePaths);
|
QString getSystemHeaderFilename(const QString& fileName, const QStringList& includePaths);
|
||||||
bool isSystemHeaderFile(const QString& fileName, const QSet<QString>& includePaths);
|
bool isSystemHeaderFile(const QString& fileName, const QSet<QString>& includePaths);
|
||||||
bool isHfile(const QString& filename);
|
bool isHfile(const QString& filename);
|
||||||
bool isCfile(const QString& filename);
|
bool isCfile(const QString& filename);
|
||||||
|
|
|
@ -557,16 +557,16 @@ void resetCppParser(std::shared_ptr<CppParser> parser)
|
||||||
Settings::PCompilerSet compilerSet = pSettings->compilerSets().defaultSet();
|
Settings::PCompilerSet compilerSet = pSettings->compilerSets().defaultSet();
|
||||||
parser->clearIncludePaths();
|
parser->clearIncludePaths();
|
||||||
if (compilerSet) {
|
if (compilerSet) {
|
||||||
for (QString file:compilerSet->CIncludeDirs()) {
|
foreach (const QString& file,compilerSet->CppIncludeDirs()) {
|
||||||
parser->addIncludePath(file);
|
parser->addIncludePath(file);
|
||||||
}
|
}
|
||||||
for (QString file:compilerSet->CppIncludeDirs()) {
|
foreach (const QString& file,compilerSet->CIncludeDirs()) {
|
||||||
parser->addIncludePath(file);
|
parser->addIncludePath(file);
|
||||||
}
|
}
|
||||||
for (QString file:compilerSet->defaultCIncludeDirs()) {
|
foreach (const QString& file,compilerSet->defaultCppIncludeDirs()) {
|
||||||
parser->addIncludePath(file);
|
parser->addIncludePath(file);
|
||||||
}
|
}
|
||||||
for (QString file:compilerSet->defaultCppIncludeDirs()) {
|
foreach (const QString& file,compilerSet->defaultCIncludeDirs()) {
|
||||||
parser->addIncludePath(file);
|
parser->addIncludePath(file);
|
||||||
}
|
}
|
||||||
//TODO: Add default include dirs last, just like gcc does
|
//TODO: Add default include dirs last, just like gcc does
|
||||||
|
|
Loading…
Reference in New Issue