1
/***************************************************************************
2
perl_parser.cpp - description
5
author : 2003 Massimo Callegari
6
email : massimocallegari@yahoo.it
7
***************************************************************************/
8
/***************************************************************************
10
* This program is free software; you can redistribute it and/or modify *
11
* it under the terms of the GNU General Public License as published by *
12
* the Free Software Foundation; either version 2 of the License, or *
13
* (at your option) any later version. *
15
***************************************************************************/
16
#include "plugin_katesymbolviewer.h"
18
void KatePluginSymbolViewerView::parsePerlSymbols(void)
20
if (!win->activeView())
23
popup->changeItem( popup->idAt(2),i18n("Show Uses"));
24
popup->changeItem( popup->idAt(3),i18n("Show Pragmas"));
25
popup->changeItem( popup->idAt(4),i18n("Show Subroutines"));
26
QString cl; // Current Line
29
QPixmap cls( ( const char** ) class_xpm );
30
QPixmap sct( ( const char** ) struct_xpm );
31
QPixmap mcr( ( const char** ) macro_xpm );
32
QPixmap cls_int( ( const char** ) class_int_xpm );
33
QTreeWidgetItem *node = NULL;
34
QTreeWidgetItem *mcrNode = NULL, *sctNode = NULL, *clsNode = NULL;
35
QTreeWidgetItem *lastMcrNode = NULL, *lastSctNode = NULL, *lastClsNode = NULL;
37
KTextEditor::Document *kv = win->activeView()->document();
39
//kdDebug(13000)<<"Lines counted :"<<kv->numLines()<<endl;
42
mcrNode = new QTreeWidgetItem(symbols, QStringList( i18n("Uses") ) );
43
sctNode = new QTreeWidgetItem(symbols, QStringList( i18n("Pragmas") ) );
44
clsNode = new QTreeWidgetItem(symbols, QStringList( i18n("Subroutines") ) );
45
mcrNode->setIcon(0, QIcon(mcr));
46
sctNode->setIcon(0, QIcon(sct));
47
clsNode->setIcon(0, QIcon(cls));
51
symbols->expandItem(mcrNode);
52
symbols->expandItem(sctNode);
53
symbols->expandItem(clsNode);
55
lastMcrNode = mcrNode;
56
lastSctNode = sctNode;
57
lastClsNode = clsNode;
58
symbols->setRootIsDecorated(1);
61
symbols->setRootIsDecorated(0);
63
for (int i=0; i<kv->lines(); i++)
68
kDebug(13000)<<"Line " << i << " : "<< cl;
70
if(cl == "" || cl.at(0) == '#') continue;
71
if(cl.indexOf(QRegExp("^=")) >= 0) comment = 1;
72
if(cl.indexOf(QRegExp("^=cut$")) >= 0)
80
if(cl.indexOf(QRegExp("^use +[A-Z]")) == 0 && macro_on)
82
QString stripped=cl.replace( QRegExp("^use +"), "" );
83
//stripped=stripped.replace( QRegExp(";$"), "" ); // Doesn't work ??
84
stripped = stripped.left(stripped.indexOf(';'));
87
node = new QTreeWidgetItem(mcrNode, lastMcrNode);
91
node = new QTreeWidgetItem(symbols);
93
node->setText(0, stripped);
94
node->setIcon(0, QIcon(mcr));
95
node->setText(1, QString::number( i, 10));
98
if(cl.indexOf(QRegExp("^use +[a-z]")) == 0 && struct_on)
100
QString stripped=cl.replace( QRegExp("^use +"), "" );
101
stripped=stripped.replace( QRegExp(";$"), "" );
104
node = new QTreeWidgetItem(sctNode, lastSctNode);
108
node = new QTreeWidgetItem(symbols);
110
node->setText(0, stripped);
111
node->setIcon(0, QIcon(sct));
112
node->setText(1, QString::number( i, 10));
116
if(cl.indexOf(QRegExp("^sub +"))==0 && func_on)
118
QString stripped=cl.replace( QRegExp("^sub +"), "" );
119
stripped=stripped.replace( QRegExp("[{;] *$"), "" );
122
node = new QTreeWidgetItem(clsNode, lastClsNode);
126
node = new QTreeWidgetItem(symbols);
127
node->setText(0, stripped);
129
if (stripped.at(0)=='_')
130
node->setIcon(0, QIcon(cls_int));
132
node->setIcon(0, QIcon(cls));
134
node->setText(1, QString::number( i, 10));