Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
f344504d
Commit
f344504d
authored
Jun 18, 2010
by
con
Browse files
Merge branch 'master' of scm.dev.nokia.troll.no:creator/mainline
parents
458a25ef
20eeca15
Changes
13
Hide whitespace changes
Inline
Side-by-side
src/plugins/texteditor/generichighlighter/highlighter.cpp
View file @
f344504d
...
...
@@ -53,7 +53,8 @@ const Highlighter::KateFormatMap Highlighter::m_kateFormats;
Highlighter
::
Highlighter
(
QTextDocument
*
parent
)
:
QSyntaxHighlighter
(
parent
),
m_persistentStatesCounter
(
PersistentsStart
),
m_regionDepth
(
0
),
m_persistentObservableStatesCounter
(
PersistentsStart
),
m_dynamicContextsCounter
(
0
),
m_isBroken
(
false
)
{}
...
...
@@ -61,7 +62,7 @@ Highlighter::Highlighter(QTextDocument *parent) :
Highlighter
::~
Highlighter
()
{}
Highlighter
::
BlockData
::
BlockData
()
Highlighter
::
BlockData
::
BlockData
()
:
m_foldingIndentDelta
(
0
)
{}
Highlighter
::
BlockData
::~
BlockData
()
...
...
@@ -93,13 +94,15 @@ void Highlighter::configureFormat(TextFormatId id, const QTextCharFormat &format
void
Highlighter
::
setDefaultContext
(
const
QSharedPointer
<
Context
>
&
defaultContext
)
{
m_defaultContext
=
defaultContext
;
m_persistentStates
.
insert
(
m_defaultContext
->
name
(),
Default
);
m_persistent
Observable
States
.
insert
(
m_defaultContext
->
name
(),
Default
);
}
void
Highlighter
::
highlightBlock
(
const
QString
&
text
)
{
if
(
!
m_defaultContext
.
isNull
()
&&
!
m_isBroken
)
{
try
{
if
(
!
currentBlockUserData
())
initializeBlockData
();
setupDataForBlock
(
text
);
handleContextChange
(
m_currentContext
->
lineBeginContext
(),
...
...
@@ -107,20 +110,19 @@ void Highlighter::highlightBlock(const QString &text)
ProgressData
progress
;
const
int
length
=
text
.
length
();
while
(
progress
.
offset
()
<
length
)
{
if
(
progress
.
offset
()
>
0
&&
progress
.
onlySpacesSoFar
()
&&
!
text
.
at
(
progress
.
offset
()).
isSpace
())
{
progress
.
setOnlySpacesSoFar
(
false
);
}
while
(
progress
.
offset
()
<
length
)
iterateThroughRules
(
text
,
length
,
&
progress
,
false
,
m_currentContext
->
rules
());
}
handleContextChange
(
m_currentContext
->
lineEndContext
(),
m_currentContext
->
definition
(),
false
);
m_contexts
.
clear
();
applyFolding
();
// Takes into the account any change that might have affected the region depth since
// the last time the state was set.
setCurrentBlockState
(
computeState
(
extractObservableState
(
currentBlockState
())));
}
catch
(
const
HighlighterException
&
)
{
m_isBroken
=
true
;
}
...
...
@@ -131,60 +133,70 @@ void Highlighter::highlightBlock(const QString &text)
void
Highlighter
::
setupDataForBlock
(
const
QString
&
text
)
{
if
(
currentBlockState
()
==
WillContinue
)
if
(
extractObservableState
(
currentBlockState
()
)
==
WillContinue
)
analyseConsistencyOfWillContinueBlock
(
text
);
if
(
previousBlockState
()
==
Default
||
previousBlockState
()
==
-
1
)
if
(
previousBlockState
()
==
-
1
)
{
m_regionDepth
=
0
;
setupDefault
();
else
if
(
previousBlockState
()
==
WillContinue
)
setupFromWillContinue
();
else
if
(
previousBlockState
()
==
Continued
)
setupFromContinued
();
else
setupFromPersistent
();
setCurrentContext
();
}
else
{
m_regionDepth
=
extractRegionDepth
(
previousBlockState
());
const
int
observablePreviousState
=
extractObservableState
(
previousBlockState
());
if
(
observablePreviousState
==
Default
)
setupDefault
();
else
if
(
observablePreviousState
==
WillContinue
)
setupFromWillContinue
();
else
if
(
observablePreviousState
==
Continued
)
setupFromContinued
();
else
setupFromPersistent
();
blockData
(
currentBlockUserData
())
->
m_foldingRegions
=
blockData
(
currentBlock
().
previous
().
userData
())
->
m_foldingRegions
;
}
assignCurrentContext
();
}
void
Highlighter
::
setupDefault
()
{
m_contexts
.
push_back
(
m_defaultContext
);
setCurrentBlockState
(
Default
);
setCurrentBlockState
(
computeState
(
Default
)
)
;
}
void
Highlighter
::
setupFromWillContinue
()
{
BlockData
*
previousData
=
static_cast
<
B
lockData
*>
(
currentBlock
().
previous
().
userData
());
BlockData
*
previousData
=
b
lockData
(
currentBlock
().
previous
().
userData
());
m_contexts
.
push_back
(
previousData
->
m_contextToContinue
);
if
(
!
currentBlockUserData
())
{
BlockData
*
data
=
initializeBlockData
();
data
->
m_originalState
=
previousData
->
m_originalState
;
}
BlockData
*
data
=
blockData
(
currentBlock
().
userData
());
data
->
m_originalObservableState
=
previousData
->
m_originalObservableState
;
if
(
currentBlockState
()
==
Default
||
currentBlockState
()
==
-
1
)
setCurrentBlockState
(
Continued
);
if
(
currentBlockState
()
==
-
1
||
extractObservableState
(
currentBlockState
()
)
==
Default
)
setCurrentBlockState
(
computeState
(
Continued
)
)
;
}
void
Highlighter
::
setupFromContinued
()
{
BlockData
*
previousData
=
static_cast
<
B
lockData
*>
(
currentBlock
().
previous
().
userData
());
BlockData
*
previousData
=
b
lockData
(
currentBlock
().
previous
().
userData
());
Q_ASSERT
(
previousData
->
m_originalState
!=
WillContinue
&&
previousData
->
m_originalState
!=
Continued
);
Q_ASSERT
(
previousData
->
m_original
Observable
State
!=
WillContinue
&&
previousData
->
m_original
Observable
State
!=
Continued
);
if
(
previousData
->
m_originalState
==
Default
||
previousData
->
m_originalState
==
-
1
)
if
(
previousData
->
m_originalObservableState
==
Default
||
previousData
->
m_originalObservableState
==
-
1
)
{
m_contexts
.
push_back
(
m_defaultContext
);
else
pushContextSequence
(
previousData
->
m_originalState
);
}
else
{
pushContextSequence
(
previousData
->
m_originalObservableState
);
}
setCurrentBlockState
(
previousData
->
m_originalState
);
setCurrentBlockState
(
computeState
(
previousData
->
m_original
Observable
State
)
)
;
}
void
Highlighter
::
setupFromPersistent
()
{
pushContextSequence
(
previousBlockState
());
pushContextSequence
(
extractObservableState
(
previousBlockState
())
)
;
setCurrentBlockState
(
previousBlockState
());
}
...
...
@@ -204,12 +216,30 @@ void Highlighter::iterateThroughRules(const QString &text,
RuleIterator
endIt
=
rules
.
end
();
while
(
it
!=
endIt
&&
progress
->
offset
()
<
length
)
{
int
startOffset
=
progress
->
offset
();
const
QSharedPointer
<
Rule
>
&
rule
=
*
it
;
if
(
rule
->
matchSucceed
(
text
,
length
,
progress
))
{
atLeastOneMatch
=
true
;
if
(
progress
->
willContinueLine
())
{
// Code folding.
if
(
!
rule
->
beginRegion
().
isEmpty
())
{
blockData
(
currentBlockUserData
())
->
m_foldingRegions
.
push
(
rule
->
beginRegion
());
++
m_regionDepth
;
if
(
progress
->
isOpeningBraceMatchAtFirstNonSpace
())
++
blockData
(
currentBlockUserData
())
->
m_foldingIndentDelta
;
}
if
(
!
rule
->
endRegion
().
isEmpty
())
{
QStack
<
QString
>
*
currentRegions
=
&
blockData
(
currentBlockUserData
())
->
m_foldingRegions
;
if
(
!
currentRegions
->
isEmpty
()
&&
rule
->
endRegion
()
==
currentRegions
->
top
())
{
currentRegions
->
pop
();
--
m_regionDepth
;
if
(
progress
->
isClosingBraceMatchAtNonEnd
())
--
blockData
(
currentBlockUserData
())
->
m_foldingIndentDelta
;
}
}
progress
->
clearBracesMatches
();
if
(
progress
->
isWillContinueLine
())
{
createWillContinueBlock
();
progress
->
setWillContinueLine
(
false
);
}
else
{
...
...
@@ -254,6 +284,8 @@ void Highlighter::iterateThroughRules(const QString &text,
}
else
{
applyFormat
(
progress
->
offset
(),
1
,
m_currentContext
->
itemData
(),
m_currentContext
->
definition
());
if
(
progress
->
isOnlySpacesSoFar
()
&&
!
text
.
at
(
progress
->
offset
()).
isSpace
())
progress
->
setOnlySpacesSoFar
(
false
);
progress
->
incrementOffset
();
}
}
...
...
@@ -268,20 +300,22 @@ bool Highlighter::contextChangeRequired(const QString &contextName) const
void
Highlighter
::
changeContext
(
const
QString
&
contextName
,
const
QSharedPointer
<
HighlightDefinition
>
&
definition
,
const
bool
set
Current
)
const
bool
assign
Current
)
{
if
(
contextName
.
startsWith
(
kPop
))
{
QStringList
list
=
contextName
.
split
(
kHash
,
QString
::
SkipEmptyParts
);
for
(
int
i
=
0
;
i
<
list
.
size
();
++
i
)
m_contexts
.
pop_back
();
if
(
currentBlockState
()
>=
PersistentsStart
)
{
if
(
extractObservableState
(
currentBlockState
()
)
>=
PersistentsStart
)
{
// One or more contexts were popped during during a persistent state.
const
QString
&
currentSequence
=
currentContextSequence
();
if
(
m_persistentStates
.
contains
(
currentSequence
))
setCurrentBlockState
(
m_persistentStates
.
value
(
currentSequence
));
if
(
m_persistentObservableStates
.
contains
(
currentSequence
))
setCurrentBlockState
(
computeState
(
m_persistentObservableStates
.
value
(
currentSequence
)));
else
setCurrentBlockState
(
m_leadingStates
.
value
(
currentSequence
));
setCurrentBlockState
(
computeState
(
m_leadingObservableStates
.
value
(
currentSequence
)));
}
}
else
{
const
QSharedPointer
<
Context
>
&
context
=
definition
->
context
(
contextName
);
...
...
@@ -292,19 +326,20 @@ void Highlighter::changeContext(const QString &contextName,
m_contexts
.
push_back
(
context
);
if
(
m_contexts
.
back
()
->
lineEndContext
()
==
kStay
||
currentBlockState
()
>=
PersistentsStart
)
{
extractObservableState
(
currentBlockState
()
)
>=
PersistentsStart
)
{
const
QString
&
currentSequence
=
currentContextSequence
();
mapLeadingSequence
(
currentSequence
);
if
(
m_contexts
.
back
()
->
lineEndContext
()
==
kStay
)
{
// A persistent context was pushed.
mapPersistentSequence
(
currentSequence
);
setCurrentBlockState
(
m_persistentStates
.
value
(
currentSequence
));
setCurrentBlockState
(
computeState
(
m_persistentObservableStates
.
value
(
currentSequence
)));
}
}
}
if
(
set
Current
)
set
CurrentContext
();
if
(
assign
Current
)
assign
CurrentContext
();
}
void
Highlighter
::
handleContextChange
(
const
QString
&
contextName
,
...
...
@@ -378,50 +413,49 @@ void Highlighter::applyVisualWhitespaceFormat(const QString &text)
void
Highlighter
::
createWillContinueBlock
()
{
if
(
!
currentBlockUserData
())
initializeBlockData
();
BlockData
*
data
=
static_cast
<
BlockData
*>
(
currentBlockUserData
());
if
(
currentBlockState
()
==
Continued
)
{
BlockData
*
previousData
=
static_cast
<
BlockData
*>
(
currentBlock
().
previous
().
userData
());
data
->
m_originalState
=
previousData
->
m_originalState
;
}
else
if
(
currentBlockState
()
!=
WillContinue
)
{
data
->
m_originalState
=
currentBlockState
();
BlockData
*
data
=
blockData
(
currentBlockUserData
());
const
int
currentObservableState
=
extractObservableState
(
currentBlockState
());
if
(
currentObservableState
==
Continued
)
{
BlockData
*
previousData
=
blockData
(
currentBlock
().
previous
().
userData
());
data
->
m_originalObservableState
=
previousData
->
m_originalObservableState
;
}
else
if
(
currentObservableState
!=
WillContinue
)
{
data
->
m_originalObservableState
=
currentObservableState
;
}
data
->
m_contextToContinue
=
m_currentContext
;
setCurrentBlockState
(
WillContinue
);
setCurrentBlockState
(
computeState
(
WillContinue
)
)
;
}
void
Highlighter
::
analyseConsistencyOfWillContinueBlock
(
const
QString
&
text
)
{
if
(
currentBlock
().
next
().
isValid
()
&&
(
text
.
length
()
==
0
||
text
.
at
(
text
.
length
()
-
1
)
!=
kBackSlash
)
&&
currentBlock
().
next
().
userState
()
!=
Continued
)
{
currentBlock
().
next
().
setUserState
(
Continued
);
extractObservableState
(
currentBlock
().
next
().
userState
()
)
!=
Continued
)
{
currentBlock
().
next
().
setUserState
(
computeState
(
Continued
)
)
;
}
if
(
text
.
length
()
==
0
||
text
.
at
(
text
.
length
()
-
1
)
!=
kBackSlash
)
{
BlockData
*
data
=
static_cast
<
B
lockData
*>
(
currentBlockUserData
());
BlockData
*
data
=
b
lockData
(
currentBlockUserData
());
data
->
m_contextToContinue
.
clear
();
setCurrentBlockState
(
data
->
m_originalState
);
setCurrentBlockState
(
computeState
(
data
->
m_original
Observable
State
)
)
;
}
}
void
Highlighter
::
mapPersistentSequence
(
const
QString
&
contextSequence
)
{
if
(
!
m_persistentStates
.
contains
(
contextSequence
))
{
int
newState
=
m_persistentStatesCounter
;
m_persistentStates
.
insert
(
contextSequence
,
newState
);
if
(
!
m_persistent
Observable
States
.
contains
(
contextSequence
))
{
int
newState
=
m_persistent
Observable
StatesCounter
;
m_persistent
Observable
States
.
insert
(
contextSequence
,
newState
);
m_persistentContexts
.
insert
(
newState
,
m_contexts
);
++
m_persistentStatesCounter
;
++
m_persistent
Observable
StatesCounter
;
}
}
void
Highlighter
::
mapLeadingSequence
(
const
QString
&
contextSequence
)
{
if
(
!
m_leadingStates
.
contains
(
contextSequence
))
m_leadingStates
.
insert
(
contextSequence
,
currentBlockState
());
if
(
!
m_leadingObservableStates
.
contains
(
contextSequence
))
m_leadingObservableStates
.
insert
(
contextSequence
,
extractObservableState
(
currentBlockState
()));
}
void
Highlighter
::
pushContextSequence
(
int
state
)
...
...
@@ -447,6 +481,11 @@ Highlighter::BlockData *Highlighter::initializeBlockData()
return
data
;
}
Highlighter
::
BlockData
*
Highlighter
::
blockData
(
QTextBlockUserData
*
userData
)
{
return
static_cast
<
BlockData
*>
(
userData
);
}
void
Highlighter
::
pushDynamicContext
(
const
QSharedPointer
<
Context
>
&
baseContext
)
{
// A dynamic context is created from another context which serves as its basis. Then,
...
...
@@ -459,7 +498,7 @@ void Highlighter::pushDynamicContext(const QSharedPointer<Context> &baseContext)
++
m_dynamicContextsCounter
;
}
void
Highlighter
::
set
CurrentContext
()
void
Highlighter
::
assign
CurrentContext
()
{
if
(
m_contexts
.
isEmpty
())
{
// This is not supposed to happen. However, there are broken files (for example, php.xml)
...
...
@@ -469,3 +508,38 @@ void Highlighter::setCurrentContext()
}
m_currentContext
=
m_contexts
.
back
();
}
int
Highlighter
::
extractRegionDepth
(
const
int
state
)
{
return
state
>>
12
;
}
int
Highlighter
::
extractObservableState
(
const
int
state
)
{
return
state
&
0xFFF
;
}
int
Highlighter
::
computeState
(
const
int
observableState
)
const
{
return
m_regionDepth
<<
12
|
observableState
;
}
void
Highlighter
::
applyFolding
()
const
{
int
folding
=
0
;
BlockData
*
data
=
blockData
(
currentBlockUserData
());
BlockData
*
previousData
=
blockData
(
currentBlock
().
previous
().
userData
());
if
(
previousData
)
{
folding
=
extractRegionDepth
(
previousBlockState
());
if
(
data
->
m_foldingIndentDelta
!=
0
)
{
folding
+=
data
->
m_foldingIndentDelta
;
if
(
data
->
m_foldingIndentDelta
>
0
)
data
->
setFoldingStartIncluded
(
true
);
else
previousData
->
setFoldingEndIncluded
(
false
);
data
->
m_foldingIndentDelta
=
0
;
}
}
data
->
setFoldingEndIncluded
(
true
);
data
->
setFoldingIndent
(
folding
);
}
src/plugins/texteditor/generichighlighter/highlighter.h
View file @
f344504d
...
...
@@ -34,6 +34,7 @@
#include
<QtCore/QString>
#include
<QtCore/QVector>
#include
<QtCore/QStack>
#include
<QtCore/QSharedPointer>
#include
<QtCore/QStringList>
...
...
@@ -92,14 +93,14 @@ private:
const
bool
childRule
,
const
QList
<
QSharedPointer
<
Rule
>
>
&
rules
);
void
set
CurrentContext
();
void
assign
CurrentContext
();
bool
contextChangeRequired
(
const
QString
&
contextName
)
const
;
void
handleContextChange
(
const
QString
&
contextName
,
const
QSharedPointer
<
HighlightDefinition
>
&
definition
,
const
bool
setCurrent
=
true
);
void
changeContext
(
const
QString
&
contextName
,
const
QSharedPointer
<
HighlightDefinition
>
&
definition
,
const
bool
set
Current
=
true
);
const
bool
assign
Current
=
true
);
QString
currentContextSequence
()
const
;
void
mapPersistentSequence
(
const
QString
&
contextSequence
);
...
...
@@ -117,6 +118,8 @@ private:
const
QSharedPointer
<
HighlightDefinition
>
&
definition
);
void
applyVisualWhitespaceFormat
(
const
QString
&
text
);
void
applyFolding
()
const
;
// Mapping from Kate format strings to format ids.
struct
KateFormatMap
{
...
...
@@ -131,27 +134,40 @@ private:
BlockData
();
virtual
~
BlockData
();
int
m_originalState
;
int
m_foldingIndentDelta
;
int
m_originalObservableState
;
QStack
<
QString
>
m_foldingRegions
;
QSharedPointer
<
Context
>
m_contextToContinue
;
};
BlockData
*
initializeBlockData
();
static
BlockData
*
blockData
(
QTextBlockUserData
*
userData
);
// Block states
// Block states are composed by the region depth (used for code folding) and what I call
// observable states. Observable states occupy the 12 least significant bits. They might have
// the following values:
// - Default [0]: Nothing special.
// - WillContinue [1]: When there is match of the LineContinue rule (backslash as the last
// character).
// - Continued [2]: Blocks that happen after a WillContinue block and continue
d
from their
// - Continued [2]: Blocks that happen after a WillContinue block and continue from their
// context until the next line end.
// - Persistent(s) [Anything >= 3]: Correspond to persistent contexts which last until a pop
// occurs due to a matching rule. Every sequence of persistent contexts seen so far is
// associated with a number (incremented by a unit each time).
enum
BlockState
{
// Region depths occupy the remaining bits.
enum
ObservableBlockState
{
Default
=
0
,
WillContinue
,
Continued
,
PersistentsStart
};
int
m_persistentStatesCounter
;
int
computeState
(
const
int
observableState
)
const
;
static
int
extractRegionDepth
(
const
int
state
);
static
int
extractObservableState
(
const
int
state
);
int
m_regionDepth
;
int
m_persistentObservableStatesCounter
;
int
m_dynamicContextsCounter
;
bool
m_isBroken
;
...
...
@@ -160,11 +176,11 @@ private:
QSharedPointer
<
Context
>
m_currentContext
;
QVector
<
QSharedPointer
<
Context
>
>
m_contexts
;
// Mapping from context sequences to the persistent state they represent.
QHash
<
QString
,
int
>
m_persistentStates
;
// Mapping from context sequences to the non-persistent state that led to them.
QHash
<
QString
,
int
>
m_leadingStates
;
// Mapping from persistent states to context sequences (the actual "stack").
// Mapping from context sequences to the
observable
persistent state they represent.
QHash
<
QString
,
int
>
m_persistent
Observable
States
;
// Mapping from context sequences to the non-persistent
observable
state that led to them.
QHash
<
QString
,
int
>
m_leading
Observable
States
;
// Mapping from
observable
persistent states to context sequences (the actual "stack").
QHash
<
int
,
QVector
<
QSharedPointer
<
Context
>
>
>
m_persistentContexts
;
// Captures used in dynamic rules.
...
...
src/plugins/texteditor/generichighlighter/progressdata.cpp
View file @
f344504d
...
...
@@ -38,7 +38,9 @@ ProgressData::ProgressData() :
m_offset
(
0
),
m_savedOffset
(
-
1
),
m_onlySpacesSoFar
(
true
),
m_willContinueLine
(
false
)
m_willContinueLine
(
false
),
m_openingBraceMatchAtFirstNonSpace
(
false
),
m_closingBraceMatchAtNonEnd
(
false
)
{}
void
ProgressData
::
setOffset
(
const
int
offset
)
...
...
@@ -66,13 +68,33 @@ void ProgressData::restoreOffset()
void
ProgressData
::
setOnlySpacesSoFar
(
const
bool
onlySpaces
)
{
m_onlySpacesSoFar
=
onlySpaces
;
}
bool
ProgressData
::
o
nlySpacesSoFar
()
const
bool
ProgressData
::
isO
nlySpacesSoFar
()
const
{
return
m_onlySpacesSoFar
;
}
void
ProgressData
::
setOpeningBraceMatchAtFirstNonSpace
(
const
bool
match
)
{
m_openingBraceMatchAtFirstNonSpace
=
match
;
}
bool
ProgressData
::
isOpeningBraceMatchAtFirstNonSpace
()
const
{
return
m_openingBraceMatchAtFirstNonSpace
;
}
void
ProgressData
::
setClosingBraceMatchAtNonEnd
(
const
bool
match
)
{
m_closingBraceMatchAtNonEnd
=
match
;
}
bool
ProgressData
::
isClosingBraceMatchAtNonEnd
()
const
{
return
m_closingBraceMatchAtNonEnd
;
}
void
ProgressData
::
clearBracesMatches
()
{
if
(
m_openingBraceMatchAtFirstNonSpace
)
m_openingBraceMatchAtFirstNonSpace
=
false
;
if
(
m_closingBraceMatchAtNonEnd
)
m_closingBraceMatchAtNonEnd
=
false
;
}
void
ProgressData
::
setWillContinueLine
(
const
bool
willContinue
)
{
m_willContinueLine
=
willContinue
;
}
bool
ProgressData
::
w
illContinueLine
()
const
bool
ProgressData
::
isW
illContinueLine
()
const
{
return
m_willContinueLine
;
}
void
ProgressData
::
setCaptures
(
const
QStringList
&
captures
)
...
...
src/plugins/texteditor/generichighlighter/progressdata.h
View file @
f344504d
...
...
@@ -50,10 +50,18 @@ public:
void
restoreOffset
();
void
setOnlySpacesSoFar
(
const
bool
onlySpaces
);
bool
onlySpacesSoFar
()
const
;
bool
isOnlySpacesSoFar
()
const
;
void
setOpeningBraceMatchAtFirstNonSpace
(
const
bool
match
);
bool
isOpeningBraceMatchAtFirstNonSpace
()
const
;
void
setClosingBraceMatchAtNonEnd
(
const
bool
match
);
bool
isClosingBraceMatchAtNonEnd
()
const
;
void
clearBracesMatches
();
void
setWillContinueLine
(
const
bool
willContinue
);
bool
w
illContinueLine
()
const
;
bool
isW
illContinueLine
()
const
;
void
setCaptures
(
const
QStringList
&
captures
);
const
QStringList
&
captures
()
const
;
...
...
@@ -62,6 +70,8 @@ private:
int
m_offset
;
int
m_savedOffset
;
bool
m_onlySpacesSoFar
;
bool
m_openingBraceMatchAtFirstNonSpace
;
bool
m_closingBraceMatchAtNonEnd
;
bool
m_willContinueLine
;
QStringList
m_captures
;
};
...
...
src/plugins/texteditor/generichighlighter/rule.cpp
View file @
f344504d
...
...
@@ -58,6 +58,8 @@ const QLatin1Char Rule::kN('n');
const
QLatin1Char
Rule
::
kR
(
'r'
);
const
QLatin1Char
Rule
::
kT
(
't'
);
const
QLatin1Char
Rule
::
kV
(
'v'
);
const
QLatin1Char
Rule
::
kOpeningBrace
(
'{'
);
const
QLatin1Char
Rule
::
kClosingBrace
(
'}'
);
Rule
::
Rule
(
bool
consumesNonSpace
)
:
m_lookAhead
(
false
),
m_firstNonSpace
(
false
),
m_column
(
-
1
),
m_consumesNonSpace
(
consumesNonSpace
)
...
...
@@ -162,7 +164,7 @@ bool Rule::charPredicateMatchSucceed(const QString &text,
bool
Rule
::
matchSucceed
(
const
QString
&
text
,
const
int
length
,
ProgressData
*
progress
)
const
{
if
(
m_firstNonSpace
&&
!
progress
->
o
nlySpacesSoFar
())
if
(
m_firstNonSpace
&&
!
progress
->
isO
nlySpacesSoFar
())
return
false
;
if
(
m_column
!=
-
1
&&
m_column
!=
progress
->
offset
())
...
...
@@ -170,7 +172,7 @@ bool Rule::matchSucceed(const QString &text, const int length, ProgressData *pro
int
original
=
progress
->
offset
();
if
(
doMatchSucceed
(
text
,
length
,
progress
))
{
if
(
progress
->
o
nlySpacesSoFar
()
&&
!
m_lookAhead
&&
m_consumesNonSpace
)
if
(
progress
->
isO
nlySpacesSoFar
()
&&
!
m_lookAhead
&&
m_consumesNonSpace
)
progress
->
setOnlySpacesSoFar
(
false
);
if
(
m_lookAhead
)
...
...
src/plugins/texteditor/generichighlighter/rule.h
View file @
f344504d
...
...
@@ -123,7 +123,9 @@ protected:
static
const
QLatin1Char
kN
;
static
const
QLatin1Char
kR
;
static
const
QLatin1Char
kT
;
static
const
QLatin1Char
kV
;
static
const
QLatin1Char
kV
;
static
const
QLatin1Char
kOpeningBrace
;
static
const
QLatin1Char
kClosingBrace
;