Fold SyntaxHighlighter::initialize into ctor
...which reveals that m_pKeyWords, m_nKeyWordCount members are unused. Change-Id: I55020e892d463f2e40d5bcf71efba92778b317c1
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
@@ -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 =
|
||||
|
@@ -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)
|
||||
{
|
||||
|
@@ -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;
|
||||
|
||||
}
|
||||
|
@@ -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);
|
||||
|
||||
|
@@ -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 &)
|
||||
|
Reference in New Issue
Block a user