diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2013-10-28 12:30:28 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2013-10-28 13:48:14 +0100 |
commit | c99267b326afcfd4002dc5ee33f5076a466c0cab (patch) | |
tree | 6b160f1ce1c505ede71424f069aca608438a2b6d | |
parent | 6aa24e7565dfa5feafd12cd0ec12312df044916e (diff) |
Fold SyntaxHighlighter::initialize into ctor
...which reveals that m_pKeyWords, m_nKeyWordCount members are unused.
Change-Id: I55020e892d463f2e40d5bcf71efba92778b317c1
-rw-r--r-- | basctl/source/basicide/baside2b.cxx | 4 | ||||
-rw-r--r-- | comphelper/qa/unit/syntaxhighlighttest.cxx | 26 | ||||
-rw-r--r-- | comphelper/source/misc/syntaxhighlight.cxx | 24 | ||||
-rw-r--r-- | helpcompiler/source/BasCodeTagger.cxx | 4 | ||||
-rw-r--r-- | include/comphelper/syntaxhighlight.hxx | 15 | ||||
-rw-r--r-- | svtools/source/edit/editsyntaxhighlighter.cxx | 3 |
6 files changed, 23 insertions, 53 deletions
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx index 0a527604ca1a..1b3ad3f7be54 100644 --- a/basctl/source/basicide/baside2b.cxx +++ b/basctl/source/basicide/baside2b.cxx @@ -233,6 +233,7 @@ EditorWindow::EditorWindow (Window* pParent, ModulWindow* pModulWindow) : pEditEngine(0), rModulWindow(*pModulWindow), nCurTextWidth(0), + aHighlighter(HIGHLIGHT_BASIC), bHighlightning(false), bDoSyntaxHighlight(true), bDelayHighlight(true), @@ -962,8 +963,6 @@ void EditorWindow::CreateEditEngine() aSyntaxIdleTimer.SetTimeout( 200 ); aSyntaxIdleTimer.SetTimeoutHdl( LINK( this, EditorWindow, SyntaxTimerHdl ) ); - aHighlighter.initialize( HIGHLIGHT_BASIC ); - bool bWasDoSyntaxHighlight = bDoSyntaxHighlight; bDoSyntaxHighlight = false; // too slow for large texts... OUString aOUSource(rModulWindow.GetModule()); @@ -1311,7 +1310,6 @@ void EditorWindow::ParagraphInsertedDeleted( sal_uLong nPara, bool bInserted ) rModulWindow.GetBreakPoints().reset(); rModulWindow.GetBreakPointWindow().Invalidate(); rModulWindow.GetLineNumberWindow().Invalidate(); - aHighlighter.initialize( HIGHLIGHT_BASIC ); } else { diff --git a/comphelper/qa/unit/syntaxhighlighttest.cxx b/comphelper/qa/unit/syntaxhighlighttest.cxx index af834a638de0..cf13cbbb8545 100644 --- a/comphelper/qa/unit/syntaxhighlighttest.cxx +++ b/comphelper/qa/unit/syntaxhighlighttest.cxx @@ -38,11 +38,9 @@ public: }; void SyntaxHighlightTest::testBasicString() { - SyntaxHighlighter h; - h.initialize(HIGHLIGHT_BASIC); OUString s("\"foo\""); std::vector<HighlightPortion> ps; - h.getHighlightPortions(s, ps); + SyntaxHighlighter(HIGHLIGHT_BASIC).getHighlightPortions(s, ps); CPPUNIT_ASSERT_EQUAL( static_cast<std::vector<HighlightPortion>::size_type>(1), ps.size()); CPPUNIT_ASSERT_EQUAL(0, ps[0].nBegin); @@ -51,11 +49,9 @@ void SyntaxHighlightTest::testBasicString() { } void SyntaxHighlightTest::testBasicComment() { - SyntaxHighlighter h; - h.initialize(HIGHLIGHT_BASIC); OUString s("' foo"); std::vector<HighlightPortion> ps; - h.getHighlightPortions(s, ps); + SyntaxHighlighter(HIGHLIGHT_BASIC).getHighlightPortions(s, ps); CPPUNIT_ASSERT_EQUAL( static_cast<std::vector<HighlightPortion>::size_type>(1), ps.size()); CPPUNIT_ASSERT_EQUAL(0, ps[0].nBegin); @@ -64,11 +60,9 @@ void SyntaxHighlightTest::testBasicComment() { } void SyntaxHighlightTest::testBasicCommentNewline() { - SyntaxHighlighter h; - h.initialize(HIGHLIGHT_BASIC); OUString s("' foo\n"); std::vector<HighlightPortion> ps; - h.getHighlightPortions(s, ps); + SyntaxHighlighter(HIGHLIGHT_BASIC).getHighlightPortions(s, ps); CPPUNIT_ASSERT_EQUAL( static_cast<std::vector<HighlightPortion>::size_type>(2), ps.size()); CPPUNIT_ASSERT_EQUAL(0, ps[0].nBegin); @@ -80,11 +74,9 @@ void SyntaxHighlightTest::testBasicCommentNewline() { } void SyntaxHighlightTest::testBasicEmptyComment() { - SyntaxHighlighter h; - h.initialize(HIGHLIGHT_BASIC); OUString s("'"); std::vector<HighlightPortion> ps; - h.getHighlightPortions(s, ps); + SyntaxHighlighter(HIGHLIGHT_BASIC).getHighlightPortions(s, ps); CPPUNIT_ASSERT_EQUAL( static_cast<std::vector<HighlightPortion>::size_type>(1), ps.size()); CPPUNIT_ASSERT_EQUAL(0, ps[0].nBegin); @@ -93,11 +85,9 @@ void SyntaxHighlightTest::testBasicEmptyComment() { } void SyntaxHighlightTest::testBasicEmptyCommentNewline() { - SyntaxHighlighter h; - h.initialize(HIGHLIGHT_BASIC); OUString s("'\n"); std::vector<HighlightPortion> ps; - h.getHighlightPortions(s, ps); + SyntaxHighlighter(HIGHLIGHT_BASIC).getHighlightPortions(s, ps); CPPUNIT_ASSERT_EQUAL( static_cast<std::vector<HighlightPortion>::size_type>(2), ps.size()); CPPUNIT_ASSERT_EQUAL(0, ps[0].nBegin); @@ -112,11 +102,9 @@ void SyntaxHighlightTest::testBasic() { OUString aBasicString(" if Mid(sText,iRun,1 )<> \" \" then Mid( sText ,iRun, 1, Chr( 1 + Asc( Mid(sText,iRun,1 )) ) '"); - SyntaxHighlighter aHighlighter; - aHighlighter.initialize( HIGHLIGHT_BASIC ); - std::vector<HighlightPortion> aPortions; - aHighlighter.getHighlightPortions( aBasicString, aPortions ); + SyntaxHighlighter(HIGHLIGHT_BASIC).getHighlightPortions( + aBasicString, aPortions ); sal_Int32 prevEnd = 0; for(std::vector<HighlightPortion>::const_iterator itr = diff --git a/comphelper/source/misc/syntaxhighlight.cxx b/comphelper/source/misc/syntaxhighlight.cxx index b886fea0355d..fa5afc1f0f68 100644 --- a/comphelper/source/misc/syntaxhighlight.cxx +++ b/comphelper/source/misc/syntaxhighlight.cxx @@ -17,6 +17,9 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include "sal/config.h" + +#include <cassert> #include <unicode/uchar.h> #include <comphelper/syntaxhighlight.hxx> @@ -706,22 +709,9 @@ void SyntaxHighlighter::Tokenizer::getHighlightPortions( const OUString& rLine, } -SyntaxHighlighter::SyntaxHighlighter() +SyntaxHighlighter::SyntaxHighlighter(HighlighterLanguage language): + eLanguage(language), m_tokenizer(new SyntaxHighlighter::Tokenizer(language)) { - m_pKeyWords = NULL; - m_nKeyWordCount = 0; -} - -SyntaxHighlighter::~SyntaxHighlighter() -{ - delete m_pKeyWords; -} - -void SyntaxHighlighter::initialize( HighlighterLanguage eLanguage_ ) -{ - eLanguage = eLanguage_; - m_tokenizer.reset(new SyntaxHighlighter::Tokenizer(eLanguage)); - switch (eLanguage) { case HIGHLIGHT_BASIC: @@ -733,10 +723,12 @@ void SyntaxHighlighter::initialize( HighlighterLanguage eLanguage_ ) sizeof( strListSqlKeyWords ) / sizeof( char* )); break; default: - m_tokenizer->setKeyWords( NULL, 0 ); + assert(false); // this cannot happen } } +SyntaxHighlighter::~SyntaxHighlighter() {} + void SyntaxHighlighter::notifyChange( const OUString* pChangedLines, sal_uInt32 nArrayLength) { diff --git a/helpcompiler/source/BasCodeTagger.cxx b/helpcompiler/source/BasCodeTagger.cxx index 782bcdc3ec6a..a01c6b62d934 100644 --- a/helpcompiler/source/BasCodeTagger.cxx +++ b/helpcompiler/source/BasCodeTagger.cxx @@ -55,13 +55,13 @@ xmlNodePtr LibXmlTreeWalker::currentNode() //====================================================== -BasicCodeTagger::BasicCodeTagger( xmlDocPtr rootDoc ) +BasicCodeTagger::BasicCodeTagger( xmlDocPtr rootDoc ): + m_Highlighter(HIGHLIGHT_BASIC) { if ( rootDoc == NULL ) throw NULL_DOCUMENT; m_pDocument = rootDoc; m_pXmlTreeWalker = NULL; - m_Highlighter.initialize( HIGHLIGHT_BASIC ); m_bTaggingCompleted = false; } diff --git a/include/comphelper/syntaxhighlight.hxx b/include/comphelper/syntaxhighlight.hxx index 43c42d00f338..8a5782273af3 100644 --- a/include/comphelper/syntaxhighlight.hxx +++ b/include/comphelper/syntaxhighlight.hxx @@ -21,6 +21,7 @@ #include <vector> +#include <boost/noncopyable.hpp> #include <boost/scoped_ptr.hpp> #include <rtl/ustring.hxx> @@ -70,24 +71,16 @@ enum HighlighterLanguage // (notifyChange) and returns the caller the range of lines, which based on the // changes, need to be highlighted again. For this the Highlighter marks all // lines internally whether or not C comments begin or end. -class COMPHELPER_DLLPUBLIC SyntaxHighlighter +class COMPHELPER_DLLPUBLIC SyntaxHighlighter: private boost::noncopyable { class Tokenizer; HighlighterLanguage eLanguage; boost::scoped_ptr<Tokenizer> m_tokenizer; - char* m_pKeyWords; - sal_uInt16 m_nKeyWordCount; - -// void initializeKeyWords( HighlighterLanguage eLanguage ); public: - SyntaxHighlighter( void ); - ~SyntaxHighlighter( void ); - - // (Re-)initialize Highlighter. The line-table will be completely erased, - // meaning that on completion an empty Source is assumed. - void initialize( HighlighterLanguage eLanguage_ ); + SyntaxHighlighter(HighlighterLanguage language); + ~SyntaxHighlighter(); void notifyChange(const OUString* pChangedLines, sal_uInt32 nArrayLength); diff --git a/svtools/source/edit/editsyntaxhighlighter.cxx b/svtools/source/edit/editsyntaxhighlighter.cxx index d84fc15e06e0..d679408143ef 100644 --- a/svtools/source/edit/editsyntaxhighlighter.cxx +++ b/svtools/source/edit/editsyntaxhighlighter.cxx @@ -26,10 +26,9 @@ MultiLineEditSyntaxHighlight::MultiLineEditSyntaxHighlight( Window* pParent, WinBits nWinStyle, - HighlighterLanguage aLanguage): MultiLineEdit(pParent,nWinStyle), mbDoBracketHilight(true) + HighlighterLanguage aLanguage): MultiLineEdit(pParent,nWinStyle), mbDoBracketHilight(true), aHighlighter(aLanguage) { EnableUpdateData(300); - aHighlighter.initialize( aLanguage ); } extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeMultiLineEditSyntaxHighlight(Window *pParent, VclBuilder::stringmap &) |