diff options
author | Noel Grandin <noel@peralex.com> | 2016-02-24 10:11:43 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2016-02-24 11:48:39 +0200 |
commit | a5e53f9ffdde320a7ba104a1e01b3f5ef75d7975 (patch) | |
tree | 49ebc3303916da8298183808630464a4c0ce00d8 | |
parent | 2f9d53df89614955215a630beb0966f0c4a663c2 (diff) |
convert TokenTypes to scoped enum
Change-Id: I17c0a616dd6cf48a22896b6cd6b0df157d1f9a9f
-rw-r--r-- | basctl/source/basicide/baside2.cxx | 30 | ||||
-rw-r--r-- | basctl/source/basicide/baside2.hxx | 9 | ||||
-rw-r--r-- | basctl/source/basicide/baside2b.cxx | 18 | ||||
-rw-r--r-- | comphelper/qa/unit/syntaxhighlighttest.cxx | 19 | ||||
-rw-r--r-- | comphelper/source/misc/syntaxhighlight.cxx | 50 | ||||
-rw-r--r-- | helpcompiler/inc/BasCodeTagger.hxx | 2 | ||||
-rw-r--r-- | helpcompiler/source/BasCodeTagger.cxx | 26 | ||||
-rw-r--r-- | include/comphelper/syntaxhighlight.hxx | 30 | ||||
-rw-r--r-- | include/svtools/editsyntaxhighlighter.hxx | 2 | ||||
-rw-r--r-- | svtools/source/edit/editsyntaxhighlighter.cxx | 30 |
10 files changed, 111 insertions, 105 deletions
diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx index bc8072cf2bf9..38b804396d5c 100644 --- a/basctl/source/basicide/baside2.cxx +++ b/basctl/source/basicide/baside2.cxx @@ -1512,9 +1512,9 @@ ModulWindowLayout::SyntaxColors::SyntaxColors () : { aConfig.AddListener(this); - aColors[TT_UNKNOWN] = - aColors[TT_WHITESPACE] = - aColors[TT_EOL] = + aColors[TokenType::Unknown] = + aColors[TokenType::Whitespace] = + aColors[TokenType::EOL] = Application::GetSettings().GetStyleSettings().GetFieldTextColor(); NewConfig(true); @@ -1528,11 +1528,11 @@ ModulWindowLayout::SyntaxColors::~SyntaxColors () void ModulWindowLayout::SyntaxColors::SettingsChanged () { Color const aColor = Application::GetSettings().GetStyleSettings().GetFieldTextColor(); - if (aColor != aColors[TT_UNKNOWN]) + if (aColor != aColors[TokenType::Unknown]) { - aColors[TT_UNKNOWN] = - aColors[TT_WHITESPACE] = - aColors[TT_EOL] = + aColors[TokenType::Unknown] = + aColors[TokenType::Whitespace] = + aColors[TokenType::EOL] = aColor; if (pEditor) pEditor->UpdateSyntaxHighlighting(); @@ -1550,18 +1550,18 @@ void ModulWindowLayout::SyntaxColors::NewConfig (bool bFirst) { static struct { - TokenTypes eTokenType; + TokenType eTokenType; svtools::ColorConfigEntry eEntry; } const vIds[] = { - { TT_IDENTIFIER, svtools::BASICIDENTIFIER }, - { TT_NUMBER, svtools::BASICNUMBER }, - { TT_STRING, svtools::BASICSTRING }, - { TT_COMMENT, svtools::BASICCOMMENT }, - { TT_ERROR, svtools::BASICERROR }, - { TT_OPERATOR, svtools::BASICOPERATOR }, - { TT_KEYWORDS, svtools::BASICKEYWORD }, + { TokenType::Identifier, svtools::BASICIDENTIFIER }, + { TokenType::Number, svtools::BASICNUMBER }, + { TokenType::String, svtools::BASICSTRING }, + { TokenType::Comment, svtools::BASICCOMMENT }, + { TokenType::Error, svtools::BASICERROR }, + { TokenType::Operator, svtools::BASICOPERATOR }, + { TokenType::Keywords, svtools::BASICKEYWORD }, }; bool bChanged = false; diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx index 9e66970dae85..996579a34aa8 100644 --- a/basctl/source/basicide/baside2.hxx +++ b/basctl/source/basicide/baside2.hxx @@ -38,6 +38,7 @@ class SvxSearchItem; #include <vcl/idle.hxx> #include <sfx2/progress.hxx> +#include <o3tl/enumarray.hxx> #include <set> @@ -428,7 +429,7 @@ public: public: void BasicAddWatch (OUString const&); void BasicRemoveWatch (); - Color GetSyntaxColor (TokenTypes eType) const { return aSyntaxColors.GetColor(eType); } + Color GetSyntaxColor (TokenType eType) const { return aSyntaxColors.GetColor(eType); } protected: // Window: @@ -456,15 +457,15 @@ private: void SetActiveEditor (EditorWindow* pEditor_) { pEditor = pEditor_; } void SettingsChanged (); public: - Color GetColor (TokenTypes eType) const { return aColors[eType]; } + Color GetColor (TokenType eType) const { return aColors[eType]; } private: virtual void ConfigurationChanged (utl::ConfigurationBroadcaster*, sal_uInt32) override; void NewConfig (bool bFirst); private: - // the color values (the indexes are TokenTypes, see comphelper/syntaxhighlight.hxx) - Color aColors[TT_KEYWORDS + 1]; + // the color values (the indexes are TokenType, see comphelper/syntaxhighlight.hxx) + o3tl::enumarray<TokenType, Color> aColors; // the configuration svtools::ColorConfig aConfig; // the active editor diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx index 70f6e7324ef5..26ecbdcc6504 100644 --- a/basctl/source/basicide/baside2b.cxx +++ b/basctl/source/basicide/baside2b.cxx @@ -622,7 +622,7 @@ void EditorWindow::HandleAutoCorrect() OUString sStr = aLine.copy( r.nBegin, r.nEnd - r.nBegin ); //if WS or empty string: stop, nothing to do - if( ( r.tokenType == TT_WHITESPACE ) || sStr.isEmpty() ) + if( ( r.tokenType == TokenType::Whitespace ) || sStr.isEmpty() ) return; //create the appropriate TextSelection, and update the cache TextPaM aStart( nLine, r.nBegin ); @@ -631,7 +631,7 @@ void EditorWindow::HandleAutoCorrect() rModulWindow.UpdateModule(); rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse( aCodeCompleteCache ); // correct the last entered keyword - if( r.tokenType == TT_KEYWORDS ) + if( r.tokenType == TokenType::Keywords ) { sStr = sStr.toAsciiLowerCase(); if( !SbModule::GetKeywordCase(sStr).isEmpty() ) @@ -644,7 +644,7 @@ void EditorWindow::HandleAutoCorrect() pEditEngine->ReplaceText( sTextSelection, sStr ); pEditView->SetSelection( aSel ); } - if( r.tokenType == TT_IDENTIFIER ) + if( r.tokenType == TokenType::Identifier ) {// correct variables if( !aCodeCompleteCache.GetCorrectCaseVarName( sStr, sActSubName ).isEmpty() ) { @@ -729,7 +729,7 @@ void EditorWindow::HandleAutoCloseDoubleQuotes() if( aPortions.empty() ) return; - if( aLine.getLength() > 0 && !aLine.endsWith("\"") && (aPortions.back().tokenType != TT_STRING) ) + if( aLine.getLength() > 0 && !aLine.endsWith("\"") && (aPortions.back().tokenType != TokenType::String) ) { GetEditView()->InsertText("\""); //leave the cursor on its place: inside the two double quotes @@ -776,7 +776,7 @@ void EditorWindow::HandleProcedureCompletion() HighlightPortion& r = aCurrPortions.front(); OUString sStr = aCurrLine.copy(r.nBegin, r.nEnd - r.nBegin); - if( r.tokenType == 9 ) + if( r.tokenType == TokenType::Keywords ) { if( sStr.equalsIgnoreAsciiCase("sub") || sStr.equalsIgnoreAsciiCase("function") ) { @@ -808,13 +808,13 @@ bool EditorWindow::GetProcedureName(OUString& rLine, OUString& rProcType, OUStri { OUString sTokStr = rLine.copy(i->nBegin, i->nEnd - i->nBegin); - if( i->tokenType == 9 && ( sTokStr.equalsIgnoreAsciiCase("sub") + if( i->tokenType == TokenType::Keywords && ( sTokStr.equalsIgnoreAsciiCase("sub") || sTokStr.equalsIgnoreAsciiCase("function")) ) { rProcType = sTokStr; bFoundType = true; } - if( i->tokenType == 1 && bFoundType ) + if( i->tokenType == TokenType::Identifier && bFoundType ) { rProcName = sTokStr; bFoundName = true; @@ -847,9 +847,9 @@ void EditorWindow::HandleCodeCompletion() aPortions.rbegin()); i != aPortions.rend(); ++i) { - if( i->tokenType == TT_WHITESPACE ) // a whitespace: stop; if there is no ws, it goes to the beginning of the line + if( i->tokenType == TokenType::Whitespace ) // a whitespace: stop; if there is no ws, it goes to the beginning of the line break; - if( i->tokenType == TT_IDENTIFIER || i->tokenType == TT_KEYWORDS ) // extract the identifiers(methods, base variable) + if( i->tokenType == TokenType::Identifier || i->tokenType == TokenType::Keywords ) // extract the identifiers(methods, base variable) /* an example: Dim aLocVar2 as com.sun.star.beans.PropertyValue * here, aLocVar2.Name, and PropertyValue's Name field is treated as a keyword(?!) * */ diff --git a/comphelper/qa/unit/syntaxhighlighttest.cxx b/comphelper/qa/unit/syntaxhighlighttest.cxx index 5297bf12ffd7..848c741c3f2f 100644 --- a/comphelper/qa/unit/syntaxhighlighttest.cxx +++ b/comphelper/qa/unit/syntaxhighlighttest.cxx @@ -37,6 +37,11 @@ public: CPPUNIT_TEST_SUITE_END(); }; +std::ostream& operator<<(std::ostream& rStrm, const TokenType& tt) +{ + return rStrm << (int)tt; +} + void SyntaxHighlightTest::testBasicString() { OUString s("\"foo\""); std::vector<HighlightPortion> ps; @@ -45,7 +50,7 @@ void SyntaxHighlightTest::testBasicString() { static_cast<std::vector<HighlightPortion>::size_type>(1), ps.size()); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), ps[0].nBegin); CPPUNIT_ASSERT_EQUAL(sal_Int32(5), ps[0].nEnd); - CPPUNIT_ASSERT_EQUAL(TT_STRING, ps[0].tokenType); + CPPUNIT_ASSERT_EQUAL(TokenType::String, ps[0].tokenType); } void SyntaxHighlightTest::testBasicComment() { @@ -56,7 +61,7 @@ void SyntaxHighlightTest::testBasicComment() { static_cast<std::vector<HighlightPortion>::size_type>(1), ps.size()); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), ps[0].nBegin); CPPUNIT_ASSERT_EQUAL(sal_Int32(5), ps[0].nEnd); - CPPUNIT_ASSERT_EQUAL(TT_COMMENT, ps[0].tokenType); + CPPUNIT_ASSERT_EQUAL(TokenType::Comment, ps[0].tokenType); } void SyntaxHighlightTest::testBasicCommentNewline() { @@ -67,10 +72,10 @@ void SyntaxHighlightTest::testBasicCommentNewline() { static_cast<std::vector<HighlightPortion>::size_type>(2), ps.size()); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), ps[0].nBegin); CPPUNIT_ASSERT_EQUAL(sal_Int32(5), ps[0].nEnd); - CPPUNIT_ASSERT_EQUAL(TT_COMMENT, ps[0].tokenType); + CPPUNIT_ASSERT_EQUAL(TokenType::Comment, ps[0].tokenType); CPPUNIT_ASSERT_EQUAL(sal_Int32(5), ps[1].nBegin); CPPUNIT_ASSERT_EQUAL(sal_Int32(6), ps[1].nEnd); - CPPUNIT_ASSERT_EQUAL(TT_EOL, ps[1].tokenType); + CPPUNIT_ASSERT_EQUAL(TokenType::EOL, ps[1].tokenType); } void SyntaxHighlightTest::testBasicEmptyComment() { @@ -81,7 +86,7 @@ void SyntaxHighlightTest::testBasicEmptyComment() { static_cast<std::vector<HighlightPortion>::size_type>(1), ps.size()); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), ps[0].nBegin); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), ps[0].nEnd); - CPPUNIT_ASSERT_EQUAL(TT_COMMENT, ps[0].tokenType); + CPPUNIT_ASSERT_EQUAL(TokenType::Comment, ps[0].tokenType); } void SyntaxHighlightTest::testBasicEmptyCommentNewline() { @@ -92,10 +97,10 @@ void SyntaxHighlightTest::testBasicEmptyCommentNewline() { static_cast<std::vector<HighlightPortion>::size_type>(2), ps.size()); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), ps[0].nBegin); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), ps[0].nEnd); - CPPUNIT_ASSERT_EQUAL(TT_COMMENT, ps[0].tokenType); + CPPUNIT_ASSERT_EQUAL(TokenType::Comment, ps[0].tokenType); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), ps[1].nBegin); CPPUNIT_ASSERT_EQUAL(sal_Int32(2), ps[1].nEnd); - CPPUNIT_ASSERT_EQUAL(TT_EOL, ps[1].tokenType); + CPPUNIT_ASSERT_EQUAL(TokenType::EOL, ps[1].tokenType); } void SyntaxHighlightTest::testBasic() diff --git a/comphelper/source/misc/syntaxhighlight.cxx b/comphelper/source/misc/syntaxhighlight.cxx index 625490875567..639a957168c7 100644 --- a/comphelper/source/misc/syntaxhighlight.cxx +++ b/comphelper/source/misc/syntaxhighlight.cxx @@ -265,7 +265,7 @@ class SyntaxHighlighter::Tokenizer bool testCharFlags(sal_Unicode c, sal_uInt16 nTestFlags) const; // Get new token, EmptyString == nothing more over there - bool getNextToken(const sal_Unicode*& pos, /*out*/TokenTypes& reType, + bool getNextToken(const sal_Unicode*& pos, /*out*/TokenType& reType, /*out*/const sal_Unicode*& rpStartPos, /*out*/const sal_Unicode*& rpEndPos) const; const char** ppListKeyWords; @@ -304,10 +304,10 @@ void SyntaxHighlighter::Tokenizer::setKeyWords( const char** ppKeyWords, sal_uIn nKeyWordCount = nCount; } -bool SyntaxHighlighter::Tokenizer::getNextToken(const sal_Unicode*& pos, /*out*/TokenTypes& reType, +bool SyntaxHighlighter::Tokenizer::getNextToken(const sal_Unicode*& pos, /*out*/TokenType& reType, /*out*/const sal_Unicode*& rpStartPos, /*out*/const sal_Unicode*& rpEndPos) const { - reType = TT_UNKNOWN; + reType = TokenType::Unknown; rpStartPos = pos; @@ -324,7 +324,7 @@ bool SyntaxHighlighter::Tokenizer::getNextToken(const sal_Unicode*& pos, /*out*/ while( testCharFlags( *pos, CHAR_SPACE ) ) ++pos; - reType = TT_WHITESPACE; + reType = TokenType::Whitespace; } // Identifier? @@ -341,7 +341,7 @@ bool SyntaxHighlighter::Tokenizer::getNextToken(const sal_Unicode*& pos, /*out*/ } while( bIdentifierChar ); - reType = TT_IDENTIFIER; + reType = TokenType::Identifier; // Keyword table if (ppListKeyWords != nullptr) @@ -367,7 +367,7 @@ bool SyntaxHighlighter::Tokenizer::getNextToken(const sal_Unicode*& pos, /*out*/ if ( bsearch( aByteStr.getStr(), ppListKeyWords, nKeyWordCount, sizeof( char* ), compare_strings ) ) { - reType = TT_KEYWORDS; + reType = TokenType::Keywords; if( aByteStr == "rem" ) { @@ -378,7 +378,7 @@ bool SyntaxHighlighter::Tokenizer::getNextToken(const sal_Unicode*& pos, /*out*/ cPeek = *++pos; } - reType = TT_COMMENT; + reType = TokenType::Comment; } } } @@ -405,7 +405,7 @@ bool SyntaxHighlighter::Tokenizer::getNextToken(const sal_Unicode*& pos, /*out*/ } while( bIdentifierChar ); } - reType = TT_PARAMETER; + reType = TokenType::Parameter; } else if (c=='-') { @@ -418,7 +418,7 @@ bool SyntaxHighlighter::Tokenizer::getNextToken(const sal_Unicode*& pos, /*out*/ ++pos; cPeekNext = *pos; } - reType = TT_COMMENT; + reType = TokenType::Comment; } } else if (c=='/') @@ -432,7 +432,7 @@ bool SyntaxHighlighter::Tokenizer::getNextToken(const sal_Unicode*& pos, /*out*/ ++pos; cPeekNext = *pos; } - reType = TT_COMMENT; + reType = TokenType::Comment; } } else @@ -449,14 +449,14 @@ bool SyntaxHighlighter::Tokenizer::getNextToken(const sal_Unicode*& pos, /*out*/ ++pos; } - reType = TT_COMMENT; + reType = TokenType::Comment; } // The real operator; can be easily used since not the actual // operator (e.g. +=) is concerned, but the fact that it is one - if( reType != TT_COMMENT ) + if( reType != TokenType::Comment ) { - reType = TT_OPERATOR; + reType = TokenType::Operator; } } @@ -465,13 +465,13 @@ bool SyntaxHighlighter::Tokenizer::getNextToken(const sal_Unicode*& pos, /*out*/ // Object separator? Must be handled before Number else if( c == '.' && ( *pos < '0' || *pos > '9' ) ) { - reType = TT_OPERATOR; + reType = TokenType::Operator; } // Number? else if( testCharFlags( c, CHAR_START_NUMBER ) ) { - reType = TT_NUMBER; + reType = TokenType::Number; // Number system, 10 = normal, it is changed for Oct/Hex int nRadix = 10; @@ -503,12 +503,12 @@ bool SyntaxHighlighter::Tokenizer::getNextToken(const sal_Unicode*& pos, /*out*/ } else { - reType = TT_OPERATOR; + reType = TokenType::Operator; } } // When it is not Oct or Hex, then it is double - if( reType == TT_NUMBER && nRadix == 10 ) + if( reType == TokenType::Number && nRadix == 10 ) { // Flag if the last character is an exponent bool bAfterExpChar = false; @@ -540,25 +540,25 @@ bool SyntaxHighlighter::Tokenizer::getNextToken(const sal_Unicode*& pos, /*out*/ if( *pos == 0 ) { // ERROR: unterminated string literal - reType = TT_ERROR; + reType = TokenType::Error; break; } c = *pos++; if( testCharFlags( c, CHAR_EOL ) ) { // ERROR: unterminated string literal - reType = TT_ERROR; + reType = TokenType::Error; break; } } - if( reType != TT_ERROR ) + if( reType != TokenType::Error ) { ++pos; if( cEndString == ']' ) - reType = TT_IDENTIFIER; + reType = TokenType::Identifier; else - reType = TT_STRING; + reType = TokenType::String; } } @@ -570,10 +570,10 @@ bool SyntaxHighlighter::Tokenizer::getNextToken(const sal_Unicode*& pos, /*out*/ if( cNext != c && testCharFlags( cNext, CHAR_EOL ) ) ++pos; - reType = TT_EOL; + reType = TokenType::EOL; } - // All other will remain TT_UNKNOWN + // All other will remain TokenType::Unknown // Save end position rpEndPos = pos; @@ -672,7 +672,7 @@ void SyntaxHighlighter::Tokenizer::getHighlightPortions(const OUString& rLine, const sal_Unicode* pos = rLine.getStr(); // Variables for the out parameter - TokenTypes eType; + TokenType eType; const sal_Unicode* pStartPos; const sal_Unicode* pEndPos; diff --git a/helpcompiler/inc/BasCodeTagger.hxx b/helpcompiler/inc/BasCodeTagger.hxx index 25f430406c91..1020374a9097 100644 --- a/helpcompiler/inc/BasCodeTagger.hxx +++ b/helpcompiler/inc/BasCodeTagger.hxx @@ -33,7 +33,7 @@ class L10N_DLLPUBLIC BasicCodeTagger SyntaxHighlighter m_Highlighter; bool m_bTaggingCompleted; void tagParagraph( xmlNodePtr paragraph ); - static xmlChar* getTypeString( TokenTypes tokenType ); + static xmlChar* getTypeString( TokenType tokenType ); void getBasicCodeContainerNodes(); void tagBasCodeParagraphs(); diff --git a/helpcompiler/source/BasCodeTagger.cxx b/helpcompiler/source/BasCodeTagger.cxx index f8b1f95952e5..cad409017db5 100644 --- a/helpcompiler/source/BasCodeTagger.cxx +++ b/helpcompiler/source/BasCodeTagger.cxx @@ -150,7 +150,7 @@ void BasicCodeTagger::tagParagraph( xmlNodePtr paragraph ) { OString sToken(OUStringToOString(strLine.copy(i->nBegin, i->nEnd-i->nBegin), RTL_TEXTENCODING_UTF8)); xmlNodePtr text = xmlNewText(reinterpret_cast<const xmlChar*>(sToken.getStr())); - if ( i->tokenType != TT_WHITESPACE ) + if ( i->tokenType != TokenType::Whitespace ) { xmlChar* typeStr = getTypeString( i->tokenType ); curNode = xmlNewTextChild( paragraph, nullptr, reinterpret_cast<xmlChar const *>("item"), nullptr ); @@ -188,42 +188,42 @@ void BasicCodeTagger::tagBasicCodes() } //! Converts SyntaxHighlighter's TokenTypes enum to a type string for <item type=... > -xmlChar* BasicCodeTagger::getTypeString( TokenTypes tokenType ) +xmlChar* BasicCodeTagger::getTypeString( TokenType tokenType ) { const char* str; switch ( tokenType ) { - case TT_UNKNOWN : + case TokenType::Unknown : str = "unknown"; break; - case TT_IDENTIFIER : + case TokenType::Identifier : str = "identifier"; break; - case TT_WHITESPACE : + case TokenType::Whitespace : str = "whitespace"; break; - case TT_NUMBER : + case TokenType::Number : str = "number"; break; - case TT_STRING : + case TokenType::String : str = "string"; break; - case TT_EOL : + case TokenType::EOL : str = "eol"; break; - case TT_COMMENT : + case TokenType::Comment : str = "comment"; break; - case TT_ERROR : + case TokenType::Error : str = "error"; break; - case TT_OPERATOR : + case TokenType::Operator : str = "operator"; break; - case TT_KEYWORDS : + case TokenType::Keywords : str = "keyword"; break; - case TT_PARAMETER : + case TokenType::Parameter : str = "parameter"; break; default : diff --git a/include/comphelper/syntaxhighlight.hxx b/include/comphelper/syntaxhighlight.hxx index 77543ed4cb8f..cfe8896c982c 100644 --- a/include/comphelper/syntaxhighlight.hxx +++ b/include/comphelper/syntaxhighlight.hxx @@ -30,29 +30,29 @@ #include <vector> #include <memory> -// Token-Typen TT_... -enum TokenTypes +enum class TokenType { - TT_UNKNOWN, - TT_IDENTIFIER, - TT_WHITESPACE, - TT_NUMBER, - TT_STRING, - TT_EOL, - TT_COMMENT, - TT_ERROR, - TT_OPERATOR, - TT_KEYWORDS, - TT_PARAMETER + Unknown, + Identifier, + Whitespace, + Number, + String, + EOL, + Comment, + Error, + Operator, + Keywords, + Parameter, + LAST = Parameter }; struct HighlightPortion { sal_Int32 nBegin; sal_Int32 nEnd; - TokenTypes tokenType; + TokenType tokenType; HighlightPortion( - sal_Int32 theBegin, sal_Int32 theEnd, TokenTypes theTokenType): + sal_Int32 theBegin, sal_Int32 theEnd, TokenType theTokenType): nBegin(theBegin), nEnd(theEnd), tokenType(theTokenType) {} }; diff --git a/include/svtools/editsyntaxhighlighter.hxx b/include/svtools/editsyntaxhighlighter.hxx index f177f9962ae0..d205e3222145 100644 --- a/include/svtools/editsyntaxhighlighter.hxx +++ b/include/svtools/editsyntaxhighlighter.hxx @@ -46,7 +46,7 @@ class SVT_DLLPUBLIC MultiLineEditSyntaxHighlight : public MultiLineEdit virtual void SetText( const OUString& rStr, const Selection& rNewSelection ) override { SetText( rStr ); SetSelection( rNewSelection ); } - Color GetColorValue(TokenTypes aToken); + Color GetColorValue(TokenType aToken); }; #endif diff --git a/svtools/source/edit/editsyntaxhighlighter.cxx b/svtools/source/edit/editsyntaxhighlighter.cxx index 894741f3c8aa..c4033349b2ee 100644 --- a/svtools/source/edit/editsyntaxhighlighter.cxx +++ b/svtools/source/edit/editsyntaxhighlighter.cxx @@ -115,7 +115,7 @@ bool MultiLineEditSyntaxHighlight::PreNotify( NotifyEvent& rNEvt ) return MultiLineEdit::PreNotify(rNEvt); } -Color MultiLineEditSyntaxHighlight::GetColorValue(TokenTypes aToken) +Color MultiLineEditSyntaxHighlight::GetColorValue(TokenType aToken) { Color aColor; switch (aHighlighter.GetLanguage()) @@ -124,13 +124,13 @@ Color MultiLineEditSyntaxHighlight::GetColorValue(TokenTypes aToken) { switch (aToken) { - case TT_IDENTIFIER: aColor = (ColorData)m_aColorConfig.GetColorValue(svtools::SQLIDENTIFIER).nColor; break; - case TT_NUMBER: aColor = (ColorData)m_aColorConfig.GetColorValue(svtools::SQLNUMBER).nColor; break; - case TT_STRING: aColor = (ColorData)m_aColorConfig.GetColorValue(svtools::SQLSTRING).nColor; break; - case TT_OPERATOR: aColor = (ColorData)m_aColorConfig.GetColorValue(svtools::SQLOPERATOR).nColor; break; - case TT_KEYWORDS: aColor = (ColorData)m_aColorConfig.GetColorValue(svtools::SQLKEYWORD).nColor; break; - case TT_PARAMETER: aColor = (ColorData)m_aColorConfig.GetColorValue(svtools::SQLPARAMETER).nColor; break; - case TT_COMMENT: aColor = (ColorData)m_aColorConfig.GetColorValue(svtools::SQLCOMMENT).nColor; break; + case TokenType::Identifier: aColor = (ColorData)m_aColorConfig.GetColorValue(svtools::SQLIDENTIFIER).nColor; break; + case TokenType::Number: aColor = (ColorData)m_aColorConfig.GetColorValue(svtools::SQLNUMBER).nColor; break; + case TokenType::String: aColor = (ColorData)m_aColorConfig.GetColorValue(svtools::SQLSTRING).nColor; break; + case TokenType::Operator: aColor = (ColorData)m_aColorConfig.GetColorValue(svtools::SQLOPERATOR).nColor; break; + case TokenType::Keywords: aColor = (ColorData)m_aColorConfig.GetColorValue(svtools::SQLKEYWORD).nColor; break; + case TokenType::Parameter: aColor = (ColorData)m_aColorConfig.GetColorValue(svtools::SQLPARAMETER).nColor; break; + case TokenType::Comment: aColor = (ColorData)m_aColorConfig.GetColorValue(svtools::SQLCOMMENT).nColor; break; default: aColor = Color(0,0,0); } break; @@ -139,13 +139,13 @@ Color MultiLineEditSyntaxHighlight::GetColorValue(TokenTypes aToken) { switch (aToken) { - case TT_IDENTIFIER: aColor = Color(255,0,0); break; - case TT_COMMENT: aColor = Color(0,0,45); break; - case TT_NUMBER: aColor = Color(204,102,204); break; - case TT_STRING: aColor = Color(0,255,45); break; - case TT_OPERATOR: aColor = Color(0,0,100); break; - case TT_KEYWORDS: aColor = Color(0,0,255); break; - case TT_ERROR : aColor = Color(0,255,255); break; + case TokenType::Identifier: aColor = Color(255,0,0); break; + case TokenType::Comment: aColor = Color(0,0,45); break; + case TokenType::Number: aColor = Color(204,102,204); break; + case TokenType::String: aColor = Color(0,255,45); break; + case TokenType::Operator: aColor = Color(0,0,100); break; + case TokenType::Keywords: aColor = Color(0,0,255); break; + case TokenType::Error : aColor = Color(0,255,255); break; default: aColor = Color(0,0,0); } break; |