summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--basctl/source/basicide/baside2b.cxx8
-rw-r--r--comphelper/source/misc/syntaxhighlight.cxx126
-rw-r--r--helpcompiler/source/BasCodeTagger.cxx1
-rw-r--r--include/comphelper/syntaxhighlight.hxx7
-rw-r--r--svtools/source/edit/editsyntaxhighlighter.cxx2
5 files changed, 47 insertions, 97 deletions
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index 1b3ad3f7be54..d9316feccb6e 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -1189,8 +1189,6 @@ void EditorWindow::ImpDoHighlight( sal_uLong nLine )
if ( bDoSyntaxHighlight )
{
OUString aLine( pEditEngine->GetText( nLine ) );
- aHighlighter.notifyChange( &aLine, 1 );
-
bool const bWasModified = pEditEngine->IsModified();
pEditEngine->RemoveAttribs( nLine, true );
std::vector<HighlightPortion> aPortions;
@@ -1326,12 +1324,6 @@ void EditorWindow::ParagraphInsertedDeleted( sal_uLong nPara, bool bInserted )
GetOutputSizePixel().Height() - 2 * DWBORDER);
rModulWindow.GetLineNumberWindow().SetPosSizePixel(Point(DWBORDER + 19, DWBORDER), aLnSz);
rModulWindow.GetLineNumberWindow().Invalidate();
-
- if ( bDoSyntaxHighlight )
- {
- OUString aDummy;
- aHighlighter.notifyChange( &aDummy, 1 );
- }
}
}
diff --git a/comphelper/source/misc/syntaxhighlight.cxx b/comphelper/source/misc/syntaxhighlight.cxx
index fa5afc1f0f68..bdf9d43e41fc 100644
--- a/comphelper/source/misc/syntaxhighlight.cxx
+++ b/comphelper/source/misc/syntaxhighlight.cxx
@@ -261,17 +261,11 @@ class SyntaxHighlighter::Tokenizer
// Character information tables
sal_uInt16 aCharTypeTab[256];
- const sal_Unicode* mpStringBegin;
- const sal_Unicode* mpActualPos;
-
- sal_Unicode peekChar( void ) { return *mpActualPos; }
- sal_Unicode getChar( void ) { return *mpActualPos++; }
-
// Auxiliary function: testing of the character flags
sal_Bool testCharFlags( sal_Unicode c, sal_uInt16 nTestFlags );
// Get new token, EmptyString == nothing more over there
- sal_Bool getNextToken( /*out*/TokenTypes& reType,
+ sal_Bool getNextToken( const sal_Unicode*& pos, /*out*/TokenTypes& reType,
/*out*/const sal_Unicode*& rpStartPos, /*out*/const sal_Unicode*& rpEndPos );
const char** ppListKeyWords;
@@ -281,7 +275,6 @@ public:
Tokenizer( HighlighterLanguage aLang = HIGHLIGHT_BASIC );
~Tokenizer( void );
- sal_uInt16 parseLine( const OUString* aSource );
void getHighlightPortions( const OUString& rLine,
/*out*/std::vector<HighlightPortion>& portions );
void setKeyWords( const char** ppKeyWords, sal_uInt16 nCount );
@@ -309,25 +302,25 @@ void SyntaxHighlighter::Tokenizer::setKeyWords( const char** ppKeyWords, sal_uIn
nKeyWordCount = nCount;
}
-sal_Bool SyntaxHighlighter::Tokenizer::getNextToken( /*out*/TokenTypes& reType,
+sal_Bool SyntaxHighlighter::Tokenizer::getNextToken( const sal_Unicode*& pos, /*out*/TokenTypes& reType,
/*out*/const sal_Unicode*& rpStartPos, /*out*/const sal_Unicode*& rpEndPos )
{
reType = TT_UNKNOWN;
- rpStartPos = mpActualPos;
+ rpStartPos = pos;
- sal_Unicode c = peekChar();
+ sal_Unicode c = *pos;
if( c == 0 )
return sal_False;
- getChar();
+ ++pos;
//*** Go through all possibilities ***
// Space?
if ( (testCharFlags( c, CHAR_SPACE ) == sal_True) )
{
- while( testCharFlags( peekChar(), CHAR_SPACE ) == sal_True )
- getChar();
+ while( testCharFlags( *pos, CHAR_SPACE ) == sal_True )
+ ++pos;
reType = TT_WHITESPACE;
}
@@ -339,10 +332,10 @@ sal_Bool SyntaxHighlighter::Tokenizer::getNextToken( /*out*/TokenTypes& reType,
do
{
// Naechstes Zeichen holen
- c = peekChar();
+ c = *pos;
bIdentifierChar = testCharFlags( c, CHAR_IN_IDENTIFIER );
if( bIdentifierChar )
- getChar();
+ ++pos;
}
while( bIdentifierChar );
@@ -351,7 +344,7 @@ sal_Bool SyntaxHighlighter::Tokenizer::getNextToken( /*out*/TokenTypes& reType,
// Keyword table
if (ppListKeyWords != NULL)
{
- int nCount = mpActualPos - rpStartPos;
+ int nCount = pos - rpStartPos;
// No keyword if string contains char > 255
bool bCanBeKeyword = true;
@@ -377,11 +370,11 @@ sal_Bool SyntaxHighlighter::Tokenizer::getNextToken( /*out*/TokenTypes& reType,
if (aByteStr.equalsL(RTL_CONSTASCII_STRINGPARAM("rem")))
{
// Remove all characters until end of line or EOF
- sal_Unicode cPeek = peekChar();
+ sal_Unicode cPeek = *pos;
while( cPeek != 0 && testCharFlags( cPeek, CHAR_EOL ) == sal_False )
{
- c = getChar();
- cPeek = peekChar();
+ c = *pos++;
+ cPeek = *pos;
}
reType = TT_COMMENT;
@@ -404,10 +397,10 @@ sal_Bool SyntaxHighlighter::Tokenizer::getNextToken( /*out*/TokenTypes& reType,
do
{
// Get next character
- c = peekChar();
+ c = *pos;
bIdentifierChar = isAlpha(c);
if( bIdentifierChar )
- getChar();
+ ++pos;
}
while( bIdentifierChar );
}
@@ -415,28 +408,28 @@ sal_Bool SyntaxHighlighter::Tokenizer::getNextToken( /*out*/TokenTypes& reType,
}
else if (c=='-')
{
- sal_Unicode cPeekNext = peekChar();
+ sal_Unicode cPeekNext = *pos;
if (cPeekNext=='-')
{
// Remove all characters until end of line or EOF
while( cPeekNext != 0 && testCharFlags( cPeekNext, CHAR_EOL ) == sal_False )
{
- getChar();
- cPeekNext = peekChar();
+ ++pos;
+ cPeekNext = *pos;
}
reType = TT_COMMENT;
}
}
else if (c=='/')
{
- sal_Unicode cPeekNext = peekChar();
+ sal_Unicode cPeekNext = *pos;
if (cPeekNext=='/')
{
// Remove all characters until end of line or EOF
while( cPeekNext != 0 && testCharFlags( cPeekNext, CHAR_EOL ) == sal_False )
{
- getChar();
- cPeekNext = peekChar();
+ ++pos;
+ cPeekNext = *pos;
}
reType = TT_COMMENT;
}
@@ -448,11 +441,11 @@ sal_Bool SyntaxHighlighter::Tokenizer::getNextToken( /*out*/TokenTypes& reType,
{
// Skip all characters until end of input or end of line:
for (;;) {
- c = peekChar();
+ c = *pos;
if (c == 0 || testCharFlags(c, CHAR_EOL)) {
break;
}
- getChar();
+ ++pos;
}
reType = TT_COMMENT;
@@ -469,7 +462,7 @@ sal_Bool SyntaxHighlighter::Tokenizer::getNextToken( /*out*/TokenTypes& reType,
}
// Object separator? Must be handled before Number
- else if( c == '.' && ( peekChar() < '0' || peekChar() > '9' ) )
+ else if( c == '.' && ( *pos < '0' || *pos > '9' ) )
{
reType = TT_OPERATOR;
}
@@ -486,26 +479,26 @@ sal_Bool SyntaxHighlighter::Tokenizer::getNextToken( /*out*/TokenTypes& reType,
if( c == '&' )
{
// Octal?
- if( peekChar() == 'o' || peekChar() == 'O' )
+ if( *pos == 'o' || *pos == 'O' )
{
// remove o
- getChar();
+ ++pos;
nRadix = 8; // Octal base
// Read all numbers
- while( testCharFlags( peekChar(), CHAR_IN_OCT_NUMBER ) )
- c = getChar();
+ while( testCharFlags( *pos, CHAR_IN_OCT_NUMBER ) )
+ c = *pos++;
}
// Hexadecimal?
- else if( peekChar() == 'h' || peekChar() == 'H' )
+ else if( *pos == 'h' || *pos == 'H' )
{
// remove x
- getChar();
+ ++pos;
nRadix = 16; // Hexadecimal base
// Read all numbers
- while( testCharFlags( peekChar(), CHAR_IN_HEX_NUMBER ) )
- c = getChar();
+ while( testCharFlags( *pos, CHAR_IN_HEX_NUMBER ) )
+ c = *pos++;
}
else
{
@@ -520,12 +513,12 @@ sal_Bool SyntaxHighlighter::Tokenizer::getNextToken( /*out*/TokenTypes& reType,
sal_Bool bAfterExpChar = sal_False;
// Read all numbers
- while( testCharFlags( peekChar(), CHAR_IN_NUMBER ) ||
- (bAfterExpChar && peekChar() == '+' ) ||
- (bAfterExpChar && peekChar() == '-' ) )
+ while( testCharFlags( *pos, CHAR_IN_NUMBER ) ||
+ (bAfterExpChar && *pos == '+' ) ||
+ (bAfterExpChar && *pos == '-' ) )
// After exponent +/- are OK, too
{
- c = getChar();
+ c = *pos++;
bAfterExpChar = ( c == 'e' || c == 'E' );
}
}
@@ -540,16 +533,16 @@ sal_Bool SyntaxHighlighter::Tokenizer::getNextToken( /*out*/TokenTypes& reType,
cEndString = ']';
// Read all characters
- while( peekChar() != cEndString )
+ while( *pos != cEndString )
{
- // Detect EOF before getChar(), so we do not loose EOF
- if( peekChar() == 0 )
+ // Detect EOF before reading next char, so we do not loose EOF
+ if( *pos == 0 )
{
// ERROR: unterminated string literal
reType = TT_ERROR;
break;
}
- c = getChar();
+ c = *pos++;
if( testCharFlags( c, CHAR_EOL ) == sal_True )
{
// ERROR: unterminated string literal
@@ -560,7 +553,7 @@ sal_Bool SyntaxHighlighter::Tokenizer::getNextToken( /*out*/TokenTypes& reType,
if( reType != TT_ERROR )
{
- getChar();
+ ++pos;
if( cEndString == ']' )
reType = TT_IDENTIFIER;
else
@@ -572,9 +565,9 @@ sal_Bool SyntaxHighlighter::Tokenizer::getNextToken( /*out*/TokenTypes& reType,
else if( testCharFlags( c, CHAR_EOL ) == sal_True )
{
// If another EOL character comes, read it
- sal_Unicode cNext = peekChar();
+ sal_Unicode cNext = *pos;
if( cNext != c && testCharFlags( cNext, CHAR_EOL ) == sal_True )
- getChar();
+ ++pos;
reType = TT_EOL;
}
@@ -582,7 +575,7 @@ sal_Bool SyntaxHighlighter::Tokenizer::getNextToken( /*out*/TokenTypes& reType,
// All other will remain TT_UNKNOWN
// Save end position
- rpEndPos = mpActualPos;
+ rpEndPos = pos;
return sal_True;
}
@@ -670,29 +663,11 @@ SyntaxHighlighter::Tokenizer::~Tokenizer( void )
{
}
-sal_uInt16 SyntaxHighlighter::Tokenizer::parseLine( const OUString* aSource )
-{
- // Set the position to the beginning of the source string
- mpStringBegin = mpActualPos = aSource->getStr();
-
- // Variables for the out parameter
- TokenTypes eType;
- const sal_Unicode* pStartPos;
- const sal_Unicode* pEndPos;
-
- // Loop over all the tokens
- sal_uInt16 nTokenCount = 0;
- while( getNextToken( eType, pStartPos, pEndPos ) )
- nTokenCount++;
-
- return nTokenCount;
-}
-
void SyntaxHighlighter::Tokenizer::getHighlightPortions( const OUString& rLine,
/*out*/std::vector<HighlightPortion>& portions )
{
// Set the position to the beginning of the source string
- mpStringBegin = mpActualPos = rLine.getStr();
+ const sal_Unicode* pos = rLine.getStr();
// Variables for the out parameter
TokenTypes eType;
@@ -700,11 +675,11 @@ void SyntaxHighlighter::Tokenizer::getHighlightPortions( const OUString& rLine,
const sal_Unicode* pEndPos;
// Loop over all the tokens
- while( getNextToken( eType, pStartPos, pEndPos ) )
+ while( getNextToken( pos, eType, pStartPos, pEndPos ) )
{
portions.push_back(
HighlightPortion(
- pStartPos - mpStringBegin, pEndPos - mpStringBegin, eType));
+ pStartPos - rLine.getStr(), pEndPos - rLine.getStr(), eType));
}
}
@@ -729,13 +704,6 @@ SyntaxHighlighter::SyntaxHighlighter(HighlighterLanguage language):
SyntaxHighlighter::~SyntaxHighlighter() {}
-void SyntaxHighlighter::notifyChange(
- const OUString* pChangedLines, sal_uInt32 nArrayLength)
-{
- for( sal_uInt32 i=0 ; i < nArrayLength ; i++ )
- m_tokenizer->parseLine(&pChangedLines[i]);
-}
-
void SyntaxHighlighter::getHighlightPortions( const OUString& rLine,
/*out*/std::vector<HighlightPortion>& portions )
{
diff --git a/helpcompiler/source/BasCodeTagger.cxx b/helpcompiler/source/BasCodeTagger.cxx
index a01c6b62d934..fcbe8e45cf01 100644
--- a/helpcompiler/source/BasCodeTagger.cxx
+++ b/helpcompiler/source/BasCodeTagger.cxx
@@ -149,7 +149,6 @@ void BasicCodeTagger::tagParagraph( xmlNodePtr paragraph )
OUString strLine( reinterpret_cast<const sal_Char*>(codeSnippet),
strlen(reinterpret_cast<const char*>(codeSnippet)),
RTL_TEXTENCODING_UTF8 );
- m_Highlighter.notifyChange ( &strLine, 1 );
std::vector<HighlightPortion> portions;
m_Highlighter.getHighlightPortions( strLine, portions );
for (std::vector<HighlightPortion>::iterator i(portions.begin());
diff --git a/include/comphelper/syntaxhighlight.hxx b/include/comphelper/syntaxhighlight.hxx
index 8a5782273af3..ec0bf7c01e41 100644
--- a/include/comphelper/syntaxhighlight.hxx
+++ b/include/comphelper/syntaxhighlight.hxx
@@ -66,11 +66,6 @@ enum HighlighterLanguage
HIGHLIGHT_SQL
};
-//*** SyntaxHighlighter Class ***
-// Concept: the Highlighter will be notified of all changes in the source
-// (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: private boost::noncopyable
{
class Tokenizer;
@@ -82,8 +77,6 @@ public:
SyntaxHighlighter(HighlighterLanguage language);
~SyntaxHighlighter();
- void notifyChange(const OUString* pChangedLines, sal_uInt32 nArrayLength);
-
void getHighlightPortions( const OUString& rLine,
std::vector<HighlightPortion>& pPortions );
diff --git a/svtools/source/edit/editsyntaxhighlighter.cxx b/svtools/source/edit/editsyntaxhighlighter.cxx
index d679408143ef..68343968643e 100644
--- a/svtools/source/edit/editsyntaxhighlighter.cxx
+++ b/svtools/source/edit/editsyntaxhighlighter.cxx
@@ -170,8 +170,6 @@ void MultiLineEditSyntaxHighlight::UpdateData()
for (unsigned int nLine=0; nLine < GetTextEngine()->GetParagraphCount(); nLine++)
{
OUString aLine( GetTextEngine()->GetText( nLine ) );
- aHighlighter.notifyChange( &aLine, 1 );
-
GetTextEngine()->RemoveAttribs( nLine, sal_True );
std::vector<HighlightPortion> aPortions;
aHighlighter.getHighlightPortions( aLine, aPortions );