1
/***************************************************************************
2
xslt_parser.cpp - description
6
email : jiri.tyr@vslib.cz
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
***************************************************************************/
17
#include "plugin_katesymbolviewer.h"
19
void KatePluginSymbolViewerView::parseXsltSymbols(void)
21
if (!mainWindow()->activeView())
24
m_macro->setText(i18n("Show Params"));
25
m_struct->setText(i18n("Show Variables"));
26
m_func->setText(i18n("Show Templates"));
28
QString cl; // Current Line
35
QPixmap cls( ( const char** ) class_xpm );
36
QPixmap sct( ( const char** ) struct_xpm );
37
QPixmap mcr( ( const char** ) macro_xpm );
38
QPixmap cls_int( ( const char** ) class_int_xpm );
40
QTreeWidgetItem *node = NULL;
41
QTreeWidgetItem *mcrNode = NULL, *sctNode = NULL, *clsNode = NULL;
42
QTreeWidgetItem *lastMcrNode = NULL, *lastSctNode = NULL, *lastClsNode = NULL;
44
KTextEditor::Document *kv = mainWindow()->activeView()->document();
45
//kdDebug(13000)<<"Lines counted :"<<kv->numLines()<<endl;
50
mcrNode = new QTreeWidgetItem(m_symbols, QStringList( i18n("Params") ) );
51
sctNode = new QTreeWidgetItem(m_symbols, QStringList( i18n("Variables") ) );
52
clsNode = new QTreeWidgetItem(m_symbols, QStringList( i18n("Templates") ) );
53
mcrNode->setIcon(0, QIcon(mcr));
54
sctNode->setIcon(0, QIcon(sct));
55
clsNode->setIcon(0, QIcon(cls));
57
if (m_plugin->expandedOn)
59
m_symbols->expandItem(mcrNode);
60
m_symbols->expandItem(sctNode);
61
m_symbols->expandItem(clsNode);
64
lastMcrNode = mcrNode;
65
lastSctNode = sctNode;
66
lastClsNode = clsNode;
68
m_symbols->setRootIsDecorated(1);
72
m_symbols->setRootIsDecorated(0);
75
for (i=0; i<kv->lines(); i++)
80
if(cl.indexOf(QRegExp("<!--")) >= 0) { comment = 1; }
81
if(cl.indexOf(QRegExp("-->")) >= 0) { comment = 0; continue; }
83
if(cl.indexOf(QRegExp("^</xsl:template>")) >= 0) { templ = 0; continue; }
85
if (comment==1) { continue; }
86
if (templ==1) { continue; }
88
if(cl.indexOf(QRegExp("^<xsl:param ")) == 0 && macro_on)
90
QString stripped = cl.remove(QRegExp("^<xsl:param +name=\""));
91
stripped = stripped.remove(QRegExp("\".*"));
95
node = new QTreeWidgetItem(mcrNode, lastMcrNode);
98
else node = new QTreeWidgetItem(m_symbols);
99
node->setText(0, stripped);
100
node->setIcon(0, QIcon(mcr));
101
node->setText(1, QString::number( i, 10));
104
if(cl.indexOf(QRegExp("^<xsl:variable ")) == 0 && struct_on)
106
QString stripped = cl.remove(QRegExp("^<xsl:variable +name=\""));
107
stripped = stripped.remove(QRegExp("\".*"));
109
if (m_plugin->treeOn)
111
node = new QTreeWidgetItem(sctNode, lastSctNode);
114
else node = new QTreeWidgetItem(m_symbols);
115
node->setText(0, stripped);
116
node->setIcon(0, QIcon(sct));
117
node->setText(1, QString::number( i, 10));
120
if(cl.indexOf(QRegExp("^<xsl:template +match=")) == 0 && func_on)
122
QString stripped = cl.remove(QRegExp("^<xsl:template +match=\""));
123
stripped = stripped.remove(QRegExp("\".*"));
125
if (m_plugin->treeOn)
127
node = new QTreeWidgetItem(clsNode, lastClsNode);
130
else node = new QTreeWidgetItem(m_symbols);
131
node->setText(0, stripped);
132
node->setIcon(0, QIcon(cls_int));
133
node->setText(1, QString::number( i, 10));
136
if(cl.indexOf(QRegExp("^<xsl:template +name=")) == 0 && func_on)
138
QString stripped = cl.remove(QRegExp("^<xsl:template +name=\""));
139
stripped = stripped.remove(QRegExp("\".*"));
141
if (m_plugin->treeOn)
143
node = new QTreeWidgetItem(clsNode, lastClsNode);
146
else node = new QTreeWidgetItem(m_symbols);
147
node->setText(0, stripped);
148
node->setIcon(0, QIcon(cls));
149
node->setText(1, QString::number( i, 10));
153
if(cl.indexOf(QRegExp("<xsl:template")) >= 0)