refactor: highlighter, work save

This commit is contained in:
Roy Qu 2022-11-23 12:51:23 +08:00
parent e352ef345c
commit b3a986f1ca
12 changed files with 57 additions and 242 deletions

View File

@ -17,6 +17,7 @@
#include "HighlighterManager.h"
#include <QFileInfo>
#include <QObject>
#include "qsynedit/Constants.h"
#include "qsynedit/highlighter/cpp.h"
#include "qsynedit/highlighter/asm.h"
#include "qsynedit/highlighter/glsl.h"
@ -79,68 +80,18 @@ QSynedit::PHighlighter HighlighterManager::copyHighlighter(QSynedit::PHighlighte
QSynedit::PHighlighter HighlighterManager::getCppHighlighter()
{
std::shared_ptr<QSynedit::CppHighlighter> highlighter = std::make_shared<QSynedit::CppHighlighter>();
highlighter->asmAttribute()->setForeground(Qt::blue);
highlighter->charAttribute()->setForeground(Qt::black);
highlighter->commentAttribute()->setForeground(0x8C8C8C);
highlighter->commentAttribute()->setStyles(QSynedit::FontStyle::fsItalic);
highlighter->classAttribute()->setForeground(0x008080);
highlighter->floatAttribute()->setForeground(Qt::darkMagenta);
highlighter->functionAttribute()->setForeground(0x00627A);
highlighter->globalVarAttribute()->setForeground(0x660E7A);
highlighter->hexAttribute()->setForeground(Qt::darkMagenta);
highlighter->identifierAttribute()->setForeground(0x080808);
highlighter->invalidAttribute()->setForeground(Qt::red);
highlighter->localVarAttribute()->setForeground(Qt::black);
highlighter->numberAttribute()->setForeground(0x1750EB);
highlighter->octAttribute()->setForeground(Qt::darkMagenta);
highlighter->preprocessorAttribute()->setForeground(0x1f542e);
highlighter->keywordAttribute()->setForeground(0x0033b3);
highlighter->whitespaceAttribute()->setForeground(Qt::lightGray);
highlighter->stringAttribute()->setForeground(0x007d17);
highlighter->stringEscapeSequenceAttribute()->setForeground(Qt::red);
highlighter->symbolAttribute()->setForeground(0xc10000);
highlighter->variableAttribute()->setForeground(0x400080);
return highlighter;
}
QSynedit::PHighlighter HighlighterManager::getAsmHighlighter()
{
std::shared_ptr<QSynedit::ASMHighlighter> highlighter=std::make_shared<QSynedit::ASMHighlighter>();
highlighter->commentAttribute()->setForeground(0x8C8C8C);
highlighter->commentAttribute()->setStyles(QSynedit::FontStyle::fsItalic);
highlighter->identifierAttribute()->setForeground(0x080808);
highlighter->keywordAttribute()->setForeground(0x0033b3);
highlighter->numberAttribute()->setForeground(0x1750EB);
highlighter->whitespaceAttribute()->setForeground(Qt::lightGray);
highlighter->stringAttribute()->setForeground(0x007d17);
highlighter->symbolAttribute()->setForeground(0xc10000);
return highlighter;
}
QSynedit::PHighlighter HighlighterManager::getGLSLHighlighter()
{
std::shared_ptr<QSynedit::GLSLHighlighter> highlighter=std::make_shared<QSynedit::GLSLHighlighter>();
highlighter->asmAttribute()->setForeground(Qt::blue);
highlighter->charAttribute()->setForeground(Qt::black);
highlighter->commentAttribute()->setForeground(0x8C8C8C);
highlighter->commentAttribute()->setStyles(QSynedit::FontStyle::fsItalic);
highlighter->classAttribute()->setForeground(0x008080);
highlighter->floatAttribute()->setForeground(Qt::darkMagenta);
highlighter->functionAttribute()->setForeground(0x00627A);
highlighter->globalVarAttribute()->setForeground(0x660E7A);
highlighter->hexAttribute()->setForeground(Qt::darkMagenta);
highlighter->identifierAttribute()->setForeground(0x080808);
highlighter->invalidAttribute()->setForeground(Qt::red);
highlighter->localVarAttribute()->setForeground(Qt::black);
highlighter->numberAttribute()->setForeground(0x1750EB);
highlighter->octAttribute()->setForeground(Qt::darkMagenta);
highlighter->preprocessorAttribute()->setForeground(0x1f542e);
highlighter->keywordAttribute()->setForeground(0x0033b3);
highlighter->whitespaceAttribute()->setForeground(Qt::lightGray);
highlighter->stringAttribute()->setForeground(0x007d17);
highlighter->stringEscapeSequenceAttribute()->setForeground(Qt::red);
highlighter->symbolAttribute()->setForeground(0xc10000);
highlighter->variableAttribute()->setForeground(0x400080);
return highlighter;
}

View File

@ -227,7 +227,7 @@ PSearchResultTreeItem CppRefacter::findOccurenceInFile(
int start = editor.highlighter()->getTokenPos() + 1;
QString token = editor.highlighter()->getToken();
QSynedit::PHighlighterAttribute attr = editor.highlighter()->getTokenAttribute();
if (!attr || attr!=editor.highlighter()->commentAttribute()) {
if (attr && attr->tokenType()==QSynedit::TokenType::Identifier) {
if (token == statement->command) {
//same name symbol , test if the same statement;
QSynedit::BufferCoord p;

View File

@ -972,7 +972,7 @@ void Editor::onPreparePaintHighlightToken(int line, int aChar, const QString &to
}
}
}
} else if (mParser->enabled() && attr == highlighter()->identifierAttribute()) {
} else if (mParser->enabled() && attr->tokenType() == QSynedit::TokenType::Identifier) {
QSynedit::BufferCoord p{aChar,line};
// BufferCoord pBeginPos,pEndPos;
// QString s= getWordAtPosition(this,p, pBeginPos,pEndPos, WordPurpose::wpInformation);
@ -1022,7 +1022,7 @@ void Editor::onPreparePaintHighlightToken(int line, int aChar, const QString &to
//selection
if (highlighter() && attr) {
if (attr == highlighter()->keywordAttribute()) {
if (attr->tokenType() == QSynedit::TokenType::Keyword) {
if (CppTypeKeywords.contains(token)
||
(
@ -1046,9 +1046,9 @@ void Editor::onPreparePaintHighlightToken(int line, int aChar, const QString &to
}
}
}
if (((attr == highlighter()->identifierAttribute())
|| (attr == highlighter()->keywordAttribute())
|| (attr->name() == SYNS_AttrPreprocessor)
if (((attr->tokenType() == QSynedit::TokenType::Identifier)
|| (attr->tokenType() == QSynedit::TokenType::Keyword)
|| (attr->tokenType() == QSynedit::TokenType::Preprocessor)
)
&& (token == mCurrentHighlightedWord)) {
if (mCurrentHighlighWordForeground.isValid())
@ -1710,7 +1710,7 @@ void Editor::onStatusChanged(QSynedit::StatusChanges changes)
QSynedit::PHighlighterAttribute attr;
QString token;
if (getHighlighterAttriAtRowCol(coord,token,attr)
&& attr == highlighter()->symbolAttribute()) {
&& attr->tokenType() == QSynedit::TokenType::Operator) {
QSynedit::BufferCoord complementCharPos = getMatchingBracketEx(coord);
if (!foldHidesLine(coord.line)
&& !foldHidesLine(complementCharPos.line)) {
@ -1961,11 +1961,13 @@ QStringList Editor::getExpressionAtPosition(
QSynedit::PHighlighterAttribute attr = highlighter->getTokenAttribute();
if ( (line == pos.line-1)
&& (start<=ch) && (ch<=endPos)) {
if (attr==highlighter->commentAttribute() || attr == highlighter->stringAttribute()) {
if (attr->tokenType() == QSynedit::TokenType::Comment
|| attr->tokenType() == QSynedit::TokenType::String) {
return result;
}
}
if (attr!=highlighter->commentAttribute() && attr!=highlighter->whitespaceAttribute()){
if (attr->tokenType() != QSynedit::TokenType::Comment
&& attr->tokenType() != QSynedit::TokenType::Space){
tokens.append(token);
}
highlighter->next();
@ -3744,8 +3746,8 @@ void Editor::updateFunctionTip(bool showTip)
if (start>=currentChar)
break;
if (attr != highlighter()->commentAttribute()
&& attr!=highlighter()->whitespaceAttribute()) {
if (attr->tokenType() != QSynedit::TokenType::Comment
&& attr->tokenType() != QSynedit::TokenType::Space) {
if (foundFunctionStart) {
if (attr!=highlighter()->identifierAttribute())
return; // not a function
@ -3755,7 +3757,7 @@ void Editor::updateFunctionTip(bool showTip)
}
tokens.append(token);
positions.append(start);
} else if (attr == highlighter()->commentAttribute()
} else if (attr->tokenType() == QSynedit::TokenType::Comment
&& currentLine == caretPos.line-1 && start<caretPos.ch
&& start+token.length()>=caretPos.ch) {
return; // in comment, do nothing

View File

@ -4594,8 +4594,7 @@ PStatement CppParser::doParseEvalTypeInfo(
pointerLevel++;
else if (token == "&")
pointerLevel--;
else if (highlighter.getTokenAttribute() == highlighter.identifierAttribute()) {
if (token!= "const")
else if (highlighter.getTokenAttribute()->tokenType() == QSynedit::TokenType::Identifier) {
baseType += token;
} else if (token == "[") {
pointerLevel++;

View File

@ -30,154 +30,29 @@ extern const QChar SoftBreakGlyph;
#define MAX_SCROLL 65535
#define SYN_ATTR_COMMENT 0
#define SYN_ATTR_IDENTIFIER 1
#define SYN_ATTR_KEYWORD 2
#define SYN_ATTR_STRING 3
#define SYN_ATTR_WHITESPACE 4
#define SYN_ATTR_SYMBOL 5
// names for highlighter attributes
#define SYNS_AttrAreaAIdentifier "Area A Identifier"
#define SYNS_AttrArrowHead "ArrowHead"
#define SYNS_AttrAsm "Asm"
#define SYNS_AttrAsmComment "Asm Comment"
#define SYNS_AttrAsmKey "Asm Key"
#define SYNS_AttrAssembler "Assembler"
#define SYNS_AttrAttribute "Attribute"
#define SYNS_AttrAttributeName "Attribute Name"
#define SYNS_AttrAttributeValue "Attribute Value"
#define SYNS_AttrBasicTypes "Basic Types"
#define SYNS_AttrBlock "Block"
#define SYNS_AttrBoolean "Boolean value"
#define SYNS_AttrBrackets "Brackets"
#define SYNS_AttrCDATASection "CDATA Section"
#define SYNS_AttrCharacter "Character"
#define SYNS_AttrClass "Class"
#define SYNS_AttrColor "Color Value"
#define SYNS_AttrComment "Comment"
#define SYNS_AttrCondition "Condition"
#define SYNS_AttrConditionalComment "Conditional Comment"
#define SYNS_AttrDataType "Data Type"
#define SYNS_AttrDebugLines "Debugging Lines"
#define SYNS_AttrDefaultPackage "Default Packages"
#define SYNS_AttrDelimitedIdentifier "Delimited Identifier"
#define SYNS_AttrDir "Direction"
#define SYNS_AttrDirections "Directions"
#define SYNS_AttrDirective "Directive"
#define SYNS_AttrDOCTYPESection "DOCTYPE Section"
#define SYNS_AttrDocumentation "Documentation"
#define SYNS_AttrElementName "Element Name"
#define SYNS_AttrEmbedSQL "Embedded SQL"
#define SYNS_AttrEmbedText "Embedded Text"
#define SYNS_AttrEntityReference "Entity Reference"
#define SYNS_AttrEscapeAmpersand "Escape Ampersand"
#define SYNS_AttrEvent "Event"
#define SYNS_AttrException "Exception"
#define SYNS_AttrFirstTri "FirstTri"
#define SYNS_AttrFloat "Float"
#define SYNS_AttrForm "Form"
#define SYNS_AttrFourthTri "FourthTri"
#define SYNS_AttrFunction "Function"
#define SYNS_AttrFunctionParameter "Function Parameter"
#define SYNS_AttrGlobalVariable "Global variable"
#define SYNS_AttrHexadecimal "Hexadecimal"
#define SYNS_AttrIcon "Icon Reference"
#define SYNS_AttrIdentifier "Identifier"
#define SYNS_AttrReserveWord_Type "Reserve Word for Types"
#define SYNS_AttrIllegalChar "Illegal Char"
#define SYNS_AttrInclude "Include"
#define SYNS_AttrIndicator "Indicator Area"
#define SYNS_AttrIndirect "Indirect"
#define SYNS_AttrInvalidSymbol "Invalid Symbol"
#define SYNS_AttrInternalFunction "Internal Function"
#define SYNS_AttrKey "Key"
#define SYNS_AttrLabel "Label"
#define SYNS_AttrLace "Lace"
#define SYNS_AttrLocalVariable "Local Variable"
#define SYNS_AttrLine "Line"
#define SYNS_AttrMacro "Macro"
#define SYNS_AttrMarker "Marker"
#define SYNS_AttrMathMode "Math Mode"
#define SYNS_AttrMessage "Message"
#define SYNS_AttrMiscellaneous "Miscellaneous"
#define SYNS_AttrNamespaceAttrName "Namespace Attribute Name"
#define SYNS_AttrNamespaceAttrValue "Namespace Attribute Value"
#define SYNS_AttrNonReservedKeyword "Non-reserved Keyword"
#define SYNS_AttrNull "Null"
#define SYNS_AttrNumber "Number"
#define SYNS_AttrOctal "Octal"
#define SYNS_AttrOperator "Operator"
#define SYNS_AttrOperatorAndSymbols "Operator And Symbols"
#define SYNS_AttrOpLine "OpLine"
#define SYNS_AttrPLSQL "PL/SQL Reserved Word"
#define SYNS_AttrPragma "Pragma"
#define SYNS_AttrPredefined "Predefined"
#define SYNS_AttrPreprocessor "Preprocessor"
#define SYNS_AttrProcessingInstr "Processing Instruction"
#define SYNS_AttrQuad "Quad"
#define SYNS_AttrQualifier "Qualifier"
#define SYNS_AttrRegister "Register"
#define SYNS_AttrReservedWord "Reserved Word"
#define SYNS_AttrResultValue "Result Value"
#define SYNS_AttrRoundBracket "Round Bracket"
#define SYNS_AttrRpl "Rpl"
#define SYNS_AttrRplKey "Rpl Key"
#define SYNS_AttrRplComment "Rpl Comment"
#define SYNS_AttrSASM "SASM"
#define SYNS_AttrSASMComment "SASM Comment"
#define SYNS_AttrSASMKey "SASM Key"
#define SYNS_AttrSecondReservedWord "Second Reserved Word"
#define SYNS_AttrSecondTri "SecondTri"
#define SYNS_AttrSection "Section"
#define SYNS_AttrSequence "Sequence Number Area"
#define SYNS_AttrShape "Shape"
#define SYNS_AttrSingleString "Single Quoted String"
#define SYNS_AttrSpace "Space"
#define SYNS_AttrSpecialVariable "Special Variable"
#define SYNS_AttrSQLKey "SQL Keyword"
#define SYNS_AttrSQLPlus "SQL*Plus Command"
#define SYNS_AttrSquareBracket "Square Bracket"
#define SYNS_AttrString "String"
#define SYNS_AttrStringEscapeSequences "Escape sequences"
#define SYNS_AttrSymbol "Symbol"
#define SYNS_AttrSyntaxError "Syntax Error"
#define SYNS_AttrSystem "System Functions and Variables"
#define SYNS_AttrSystemValue "System Value"
#define SYNS_AttrTagArea "Tag Area"
#define SYNS_AttrTableName "Table Name"
#define SYNS_AttrTerminator "Terminator"
#define SYNS_AttrTeXCommand "TeX Command"
#define SYNS_AttrText "Text"
#define SYNS_AttrTextMathMode "Text in Math Mode"
#define SYNS_AttrThirdTri "ThirdTri"
#define SYNS_AttrTriangle "Triangle"
#define SYNS_AttrUnknownWord "Unknown Word"
#define SYNS_AttrURI "URI"
#define SYNS_AttrUser "User Functions and Variables"
#define SYNS_AttrUserFunction "User Functions"
#define SYNS_AttrValue "Value"
#define SYNS_AttrVariable "Variable"
#define SYNS_AttrVisitedURI "Visited URI"
#define SYNS_AttrVrmlAppearance "Vrml_Appearance"
#define SYNS_AttrVrmlAttribute "Vrml_Attribute"
#define SYNS_AttrVrmlDefinition "Vrml_Definition"
#define SYNS_AttrVrmlEvent "Vrml_Event"
#define SYNS_AttrVrmlGrouping "Vrml_Grouping"
#define SYNS_AttrVrmlInterpolator "Vrml_Interpolator"
#define SYNS_AttrVrmlLight "Vrml_Light"
#define SYNS_AttrVrmlNode "Vrml_Node"
#define SYNS_AttrVrmlParameter "Vrml_Parameter"
#define SYNS_AttrVrmlProto "Vrml_Proto"
#define SYNS_AttrVrmlSensor "Vrml_Sensor"
#define SYNS_AttrVrmlShape "Vrml_Shape"
#define SYNS_AttrVrmlShape_Hint "Vrml_Shape_Hint"
#define SYNS_AttrVrmlTime_dependent "Vrml_Time_dependent"
#define SYNS_AttrVrmlViewpoint "Vrml_Viewpoint"
#define SYNS_AttrVrmlWorldInfo "Vrml_WorldInfo"
#define SYNS_AttrWhitespace "Whitespace"
#define SYNS_AttrX3DDocType "X3DDocType"
#define SYNS_AttrX3DHeader "X3DHeader"
#define SYNS_AttrSpace "Space"
// names of exporter output formats
#define SYNS_ExporterFormatHTML "HTML"
#define SYNS_ExporterFormatRTF "RTF"

View File

@ -518,9 +518,9 @@ BufferCoord SynEdit::getMatchingBracketEx(BufferCoord APoint)
isCommentOrStringOrChar = false;
if (getHighlighterAttriAtRowCol(p, vDummy, attr))
isCommentOrStringOrChar =
(attr == mHighlighter->stringAttribute()) ||
(attr == mHighlighter->commentAttribute()) ||
(attr->name() == SYNS_AttrCharacter);
(attr->tokenType() == TokenType::String) ||
(attr->tokenType() == TokenType::Comment) ||
(attr->tokenType() == TokenType::Character);
if ((Test == BracketInc) && (!isCommentOrStringOrChar))
NumBrackets++;
else if ((Test == BracketDec) && (!isCommentOrStringOrChar)) {
@ -552,9 +552,9 @@ BufferCoord SynEdit::getMatchingBracketEx(BufferCoord APoint)
isCommentOrStringOrChar = false;
if (getHighlighterAttriAtRowCol(p, vDummy, attr))
isCommentOrStringOrChar =
(attr == mHighlighter->stringAttribute()) ||
(attr == mHighlighter->commentAttribute()) ||
(attr->name() == SYNS_AttrCharacter);
(attr->tokenType() == TokenType::String) ||
(attr->tokenType() == TokenType::Comment) ||
(attr->tokenType() == TokenType::Character);
else
isCommentOrStringOrChar = false;
if ((Test == BracketInc) && (!isCommentOrStringOrChar))
@ -1294,9 +1294,9 @@ BufferCoord SynEdit::getPreviousLeftBrace(int x, int y)
if (Test=='{' || Test == '}') {
if (getHighlighterAttriAtRowCol(p, vDummy, attr)) {
isCommentOrStringOrChar =
(attr == mHighlighter->stringAttribute()) ||
(attr == mHighlighter->commentAttribute()) ||
(attr->name() == SYNS_AttrCharacter);
(attr->tokenType() == TokenType::String) ||
(attr->tokenType() == TokenType::Comment) ||
(attr->tokenType() == TokenType::Character);
} else
isCommentOrStringOrChar = false;
if ((Test == '{') && (! isCommentOrStringOrChar))
@ -1588,7 +1588,7 @@ int SynEdit::calcIndentSpaces(int line, const QString& lineText, bool addIndent)
HighlighterState rangeAfterFirstToken = mHighlighter->getState();
QString firstToken = mHighlighter->getToken();
PHighlighterAttribute attr = mHighlighter->getTokenAttribute();
if (attr == mHighlighter->keywordAttribute()
if (attr->tokenType() == TokenType::Keyword
&& lineText.endsWith(':')
&& (
firstToken == "public" || firstToken == "private"
@ -1606,13 +1606,13 @@ int SynEdit::calcIndentSpaces(int line, const QString& lineText, bool addIndent)
int additionIndent = 0;
QVector<int> matchingIndents;
int l;
if (attr == mHighlighter->symbolAttribute()
if (attr->tokenType() == TokenType::Operator
&& (firstToken == '}')) {
// current line starts with '}', we should consider it to calc indents
matchingIndents = rangeAfterFirstToken.matchingIndents;
indentAdded = true;
l = startLine;
} else if (attr == mHighlighter->symbolAttribute()
} else if (attr->tokenType() == TokenType::Operator
&& (firstToken == '{')
&& (rangePreceeding.getLastIndent()==sitStatement)) {
// current line starts with '{' and last statement not finished, we should consider it to calc indents
@ -1724,7 +1724,7 @@ int SynEdit::calcIndentSpaces(int line, const QString& lineText, bool addIndent)
coord.line = startLine;
coord.ch = document()->getString(startLine-1).length();
if (getHighlighterAttriAtRowCol(coord,token,attr)
&& attr == mHighlighter->symbolAttribute()
&& attr->tokenType() == QSynedit::TokenType::Operator
&& token == ":") {
indentSpaces += tabWidth();
indentAdded = true;

View File

@ -766,7 +766,7 @@ void SynEditTextPainter::getBraceColorAttr(int level, PHighlighterAttribute &att
{
if (!edit->mOptions.testFlag(EditorOption::eoShowRainbowColor))
return;
if (attr != edit->mHighlighter->symbolAttribute())
if (!attr || attr->tokenType() != TokenType::Operator)
return;
PHighlighterAttribute oldAttr = attr;
switch(level % 4) {

View File

@ -57,22 +57,8 @@ const QSet<QString> ASMHighlighter::Keywords {
ASMHighlighter::ASMHighlighter()
{
mCommentAttribute = std::make_shared<HighlighterAttribute>(SYNS_AttrComment, TokenType::Comment);
mCommentAttribute->setStyles(FontStyle::fsItalic);
addAttribute(mCommentAttribute);
mIdentifierAttribute = std::make_shared<HighlighterAttribute>(SYNS_AttrIdentifier, TokenType::Identifier);
addAttribute(mIdentifierAttribute);
mKeywordAttribute = std::make_shared<HighlighterAttribute>(SYNS_AttrReservedWord, TokenType::Keyword);
mKeywordAttribute->setStyles(FontStyle::fsBold);
addAttribute(mKeywordAttribute);
mNumberAttribute = std::make_shared<HighlighterAttribute>(SYNS_AttrNumber, TokenType::Number);
addAttribute(mNumberAttribute);
mWhitespaceAttribute = std::make_shared<HighlighterAttribute>(SYNS_AttrSpace, TokenType::Space);
addAttribute(mWhitespaceAttribute);
mStringAttribute = std::make_shared<HighlighterAttribute>(SYNS_AttrString, TokenType::String);
addAttribute(mStringAttribute);
mSymbolAttribute = std::make_shared<HighlighterAttribute>(SYNS_AttrSymbol, TokenType::Operator);
addAttribute(mSymbolAttribute);
}
PHighlighterAttribute ASMHighlighter::numberAttribute()

View File

@ -22,7 +22,24 @@ Highlighter::Highlighter() :
mEnabled(true),
mWordBreakChars{ WordBreakChars }
{
mCommentAttribute = std::make_shared<HighlighterAttribute>(SYNS_AttrComment,
TokenType::Comment);
addAttribute(mCommentAttribute);
mIdentifierAttribute = std::make_shared<HighlighterAttribute>(SYNS_AttrIdentifier,
TokenType::Identifier);
addAttribute(mIdentifierAttribute);
mKeywordAttribute = std::make_shared<HighlighterAttribute>(SYNS_AttrReservedWord,
TokenType::Keyword);
addAttribute(mKeywordAttribute);
mStringAttribute = std::make_shared<HighlighterAttribute>(SYNS_AttrString,
TokenType::String);
addAttribute(mStringAttribute);
mWhitespaceAttribute = std::make_shared<HighlighterAttribute>(SYNS_AttrSpace,
TokenType::Space);
addAttribute(mWhitespaceAttribute);
mSymbolAttribute = std::make_shared<HighlighterAttribute>(SYNS_AttrSymbol,
TokenType::Operator);
addAttribute(mSymbolAttribute);
}
const QMap<QString, PHighlighterAttribute>& Highlighter::attributes() const
@ -35,11 +52,6 @@ const QSet<QChar>& Highlighter::wordBreakChars() const
return mWordBreakChars;
}
PHighlighterAttribute Highlighter::commentAttribute() const
{
return mCommentAttribute;
}
PHighlighterAttribute Highlighter::identifierAttribute() const
{
return mIdentifierAttribute;
@ -50,6 +62,11 @@ PHighlighterAttribute Highlighter::keywordAttribute() const
return mKeywordAttribute;
}
PHighlighterAttribute Highlighter::commentAttribute() const
{
return mCommentAttribute;
}
PHighlighterAttribute Highlighter::stringAttribute() const
{
return mStringAttribute;

View File

@ -124,13 +124,12 @@ public:
const QSet<QChar>& wordBreakChars() const;
PHighlighterAttribute commentAttribute() const;
PHighlighterAttribute identifierAttribute() const;
PHighlighterAttribute keywordAttribute() const;
PHighlighterAttribute commentAttribute() const;
PHighlighterAttribute stringAttribute() const;
PHighlighterAttribute whitespaceAttribute() const;

View File

@ -165,9 +165,6 @@ CppHighlighter::CppHighlighter(): Highlighter()
mHexAttribute = std::make_shared<HighlighterAttribute>(SYNS_AttrHexadecimal,
TokenType::Number);
addAttribute(mHexAttribute);
mIdentifierAttribute = std::make_shared<HighlighterAttribute>(SYNS_AttrIdentifier,
TokenType::Identifier);
addAttribute(mIdentifierAttribute);
mInvalidAttribute = std::make_shared<HighlighterAttribute>(SYNS_AttrIllegalChar,
TokenType::Error);
addAttribute(mInvalidAttribute);
@ -184,10 +181,6 @@ CppHighlighter::CppHighlighter(): Highlighter()
TokenType::Preprocessor);
addAttribute(mPreprocessorAttribute);
mKeywordAttribute = std::make_shared<HighlighterAttribute>(SYNS_AttrReservedWord,
TokenType::Keyword);
addAttribute(mKeywordAttribute);
mStringEscapeSequenceAttribute = std::make_shared<HighlighterAttribute>(SYNS_AttrStringEscapeSequences,
TokenType::String);
addAttribute(mStringEscapeSequenceAttribute);

View File

@ -105,9 +105,6 @@ GLSLHighlighter::GLSLHighlighter(): Highlighter()
mHexAttribute = std::make_shared<HighlighterAttribute>(SYNS_AttrHexadecimal,
TokenType::Number);
addAttribute(mHexAttribute);
mIdentifierAttribute = std::make_shared<HighlighterAttribute>(SYNS_AttrIdentifier,
TokenType::Identifier);
addAttribute(mIdentifierAttribute);
mInvalidAttribute = std::make_shared<HighlighterAttribute>(SYNS_AttrIllegalChar,
TokenType::Error);
addAttribute(mInvalidAttribute);
@ -124,10 +121,6 @@ GLSLHighlighter::GLSLHighlighter(): Highlighter()
TokenType::Preprocessor);
addAttribute(mPreprocessorAttribute);
mKeywordAttribute = std::make_shared<HighlighterAttribute>(SYNS_AttrReservedWord,
TokenType::Keyword);
addAttribute(mKeywordAttribute);
mStringEscapeSequenceAttribute = std::make_shared<HighlighterAttribute>(SYNS_AttrStringEscapeSequences,
TokenType::String);
addAttribute(mStringEscapeSequenceAttribute);