- enhancement: False branches are displayed as comments.
This commit is contained in:
parent
d720421830
commit
dd5640d334
1
NEWS.md
1
NEWS.md
|
@ -32,6 +32,7 @@ Red Panda C++ Version 2.24
|
||||||
- fix: Press up/down arrow key in the option dialog's left panel won't switch page.
|
- fix: Press up/down arrow key in the option dialog's left panel won't switch page.
|
||||||
- fix: Can't suggest header filename starting with numbers.
|
- fix: Can't suggest header filename starting with numbers.
|
||||||
- enhancement: Better layout for compiler options page.
|
- enhancement: Better layout for compiler options page.
|
||||||
|
- enhancement: False branches are displayed as comments.
|
||||||
|
|
||||||
Red Panda C++ Version 2.23
|
Red Panda C++ Version 2.23
|
||||||
|
|
||||||
|
|
|
@ -1136,6 +1136,13 @@ void Editor::onPreparePaintHighlightToken(int line, int aChar, const QString &to
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (mParser && syntaxer()) {
|
if (mParser && syntaxer()) {
|
||||||
|
if (!mParser->isLineVisible(mFilename, line)) {
|
||||||
|
if (syntaxer()->commentAttribute()->foreground().isValid())
|
||||||
|
foreground = syntaxer()->commentAttribute()->foreground();
|
||||||
|
if (syntaxer()->commentAttribute()->background().isValid())
|
||||||
|
background = syntaxer()->commentAttribute()->background();
|
||||||
|
return;
|
||||||
|
}
|
||||||
QString lineText = document()->getLine(line-1);
|
QString lineText = document()->getLine(line-1);
|
||||||
if (mParser->isIncludeLine(lineText)) {
|
if (mParser->isIncludeLine(lineText)) {
|
||||||
if (cursor() == Qt::PointingHandCursor) {
|
if (cursor() == Qt::PointingHandCursor) {
|
||||||
|
|
|
@ -849,7 +849,16 @@ QString CppParser::getHeaderFileName(const QString &relativeTo, const QString &h
|
||||||
projectIncludes = mPreprocessor.projectIncludePathList();
|
projectIncludes = mPreprocessor.projectIncludePathList();
|
||||||
}
|
}
|
||||||
return ::getHeaderFilename(relativeTo, headerName, includes,
|
return ::getHeaderFilename(relativeTo, headerName, includes,
|
||||||
projectIncludes);
|
projectIncludes);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CppParser::isLineVisible(const QString &fileName, int line)
|
||||||
|
{
|
||||||
|
QMutexLocker locker(&mMutex);
|
||||||
|
PFileIncludes fileIncludes = mPreprocessor.includesList().value(fileName);
|
||||||
|
if (!fileIncludes)
|
||||||
|
return true;
|
||||||
|
return fileIncludes->isLineVisible(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppParser::invalidateFile(const QString &fileName)
|
void CppParser::invalidateFile(const QString &fileName)
|
||||||
|
|
|
@ -104,6 +104,7 @@ public:
|
||||||
QString getHeaderFileName(const QString& relativeTo, const QString& headerName, bool fromNext=false);// both
|
QString getHeaderFileName(const QString& relativeTo, const QString& headerName, bool fromNext=false);// both
|
||||||
|
|
||||||
void invalidateFile(const QString& fileName);
|
void invalidateFile(const QString& fileName);
|
||||||
|
bool isLineVisible(const QString& fileName, int line);
|
||||||
bool isIncludeLine(const QString &line);
|
bool isIncludeLine(const QString &line);
|
||||||
bool isIncludeNextLine(const QString &line);
|
bool isIncludeNextLine(const QString &line);
|
||||||
bool isProjectHeaderFile(const QString& fileName);
|
bool isProjectHeaderFile(const QString& fileName);
|
||||||
|
|
|
@ -137,11 +137,19 @@ private:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
void setCurrentBranch(bool value){
|
void setCurrentBranch(bool value){
|
||||||
|
if (value!=getCurrentBranch()) {
|
||||||
|
mCurrentIncludes->branches.insert(mIndex+1,value);
|
||||||
|
}
|
||||||
mBranchResults.append(value);
|
mBranchResults.append(value);
|
||||||
}
|
}
|
||||||
void removeCurrentBranch(){
|
void removeCurrentBranch(){
|
||||||
if (mBranchResults.size()>0)
|
bool result = getCurrentBranch();
|
||||||
|
if (mBranchResults.size()>0) {
|
||||||
mBranchResults.pop_back();
|
mBranchResults.pop_back();
|
||||||
|
}
|
||||||
|
if (getCurrentBranch()!=result) {
|
||||||
|
mCurrentIncludes->branches.insert(mIndex,getCurrentBranch());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
// include stuff
|
// include stuff
|
||||||
PFileIncludes getFileIncludesEntry(const QString& fileName){
|
PFileIncludes getFileIncludesEntry(const QString& fileName){
|
||||||
|
|
|
@ -765,3 +765,15 @@ bool isTypeKind(StatementKind kind)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FileIncludes::isLineVisible(int line)
|
||||||
|
{
|
||||||
|
int lastI=-1;
|
||||||
|
foreach(int i,branches.keys()) {
|
||||||
|
if (line<i)
|
||||||
|
break;
|
||||||
|
else
|
||||||
|
lastI = i;
|
||||||
|
}
|
||||||
|
return lastI<0?true:branches[lastI];
|
||||||
|
}
|
||||||
|
|
|
@ -300,6 +300,8 @@ struct FileIncludes {
|
||||||
StatementMap statements; // but we don't save temporary statements (full name as key)
|
StatementMap statements; // but we don't save temporary statements (full name as key)
|
||||||
StatementMap declaredStatements; // statements declared in this file (full name as key)
|
StatementMap declaredStatements; // statements declared in this file (full name as key)
|
||||||
CppScopes scopes; // int is start line of the statement scope
|
CppScopes scopes; // int is start line of the statement scope
|
||||||
|
QMap<int,bool> branches;
|
||||||
|
bool isLineVisible(int line);
|
||||||
};
|
};
|
||||||
using PFileIncludes = std::shared_ptr<FileIncludes>;
|
using PFileIncludes = std::shared_ptr<FileIncludes>;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue