File: phperrorview.cpp

package info (click to toggle)
kdevelop3 4%3A3.2.0-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 58,220 kB
  • ctags: 33,997
  • sloc: cpp: 278,404; ansic: 48,238; sh: 23,721; tcl: 19,882; perl: 5,498; makefile: 4,717; ruby: 1,610; python: 1,549; awk: 1,484; xml: 563; java: 359; php: 20; asm: 14; ada: 5; pascal: 4; fortran: 4; haskell: 2; sql: 1
file content (97 lines) | stat: -rw-r--r-- 3,982 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/***************************************************************************
                          phperrorview.cpp  -  description
                             -------------------
    begin                : Sat May 26 2001
    copyright            : (C) 2001 by
    email                :
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#include "phperrorview.h"
#include <qstringlist.h>
#include <qregexp.h>
#include <iostream>

#include <klocale.h>

using namespace std;

PHPErrorView::PHPErrorView(PHPSupportPart */*part*/) : QListBox(0,"PHP Error View") {
  connect(this,SIGNAL(selected(int)),this,SLOT(slotItemSelected(int)));
}

PHPErrorView::~PHPErrorView(){
}

void PHPErrorView::slotItemSelected(int index){
  ErrorItem* errorItem = errorDict[index];
  emit fileSelected(errorItem->filename,errorItem->line -1);
}

void PHPErrorView::parse(QString& phpOutput){
  ///  KRegExp parseerror("^<b>Parse error</b>: parse error in<b>(.*)</b> on line<b>(.*)</b>*$");
  errorDict.clear();
  clear();
  ErrorItem* errorItem;
  int currentLine=0;

  /// @todo test and add other
  QRegExp parseError("^<b>Parse error</b>:  parse error in <b>(.*)</b> on line <b>(.*)</b>.*$");
  QRegExp undefFunctionError("^<b>Fatal error</b>:  Call to undefined function:  (.*) in <b>(.*)</b> on line <b>(.*)</b>.*$");
  QRegExp warning("^<b>Warning</b>.*<b>(.*)</b> on line <b>(.*)</b>.*$");
  QRegExp generalFatalError("^<b>Fatal error</b>: (.*) in <b>(.*)</b> on line <b>(.*)</b>.*$");


  QStringList list = QStringList::split("\n",phpOutput);
  QStringList::Iterator it;
  for( it = list.begin(); it != list.end(); ++it ){
    if(parseError.search(*it)>=0){
      insertItem(i18n("Parse Error in %1 on Line %2").arg(parseError.cap(1)).arg(parseError.cap(2)));
      errorItem = new ErrorItem();
      errorItem->filename = QString(parseError.cap(1));
      errorItem->line = QString(parseError.cap(2)).toInt();
      errorDict.insert(currentLine,errorItem);
      currentLine++;
    }
    else if(undefFunctionError.search(*it)>=0){
      insertItem(i18n("Call to Undefined Function %1 in %2 on Line %3")
                 .arg(undefFunctionError.cap(1))
                 .arg(undefFunctionError.cap(2))
                 .arg(undefFunctionError.cap(3)));
      errorItem = new ErrorItem();
      errorItem->filename = QString(parseError.cap(2));
      errorItem->line = QString(parseError.cap(3)).toInt();
      errorDict.insert(currentLine,errorItem);
      currentLine++;
    }
    else if(warning.search(*it)>=0){
      insertItem(i18n("Warning in %1 on Line %2").arg(warning.cap(1)).arg(warning.cap(2)));
      errorItem = new ErrorItem();
      errorItem->filename = QString(warning.cap(1));
      errorItem->line = QString(warning.cap(2)).toInt();
      errorDict.insert(currentLine,errorItem);
      currentLine++;
    }
    else if(generalFatalError.search(*it)>=0){
      insertItem(i18n("%1 in %2 on Line %3")
                 .arg(generalFatalError.cap(1))
                 .arg(generalFatalError.cap(2))
                 .arg((generalFatalError.cap(3))));
      errorItem = new ErrorItem();
      errorItem->filename = QString(generalFatalError.cap(2));
      errorItem->line = QString(generalFatalError.cap(3)).toInt();
      errorDict.insert(currentLine,errorItem);
      currentLine++;

    }
  }
}
#include "phperrorview.moc"