Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
3d3802d5
Commit
3d3802d5
authored
Dec 04, 2008
by
Roberto Raggi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added macro expanding events and some initial on the macro highlighting support.
parent
10053aa6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
87 additions
and
2 deletions
+87
-2
src/libs/cplusplus/CppDocument.cpp
src/libs/cplusplus/CppDocument.cpp
+5
-0
src/libs/cplusplus/CppDocument.h
src/libs/cplusplus/CppDocument.h
+6
-0
src/plugins/cpptools/cppmodelmanager.cpp
src/plugins/cpptools/cppmodelmanager.cpp
+35
-0
src/plugins/cpptools/rpp/pp-client.h
src/plugins/cpptools/rpp/pp-client.h
+9
-0
src/plugins/cpptools/rpp/pp-engine.cpp
src/plugins/cpptools/rpp/pp-engine.cpp
+32
-2
No files found.
src/libs/cplusplus/CppDocument.cpp
View file @
3d3802d5
...
...
@@ -153,6 +153,11 @@ void Document::appendMacro(const QByteArray ¯oName, const QByteArray &text)
_definedMacros
+=
text
;
}
void
Document
::
addMacroUse
(
unsigned
offset
,
unsigned
length
)
{
_macroUses
.
append
(
Block
(
offset
,
offset
+
length
));
}
TranslationUnit
*
Document
::
translationUnit
()
const
{
return
_translationUnit
;
...
...
src/libs/cplusplus/CppDocument.h
View file @
3d3802d5
...
...
@@ -68,6 +68,8 @@ public:
void
appendMacro
(
const
QByteArray
&
macroName
,
const
QByteArray
&
text
);
void
addMacroUse
(
unsigned
offset
,
unsigned
length
);
Control
*
control
()
const
;
TranslationUnit
*
translationUnit
()
const
;
...
...
@@ -176,6 +178,9 @@ public:
QList
<
Block
>
skippedBlocks
()
const
{
return
_skippedBlocks
;
}
QList
<
Block
>
macroUses
()
const
{
return
_macroUses
;
}
private:
Symbol
*
findSymbolAt
(
unsigned
line
,
unsigned
column
,
Scope
*
scope
)
const
;
...
...
@@ -189,6 +194,7 @@ private:
QByteArray
_definedMacros
;
QSet
<
QByteArray
>
_macroNames
;
QList
<
Block
>
_skippedBlocks
;
QList
<
Block
>
_macroUses
;
};
}
// end of namespace CPlusPlus
...
...
src/plugins/cpptools/cppmodelmanager.cpp
View file @
3d3802d5
...
...
@@ -253,6 +253,25 @@ protected:
m_currentDoc
->
appendMacro
(
macroName
,
macroText
);
}
virtual
void
startExpandingMacro
(
unsigned
offset
,
const
rpp
::
Macro
&
macro
,
const
QByteArray
&
originalText
)
{
if
(
!
m_currentDoc
)
return
;
//qDebug() << "start expanding:" << macro.name << "text:" << originalText;
m_currentDoc
->
addMacroUse
(
offset
,
originalText
.
length
());
}
virtual
void
stopExpandingMacro
(
unsigned
offset
,
const
rpp
::
Macro
&
macro
)
{
if
(
!
m_currentDoc
)
return
;
//qDebug() << "stop expanding:" << macro.name;
}
void
mergeEnvironment
(
Document
::
Ptr
doc
)
{
QSet
<
QString
>
processed
;
...
...
@@ -595,6 +614,22 @@ void CppModelManager::onDocumentUpdated(Document::Ptr doc)
QList
<
QTextEdit
::
ExtraSelection
>
selections
;
#ifdef QTCREATOR_WITH_MACRO_HIGHLIGHTING
// set up the format for the macros
QTextCharFormat
macroFormat
;
macroFormat
.
setUnderlineStyle
(
QTextCharFormat
::
SingleUnderline
);
QTextCursor
c
=
ed
->
textCursor
();
foreach
(
const
Document
::
Block
block
,
doc
->
macroUses
())
{
QTextEdit
::
ExtraSelection
sel
;
sel
.
cursor
=
c
;
sel
.
cursor
.
setPosition
(
block
.
begin
());
sel
.
cursor
.
setPosition
(
block
.
end
(),
QTextCursor
::
KeepAnchor
);
sel
.
format
=
macroFormat
;
selections
.
append
(
sel
);
}
#endif // QTCREATOR_WITH_MACRO_HIGHLIGHTING
// set up the format for the errors
QTextCharFormat
errorFormat
;
errorFormat
.
setUnderlineStyle
(
QTextCharFormat
::
WaveUnderline
);
...
...
src/plugins/cpptools/rpp/pp-client.h
View file @
3d3802d5
...
...
@@ -40,6 +40,8 @@
namespace
rpp
{
class
Macro
;
class
Client
{
Client
(
const
Client
&
other
);
...
...
@@ -61,6 +63,13 @@ public:
virtual
void
macroAdded
(
const
QByteArray
&
macroId
,
const
QByteArray
&
text
)
=
0
;
virtual
void
sourceNeeded
(
QString
&
fileName
,
IncludeType
mode
)
=
0
;
// ### FIX the signature.
virtual
void
startExpandingMacro
(
unsigned
offset
,
const
Macro
&
macro
,
const
QByteArray
&
originalTextt
)
=
0
;
virtual
void
stopExpandingMacro
(
unsigned
offset
,
const
Macro
&
macro
)
=
0
;
virtual
void
startSkippingBlocks
(
unsigned
offset
)
=
0
;
virtual
void
stopSkippingBlocks
(
unsigned
offset
)
=
0
;
};
...
...
src/plugins/cpptools/rpp/pp-engine.cpp
View file @
3d3802d5
...
...
@@ -575,7 +575,17 @@ void pp::operator()(const QByteArray &source, QByteArray *result)
const
QByteArray
spell
=
tokenSpell
(
*
identifierToken
);
if
(
env
.
isBuiltinMacro
(
spell
))
{
const
Macro
trivial
;
if
(
client
)
client
->
startExpandingMacro
(
identifierToken
->
offset
,
trivial
,
spell
);
expand
(
spell
.
constBegin
(),
spell
.
constEnd
(),
result
);
if
(
client
)
client
->
stopExpandingMacro
(
_dot
->
offset
,
trivial
);
continue
;
}
...
...
@@ -585,10 +595,19 @@ void pp::operator()(const QByteArray &source, QByteArray *result)
}
else
{
if
(
!
m
->
function_like
)
{
if
(
_dot
->
isNot
(
T_LPAREN
))
{
if
(
client
)
client
->
startExpandingMacro
(
identifierToken
->
offset
,
*
m
,
spell
);
m
->
hidden
=
true
;
expand
(
m
->
definition
.
constBegin
(),
m
->
definition
.
constEnd
(),
result
);
if
(
client
)
client
->
stopExpandingMacro
(
_dot
->
offset
,
*
m
);
m
->
hidden
=
false
;
continue
;
}
else
{
...
...
@@ -640,9 +659,20 @@ void pp::operator()(const QByteArray &source, QByteArray *result)
const
char
*
beginOfText
=
startOfToken
(
*
identifierToken
);
const
char
*
endOfText
=
endOfToken
(
*
_dot
);
++
_dot
;
// skip T_RPAREN
//m->hidden = true;
if
(
client
)
{
const
QByteArray
text
=
QByteArray
::
fromRawData
(
beginOfText
,
endOfText
-
beginOfText
);
client
->
startExpandingMacro
(
identifierToken
->
offset
,
*
m
,
text
);
}
expand
(
beginOfText
,
endOfText
,
result
);
//m->hidden = false;
if
(
client
)
client
->
stopExpandingMacro
(
_dot
->
offset
,
*
m
);
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment