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 /basctl | |
parent | 2f9d53df89614955215a630beb0966f0c4a663c2 (diff) |
convert TokenTypes to scoped enum
Change-Id: I17c0a616dd6cf48a22896b6cd6b0df157d1f9a9f
Diffstat (limited to 'basctl')
-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 |
3 files changed, 29 insertions, 28 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(?!) * */ |