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 /comphelper | |
parent | 6aa24e7565dfa5feafd12cd0ec12312df044916e (diff) |
Fold SyntaxHighlighter::initialize into ctor
...which reveals that m_pKeyWords, m_nKeyWordCount members are unused.
Change-Id: I55020e892d463f2e40d5bcf71efba92778b317c1
Diffstat (limited to 'comphelper')
-rw-r--r-- | comphelper/qa/unit/syntaxhighlighttest.cxx | 26 | ||||
-rw-r--r-- | comphelper/source/misc/syntaxhighlight.cxx | 24 |
2 files changed, 15 insertions, 35 deletions
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) { |