- enhancement: use expression processing in syntax highlighting for identifiers
- fix: if a function's declaration can't be found, it will be wrongly highlighted as variable
This commit is contained in:
parent
2a84679f7c
commit
44d5453263
2
NEWS.md
2
NEWS.md
|
@ -22,6 +22,8 @@ Red Panda C++ Version 0.14.5
|
|||
- fix: crash when open a project that contains custom folder
|
||||
- enhancement: symbol completion when editor has selection
|
||||
- fix: save project's layout shouldn't modify the project file
|
||||
- enhancement: use expression processing in syntax highlighting for identifiers
|
||||
- fix: if a function's declaration can't be found, it will be wrongly highlighted as variable
|
||||
|
||||
Red Panda C++ Version 0.14.4
|
||||
- enhancement: git - log
|
||||
|
|
|
@ -887,17 +887,24 @@ void Editor::onPreparePaintHighlightToken(int line, int aChar, const QString &to
|
|||
|
||||
if (mParser && highlighter() && (attr == highlighter()->identifierAttribute())) {
|
||||
BufferCoord p{aChar,line};
|
||||
BufferCoord pBeginPos,pEndPos;
|
||||
QString s= getWordAtPosition(this,p, pBeginPos,pEndPos, WordPurpose::wpInformation);
|
||||
// BufferCoord pBeginPos,pEndPos;
|
||||
// QString s= getWordAtPosition(this,p, pBeginPos,pEndPos, WordPurpose::wpInformation);
|
||||
// qDebug()<<s;
|
||||
PStatement statement = mParser->findStatementOf(mFilename,
|
||||
s , p.Line);
|
||||
// PStatement statement = mParser->findStatementOf(mFilename,
|
||||
// s , p.Line);
|
||||
QStringList expression = getExpressionAtPosition(p);
|
||||
PStatement statement = parser()->findStatementOf(
|
||||
filename(),
|
||||
expression,
|
||||
p.Line);
|
||||
StatementKind kind = getKindOfStatement(statement);
|
||||
if (kind == StatementKind::skUnknown) {
|
||||
BufferCoord pBeginPos,pEndPos;
|
||||
QString s= getWordAtPosition(this,p, pBeginPos,pEndPos, WordPurpose::wpInformation);
|
||||
if ((pEndPos.Line>=1)
|
||||
&& (pEndPos.Char>=0)
|
||||
&& (pEndPos.Char < lines()->getString(pEndPos.Line-1).length())
|
||||
&& (lines()->getString(pEndPos.Line-1)[pEndPos.Char] == '(')) {
|
||||
&& (pEndPos.Char+1 < lines()->getString(pEndPos.Line-1).length())
|
||||
&& (lines()->getString(pEndPos.Line-1)[pEndPos.Char+1] == '(')) {
|
||||
kind = StatementKind::skFunction;
|
||||
} else {
|
||||
kind = StatementKind::skVariable;
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
QStringList CppDirectives;
|
||||
QStringList JavadocTags;
|
||||
QMap<QString,SkipType> CppKeywords;
|
||||
QSet<QString> CppControlKeyWords;
|
||||
QSet<QString> CppTypeKeywords;
|
||||
QSet<QString> CKeywords;
|
||||
QSet<QString> STLPointers;
|
||||
|
@ -239,6 +240,10 @@ void initParser()
|
|||
CKeywords.insert("volatile");
|
||||
CKeywords.insert("while");
|
||||
|
||||
CppControlKeyWords.insert("for");
|
||||
CppControlKeyWords.insert("if");
|
||||
CppControlKeyWords.insert("catch");
|
||||
|
||||
//STL Containers
|
||||
STLContainers.insert("std::array");
|
||||
STLContainers.insert("std::vector");
|
||||
|
@ -621,3 +626,8 @@ bool isCppFile(const QString &filename)
|
|||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isCppControlKeyword(const QString &word)
|
||||
{
|
||||
return CppControlKeyWords.contains(word);
|
||||
}
|
||||
|
|
|
@ -248,6 +248,7 @@ using PFileIncludes = std::shared_ptr<FileIncludes>;
|
|||
extern QStringList CppDirectives;
|
||||
extern QStringList JavadocTags;
|
||||
extern QMap<QString,SkipType> CppKeywords;
|
||||
extern QSet<QString> CppControlKeyWords;
|
||||
extern QSet<QString> CKeywords;
|
||||
extern QSet<QString> CppTypeKeywords;
|
||||
extern QSet<QString> STLPointers;
|
||||
|
@ -268,6 +269,7 @@ bool isHFile(const QString& filename);
|
|||
bool isCFile(const QString& filename);
|
||||
bool isCppFile(const QString& filename);
|
||||
bool isCppKeyword(const QString& word);
|
||||
bool isCppControlKeyword(const QString& word);
|
||||
bool isScopeTypeKind(StatementKind kind);
|
||||
MemberOperatorType getOperatorType(const QString& phrase, int index);
|
||||
QStringList getOwnerExpressionAndMember(
|
||||
|
|
Loading…
Reference in New Issue