aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Felt <olivier.felt@kdemail.net>2016-09-03 20:31:42 (GMT)
committerSven Brauch <mail@svenbrauch.de>2016-09-03 20:32:14 (GMT)
commit0e1086254f2609b5fa6324af19a1d8451fb50e28 (patch)
treee8280f71b207f3a82836e75981ccb0cdd6155644
parentd4a2f3d9e2e63d190ab9550c13aa4750fe72e442 (diff)
Add tooltip to symbolsviewer plugin
Differential revision: https://phabricator.kde.org/D2513
-rw-r--r--addons/symbolviewer/cpp_parser.cpp2
-rw-r--r--addons/symbolviewer/php_parser.cpp57
-rw-r--r--addons/symbolviewer/ruby_parser.cpp15
3 files changed, 44 insertions, 30 deletions
diff --git a/addons/symbolviewer/cpp_parser.cpp b/addons/symbolviewer/cpp_parser.cpp
index d2dd493..c1a90f1 100644
--- a/addons/symbolviewer/cpp_parser.cpp
+++ b/addons/symbolviewer/cpp_parser.cpp
@@ -242,6 +242,7 @@ void KatePluginSymbolViewerView::parseCppSymbols(void)
stripped.replace(0x9, QLatin1String(" "));
if(func_on == true)
{
+ QString strippedWithTypes = stripped;
if (m_plugin->typesOn == false)
{
while (stripped.indexOf(QLatin1Char('(')) >= 0)
@@ -278,6 +279,7 @@ void KatePluginSymbolViewerView::parseCppSymbols(void)
if (mclass == 4) node->setIcon(0, QIcon(mtd));
else node->setIcon(0, QIcon(cls));
node->setText(1, QString::number( tmpPos, 10));
+ node->setToolTip(0, strippedWithTypes);
}
stripped.clear();
//retry = 0;
diff --git a/addons/symbolviewer/php_parser.cpp b/addons/symbolviewer/php_parser.cpp
index 0758fe5..cfdd7eb 100644
--- a/addons/symbolviewer/php_parser.cpp
+++ b/addons/symbolviewer/php_parser.cpp
@@ -87,6 +87,7 @@ void KatePluginSymbolViewerView::parsePhpSymbols(void)
QRegExp functionArgsRegExp(QLatin1String("(\\$[\\w_]+)"), Qt::CaseInsensitive);
QStringList functionArgsList;
QString functionArgs;
+ QString nameWithTypes;
// replace literals by empty strings: “function a($b='nothing', $c="pretty \"cool\" string")” => “function ($b='', $c="")”
QRegExp literalRegExp(QLatin1String("([\"'])(?:\\\\.|[^\\\\])*\\1"));
@@ -210,17 +211,20 @@ void KatePluginSymbolViewerView::parsePhpSymbols(void)
}
if (isClass)
{
- if (m_plugin->typesOn && !classRegExp.cap(1).trimmed().isEmpty() && !classRegExp.cap(4).trimmed().isEmpty())
- {
- node->setText(0, classRegExp.cap(3)+QLatin1String(" [")+classRegExp.cap(1).trimmed()+QLatin1Char(',')+classRegExp.cap(4).trimmed()+QLatin1Char(']'));
- }
- else if (m_plugin->typesOn && !classRegExp.cap(1).trimmed().isEmpty())
- {
- node->setText(0, classRegExp.cap(3)+QLatin1String(" [")+classRegExp.cap(1).trimmed()+QLatin1Char(']'));
- }
- else if (m_plugin->typesOn && !classRegExp.cap(4).trimmed().isEmpty())
- {
- node->setText(0, classRegExp.cap(3)+QLatin1String(" [")+classRegExp.cap(4).trimmed()+QLatin1Char(']'));
+ if (m_plugin->typesOn) {
+ if (!classRegExp.cap(1).trimmed().isEmpty() && !classRegExp.cap(4).trimmed().isEmpty())
+ {
+ nameWithTypes = classRegExp.cap(3)+QLatin1String(" [")+classRegExp.cap(1).trimmed()+QLatin1Char(',')+classRegExp.cap(4).trimmed()+QLatin1Char(']');
+ }
+ else if (!classRegExp.cap(1).trimmed().isEmpty())
+ {
+ nameWithTypes = classRegExp.cap(3)+QLatin1String(" [")+classRegExp.cap(1).trimmed()+QLatin1Char(']');
+ }
+ else if (!classRegExp.cap(4).trimmed().isEmpty())
+ {
+ nameWithTypes = classRegExp.cap(3)+QLatin1String(" [")+classRegExp.cap(4).trimmed()+QLatin1Char(']');
+ }
+ node->setText(0, nameWithTypes);
}
else
{
@@ -231,7 +235,8 @@ void KatePluginSymbolViewerView::parsePhpSymbols(void)
{
if (m_plugin->typesOn)
{
- node->setText(0, interfaceRegExp.cap(1) + QLatin1String(" [interface]"));
+ nameWithTypes = interfaceRegExp.cap(1) + QLatin1String(" [interface]");
+ node->setText(0, nameWithTypes);
}
else
{
@@ -240,6 +245,7 @@ void KatePluginSymbolViewerView::parsePhpSymbols(void)
}
node->setIcon(0, QIcon(classPix));
node->setText(1, QString::number( i, 10));
+ node->setToolTip(0, nameWithTypes);
inClass = true;
inFunction = false;
}
@@ -295,26 +301,31 @@ void KatePluginSymbolViewerView::parsePhpSymbols(void)
node = new QTreeWidgetItem(m_symbols);
}
+ QString functionArgs(functionRegExp.cap(5));
+ pos = 0;
+ while (pos >= 0) {
+ pos = functionArgsRegExp.indexIn(functionArgs, pos);
+ if (pos >= 0) {
+ pos += functionArgsRegExp.matchedLength();
+ functionArgsList += functionArgsRegExp.cap(1);
+ }
+ }
+
+ nameWithTypes = functionRegExp.cap(4) + QLatin1Char('(') + functionArgsList.join(QLatin1String(", ")) + QLatin1Char(')');
if (m_plugin->typesOn)
{
- QString functionArgs(functionRegExp.cap(5));
- pos = 0;
- while (pos >= 0) {
- pos = functionArgsRegExp.indexIn(functionArgs, pos);
- if (pos >= 0) {
- pos += functionArgsRegExp.matchedLength();
- functionArgsList += functionArgsRegExp.cap(1);
- }
- }
- node->setText(0, functionRegExp.cap(4) + QLatin1Char('(') + functionArgsList.join(QLatin1String(", ")) + QLatin1Char(')'));
- functionArgsList.clear();
+ node->setText(0, nameWithTypes);
}
else
{
node->setText(0, functionRegExp.cap(4));
}
+
node->setIcon(0, QIcon(functionPix));
node->setText(1, QString::number( i, 10));
+ node->setToolTip(0, nameWithTypes);
+
+ functionArgsList.clear();
inFunction = true;
}
diff --git a/addons/symbolviewer/ruby_parser.cpp b/addons/symbolviewer/ruby_parser.cpp
index f119513..63a7896 100644
--- a/addons/symbolviewer/ruby_parser.cpp
+++ b/addons/symbolviewer/ruby_parser.cpp
@@ -60,7 +60,6 @@ void KatePluginSymbolViewerView::parseRubySymbols(void)
if (cl.indexOf( QRegExp(QLatin1String("^class [a-zA-Z0-9]+[^#]")) ) >= 0)
{
- name = cl.mid(6);
if (func_on == true)
{
if (m_plugin->treeOn)
@@ -72,18 +71,13 @@ void KatePluginSymbolViewerView::parseRubySymbols(void)
lastMtdNode = lastClsNode;
}
else node = new QTreeWidgetItem(m_symbols);
- node->setText(0, name);
+ node->setText(0, cl.mid(6));
node->setIcon(0, QIcon(cls));
node->setText(1, QString::number( i, 10));
}
}
if (cl.indexOf( QRegExp(QLatin1String("^def [a-zA-Z_]+[^#]")) ) >= 0 )
{
- name = cl.mid(4);
- if (m_plugin->typesOn == false)
- {
- name = name.left(name.indexOf(QLatin1Char('(')));
- }
if (struct_on == true)
{
if (m_plugin->treeOn)
@@ -92,6 +86,13 @@ void KatePluginSymbolViewerView::parseRubySymbols(void)
lastMtdNode = node;
}
else node = new QTreeWidgetItem(m_symbols);
+
+ name = cl.mid(4);
+ node->setToolTip(0, name);
+ if (m_plugin->typesOn == false)
+ {
+ name = name.left(name.indexOf(QLatin1Char('(')));
+ }
node->setText(0, name);
node->setIcon(0, QIcon(mtd));
node->setText(1, QString::number( i, 10));