summaryrefslogtreecommitdiff
path: root/src/libs/cplusplus/Macro.cpp
diff options
context:
space:
mode:
authorLeandro Melo <leandro.melo@nokia.com>2011-09-06 11:50:58 +0200
committerLeandro T. C. Melo <leandro.melo@nokia.com>2011-09-06 14:21:04 +0200
commitd91c218d540e3b4753f1fba98fa4c72c27cf39f8 (patch)
treece9c69bcca535fe5d732f3e6efca8797e6174024 /src/libs/cplusplus/Macro.cpp
parentb2374640457c4594d4d4b9a21d02be61921253eb (diff)
downloadqt-creator-d91c218d540e3b4753f1fba98fa4c72c27cf39f8.tar.gz
C++: More flexibility for string representation of macros
It's now possible to get the macro definition with the actual line breaks used on the code. This is particularly useful for tooltips in order for them to look nice. The preprocessor is changed so the macro also stores the breaks positions. This doesn't seem to have any impact on performance. In my machine, for example, the total time for parsing Creator's source code is approx. 18100ms with or without the patch. Change-Id: Ic7487236315c3567d26496315accdb2adfea894a Reviewed-on: http://codereview.qt.nokia.com/4253 Reviewed-by: Christian Kamm <christian.d.kamm@nokia.com>
Diffstat (limited to 'src/libs/cplusplus/Macro.cpp')
-rw-r--r--src/libs/cplusplus/Macro.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/libs/cplusplus/Macro.cpp b/src/libs/cplusplus/Macro.cpp
index 402ce4ae9c..8247e26adc 100644
--- a/src/libs/cplusplus/Macro.cpp
+++ b/src/libs/cplusplus/Macro.cpp
@@ -62,7 +62,7 @@ Macro::Macro()
_state(0)
{ }
-QString Macro::toString() const
+QString Macro::decoratedName() const
{
QString text;
if (f._hidden)
@@ -85,6 +85,25 @@ QString Macro::toString() const
text += QLatin1Char(')');
}
text += QLatin1Char(' ');
- text += QString::fromUtf8(_definition.constData(), _definition.size());
+ return text;
+}
+
+QString Macro::toString() const
+{
+ QString text = decoratedName();
+ text.append(QString::fromUtf8(_definition.constData(), _definition.size()));
+ return text;
+}
+
+QString Macro::toStringWithLineBreaks() const
+{
+ if (_lineBreaks.isEmpty())
+ return toString();
+
+ QString text = decoratedName();
+ QString definitionWithBreaks = QString::fromUtf8(_definition.constData(), _definition.size());
+ foreach (unsigned pos, _lineBreaks)
+ definitionWithBreaks[pos] = '\n';
+ text.append(definitionWithBreaks);
return text;
}