~ubuntu-branches/ubuntu/saucy/kate/saucy

« back to all changes in this revision

Viewing changes to addons/kate/symbolviewer/perl_parser.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell, Rohan Garg, Jonathan Riddell
  • Date: 2013-06-21 00:48:29 UTC
  • mfrom: (1.1.28)
  • Revision ID: package-import@ubuntu.com-20130621004829-y2ui02eg0j47h94y
Tags: 4:4.10.80-0ubuntu1
[ Rohan Garg ]
* New upstream release
  - Update and sort install files
  - Drop kubuntu_pate_find_python.diff, kubuntu_kate_initial_preference.patch,
    kubuntu_find_python.diff from debian/patches , not required

[ Jonathan Riddell ]
* New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
                          perl_parser.cpp  -  description
 
3
                             -------------------
 
4
    begin                : Apr 2 2003
 
5
    author               : 2003 Massimo Callegari
 
6
    email                : massimocallegari@yahoo.it
 
7
 ***************************************************************************/
 
8
 /***************************************************************************
 
9
 *                                                                         *
 
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.                                   *
 
14
 *                                                                         *
 
15
 ***************************************************************************/
 
16
#include "plugin_katesymbolviewer.h"
 
17
 
 
18
void KatePluginSymbolViewerView::parsePerlSymbols(void)
 
19
{
 
20
 if (!mainWindow()->activeView())
 
21
   return;
 
22
 
 
23
 m_popup->changeItem( m_popup->idAt(2),i18n("Show Uses"));
 
24
 m_popup->changeItem( m_popup->idAt(3),i18n("Show Pragmas"));
 
25
 m_popup->changeItem( m_popup->idAt(4),i18n("Show Subroutines"));
 
26
 QString cl; // Current Line
 
27
 QString stripped;
 
28
 char comment = 0;
 
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;
 
36
 
 
37
 KTextEditor::Document *kv = mainWindow()->activeView()->document();
 
38
 
 
39
     //kdDebug(13000)<<"Lines counted :"<<kv->numLines()<<endl;
 
40
 if(treeMode)
 
41
   {
 
42
    mcrNode = new QTreeWidgetItem(m_symbols, QStringList( i18n("Uses") ) );
 
43
    sctNode = new QTreeWidgetItem(m_symbols, QStringList( i18n("Pragmas") ) );
 
44
    clsNode = new QTreeWidgetItem(m_symbols, QStringList( i18n("Subroutines") ) );
 
45
    mcrNode->setIcon(0, QIcon(mcr));
 
46
    sctNode->setIcon(0, QIcon(sct));
 
47
    clsNode->setIcon(0, QIcon(cls));
 
48
 
 
49
    if (m_plugin->expanded_on)
 
50
      {
 
51
       m_symbols->expandItem(mcrNode);
 
52
       m_symbols->expandItem(sctNode);
 
53
       m_symbols->expandItem(clsNode);
 
54
      }
 
55
    lastMcrNode = mcrNode;
 
56
    lastSctNode = sctNode;
 
57
    lastClsNode = clsNode;
 
58
    m_symbols->setRootIsDecorated(1);
 
59
   }
 
60
 else
 
61
    m_symbols->setRootIsDecorated(0);
 
62
 
 
63
 for (int i=0; i<kv->lines(); i++)
 
64
   {
 
65
    cl = kv->line(i);
 
66
    cl = cl.trimmed();
 
67
 
 
68
    kDebug(13000)<<"Line " << i << " : "<< cl;
 
69
 
 
70
    if(cl.isEmpty() || cl.at(0) == '#') continue;
 
71
    if(cl.indexOf(QRegExp("^=")) >= 0) comment = 1;
 
72
    if(cl.indexOf(QRegExp("^=cut$")) >= 0)
 
73
       {
 
74
        comment = 0;
 
75
        continue;
 
76
       }
 
77
    if (comment==1)
 
78
        continue;
 
79
 
 
80
    if(cl.indexOf(QRegExp("^use +[A-Z]")) == 0 && macro_on)
 
81
      {
 
82
       QString stripped=cl.remove( QRegExp("^use +") );
 
83
       //stripped=stripped.replace( QRegExp(";$"), "" ); // Doesn't work ??
 
84
       stripped = stripped.left(stripped.indexOf(';'));
 
85
       if (treeMode)
 
86
         {
 
87
          node = new QTreeWidgetItem(mcrNode, lastMcrNode);
 
88
          lastMcrNode = node;
 
89
         }
 
90
       else
 
91
          node = new QTreeWidgetItem(m_symbols);
 
92
 
 
93
       node->setText(0, stripped);
 
94
       node->setIcon(0, QIcon(mcr));
 
95
       node->setText(1, QString::number( i, 10));
 
96
      }
 
97
#if 1
 
98
    if(cl.indexOf(QRegExp("^use +[a-z]")) == 0 && struct_on)
 
99
      {
 
100
       QString stripped=cl.remove( QRegExp("^use +") );
 
101
       stripped=stripped.remove( QRegExp(";$") );
 
102
       if (treeMode)
 
103
         {
 
104
          node = new QTreeWidgetItem(sctNode, lastSctNode);
 
105
          lastMcrNode = node;
 
106
         }
 
107
       else
 
108
          node = new QTreeWidgetItem(m_symbols);
 
109
 
 
110
       node->setText(0, stripped);
 
111
       node->setIcon(0, QIcon(sct));
 
112
       node->setText(1, QString::number( i, 10));
 
113
      }
 
114
#endif
 
115
#if 1
 
116
    if(cl.indexOf(QRegExp("^sub +"))==0 && func_on)
 
117
      {
 
118
       QString stripped=cl.remove( QRegExp("^sub +") );
 
119
       stripped=stripped.remove( QRegExp("[{;] *$") );
 
120
       if (treeMode)
 
121
         {
 
122
          node = new QTreeWidgetItem(clsNode, lastClsNode);
 
123
          lastClsNode = node;
 
124
         }
 
125
       else
 
126
          node = new QTreeWidgetItem(m_symbols);
 
127
        node->setText(0, stripped);
 
128
 
 
129
        if (!stripped.isEmpty() && stripped.at(0)=='_')
 
130
             node->setIcon(0, QIcon(cls_int));
 
131
        else
 
132
             node->setIcon(0, QIcon(cls));
 
133
 
 
134
        node->setText(1, QString::number( i, 10));
 
135
       }
 
136
#endif
 
137
   }
 
138
}
 
139
 
 
140
 
 
141