Skip to content
GitLab
Menu
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
20e36cc3
Commit
20e36cc3
authored
Dec 09, 2008
by
Roberto Raggi
Browse files
tooltip for macro definitions.
parent
4a552ead
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/libs/cplusplus/CppDocument.cpp
View file @
20e36cc3
...
...
@@ -146,9 +146,9 @@ void Document::appendMacro(const Macro ¯o)
_definedMacros
.
append
(
macro
);
}
void
Document
::
addMacroUse
(
unsigned
offset
,
unsigned
length
)
void
Document
::
addMacroUse
(
const
Macro
&
macro
,
unsigned
offset
,
unsigned
length
)
{
_macroUses
.
append
(
Block
(
offset
,
offset
+
length
));
_macroUses
.
append
(
MacroUse
(
macro
,
offset
,
offset
+
length
));
}
TranslationUnit
*
Document
::
translationUnit
()
const
...
...
src/libs/cplusplus/CppDocument.h
View file @
20e36cc3
...
...
@@ -68,8 +68,7 @@ public:
void
addIncludeFile
(
const
QString
&
fileName
);
void
appendMacro
(
const
Macro
&
macro
);
void
addMacroUse
(
unsigned
offset
,
unsigned
length
);
void
addMacroUse
(
const
Macro
&
macro
,
unsigned
offset
,
unsigned
length
);
Control
*
control
()
const
;
TranslationUnit
*
translationUnit
()
const
;
...
...
@@ -177,12 +176,30 @@ public:
inline
unsigned
end
()
const
{
return
_end
;
}
bool
contains
(
unsigned
pos
)
const
{
return
pos
>=
_begin
&&
pos
<
_end
;
}
};
class
MacroUse
:
public
Block
{
Macro
_macro
;
public:
inline
MacroUse
(
const
Macro
&
macro
,
unsigned
begin
=
0
,
unsigned
end
=
0
)
:
Block
(
begin
,
end
),
_macro
(
macro
)
{
}
const
Macro
&
macro
()
const
{
return
_macro
;
}
};
QList
<
Block
>
skippedBlocks
()
const
{
return
_skippedBlocks
;
}
QList
<
Block
>
macroUses
()
const
QList
<
MacroUse
>
macroUses
()
const
{
return
_macroUses
;
}
private:
...
...
@@ -197,7 +214,7 @@ private:
QList
<
DiagnosticMessage
>
_diagnosticMessages
;
QList
<
Macro
>
_definedMacros
;
QList
<
Block
>
_skippedBlocks
;
QList
<
Block
>
_macroUses
;
QList
<
MacroUse
>
_macroUses
;
};
}
// end of namespace CPlusPlus
...
...
src/libs/cplusplus/pp-engine.cpp
View file @
20e36cc3
...
...
@@ -604,28 +604,29 @@ void pp::operator()(const QByteArray &source, QByteArray *result)
m
->
definition
.
constEnd
(),
result
);
m
->
hidden
=
false
;
if
(
client
)
client
->
stopExpandingMacro
(
_dot
->
offset
,
*
m
);
m
->
hidden
=
false
;
continue
;
}
else
{
QByteArray
tmp
;
m
->
hidden
=
true
;
if
(
client
)
client
->
startExpandingMacro
(
identifierToken
->
offset
,
*
m
,
spell
);
m
->
hidden
=
true
;
expand
(
m
->
definition
.
constBegin
(),
m
->
definition
.
constEnd
(),
&
tmp
);
m
->
hidden
=
false
;
if
(
client
)
client
->
stopExpandingMacro
(
_dot
->
offset
,
*
m
);
m
->
hidden
=
false
;
m
=
0
;
// reset the active the macro
pushState
(
createStateFromSource
(
tmp
));
...
...
src/libs/cplusplus/pp-macro.h
View file @
20e36cc3
...
...
@@ -57,6 +57,7 @@
#include <QByteArray>
#include <QVector>
#include <QString>
namespace
CPlusPlus
{
...
...
@@ -89,6 +90,33 @@ public:
hashcode
(
0
),
state
(
0
)
{
}
QString
toString
()
const
{
QString
text
;
if
(
hidden
)
text
+=
QLatin1String
(
"#undef "
);
else
text
+=
QLatin1String
(
"#define "
);
text
+=
QString
::
fromUtf8
(
name
.
constData
(),
name
.
size
());
if
(
function_like
)
{
text
+=
QLatin1Char
(
'('
);
bool
first
=
true
;
foreach
(
const
QByteArray
formal
,
formals
)
{
if
(
!
first
)
text
+=
QLatin1String
(
", "
);
else
first
=
false
;
text
+=
QString
::
fromUtf8
(
formal
.
constData
(),
formal
.
size
());
}
if
(
variadics
)
text
+=
QLatin1String
(
"..."
);
text
+=
QLatin1Char
(
' '
);
}
text
+=
QLatin1Char
(
' '
);
text
+=
QString
::
fromUtf8
(
definition
.
constData
(),
definition
.
size
());
return
text
;
}
};
}
// namespace CPlusPlus
...
...
src/plugins/cpptools/cpphoverhandler.cpp
View file @
20e36cc3
...
...
@@ -37,6 +37,7 @@
#include <coreplugin/icore.h>
#include <coreplugin/uniqueidmanager.h>
#include <texteditor/itexteditor.h>
#include <texteditor/basetexteditor.h>
#include <debugger/debuggerconstants.h>
#include <CoreTypes.h>
...
...
@@ -51,13 +52,13 @@
#include <cplusplus/TypeOfExpression.h>
#include <QtGui/QToolTip>
#include <QtGui/QPlainTextEdit>
#include <QtGui/QTextCursor>
#include <QtGui/QTextBlock>
#include <QtHelp/QHelpEngineCore>
#include <QtCore/QtCore>
using
namespace
CppTools
::
Internal
;
using
namespace
CPlusPlus
;
CppHoverHandler
::
CppHoverHandler
(
CppModelManager
*
manager
,
QObject
*
parent
)
:
QObject
(
parent
),
m_manager
(
manager
),
m_helpEngineNeedsSetup
(
false
)
...
...
@@ -104,11 +105,9 @@ void CppHoverHandler::showToolTip(TextEditor::ITextEditor *editor, const QPoint
}
}
static
QString
buildHelpId
(
const
CPlusPlus
::
FullySpecifiedType
&
type
,
const
CPlusPlus
::
Symbol
*
symbol
)
static
QString
buildHelpId
(
const
FullySpecifiedType
&
type
,
const
Symbol
*
symbol
)
{
using
namespace
CPlusPlus
;
Name
*
name
=
0
;
Scope
*
scope
=
0
;
...
...
@@ -156,12 +155,10 @@ static QString buildHelpId(const CPlusPlus::FullySpecifiedType &type,
void
CppHoverHandler
::
updateHelpIdAndTooltip
(
TextEditor
::
ITextEditor
*
editor
,
int
pos
)
{
using
namespace
CPlusPlus
;
m_helpId
.
clear
();
m_toolTip
.
clear
();
QPlain
TextEdit
*
edit
=
qobject_cast
<
QPlain
TextEdit
*>
(
editor
->
widget
());
TextEditor
::
Base
TextEdit
or
*
edit
=
qobject_cast
<
TextEditor
::
Base
TextEdit
or
*>
(
editor
->
widget
());
if
(
!
edit
)
return
;
...
...
@@ -169,8 +166,7 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in
tc
.
setPosition
(
pos
);
const
int
lineNumber
=
tc
.
block
().
blockNumber
()
+
1
;
QString
fileName
=
editor
->
file
()
->
fileName
();
const
QString
fileName
=
editor
->
file
()
->
fileName
();
Document
::
Ptr
doc
=
m_manager
->
document
(
fileName
);
if
(
doc
)
{
foreach
(
Document
::
DiagnosticMessage
m
,
doc
->
diagnosticMessages
())
{
...
...
@@ -179,6 +175,15 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in
break
;
}
}
if
(
m_toolTip
.
isEmpty
())
{
foreach
(
const
Document
::
MacroUse
use
,
doc
->
macroUses
())
{
if
(
use
.
contains
(
pos
))
{
m_toolTip
=
use
.
macro
().
toString
();
break
;
}
}
}
}
if
(
m_toolTip
.
isEmpty
())
{
...
...
src/plugins/cpptools/cppmodelmanager.cpp
View file @
20e36cc3
...
...
@@ -302,14 +302,14 @@ void CppPreprocessor::macroAdded(const Macro ¯o)
}
void
CppPreprocessor
::
startExpandingMacro
(
unsigned
offset
,
const
Macro
&
,
const
Macro
&
macro
,
const
QByteArray
&
originalText
)
{
if
(
!
m_currentDoc
)
return
;
//qDebug() << "start expanding:" << macro.name << "text:" << originalText;
m_currentDoc
->
addMacroUse
(
offset
,
originalText
.
length
());
m_currentDoc
->
addMacroUse
(
macro
,
offset
,
originalText
.
length
());
}
void
CppPreprocessor
::
stopExpandingMacro
(
unsigned
,
const
Macro
&
)
...
...
Write
Preview
Supports
Markdown
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