00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
#include "phperrorview.h"
00019
#include <qstringlist.h>
00020
#include <qregexp.h>
00021
#include <iostream>
00022
00023
#include <klocale.h>
00024
00025
using namespace std;
00026
00027 PHPErrorView::PHPErrorView(
PHPSupportPart *) :
QListBox(0,"PHP
Error View") {
00028 connect(
this,SIGNAL(selected(
int)),
this,SLOT(
slotItemSelected(
int)));
00029 }
00030
00031 PHPErrorView::~PHPErrorView(){
00032 }
00033
00034 void PHPErrorView::slotItemSelected(
int index){
00035
ErrorItem* errorItem =
errorDict[index];
00036 emit
fileSelected(errorItem->
filename,errorItem->
line -1);
00037 }
00038
00039 void PHPErrorView::parse(
QString& phpOutput){
00041
errorDict.clear();
00042 clear();
00043
ErrorItem* errorItem;
00044
int currentLine=0;
00045
00047
QRegExp parseError(
"^<b>Parse error</b>: parse error in <b>(.*)</b> on line <b>(.*)</b>.*$");
00048
QRegExp undefFunctionError(
"^<b>Fatal error</b>: Call to undefined function: (.*) in <b>(.*)</b> on line <b>(.*)</b>.*$");
00049
QRegExp warning(
"^<b>Warning</b>.*<b>(.*)</b> on line <b>(.*)</b>.*$");
00050
QRegExp generalFatalError(
"^<b>Fatal error</b>: (.*) in <b>(.*)</b> on line <b>(.*)</b>.*$");
00051
00052
00053
QStringList list = QStringList::split(
"\n",phpOutput);
00054 QStringList::Iterator it;
00055
for( it = list.begin(); it != list.end(); ++it ){
00056
if(parseError.search(*it)>=0){
00057 insertItem(i18n(
"Parse Error in %1 on Line %2").arg(parseError.cap(1)).arg(parseError.cap(2)));
00058 errorItem =
new ErrorItem();
00059 errorItem->
filename =
QString(parseError.cap(1));
00060 errorItem->
line =
QString(parseError.cap(2)).toInt();
00061
errorDict.insert(currentLine,errorItem);
00062 currentLine++;
00063 }
00064
else if(undefFunctionError.search(*it)>=0){
00065 insertItem(i18n(
"Call to Undefined Function %1 in %2 on Line %3")
00066 .arg(undefFunctionError.cap(1))
00067 .arg(undefFunctionError.cap(2))
00068 .arg(undefFunctionError.cap(3)));
00069 errorItem =
new ErrorItem();
00070 errorItem->
filename =
QString(parseError.cap(2));
00071 errorItem->
line =
QString(parseError.cap(3)).toInt();
00072
errorDict.insert(currentLine,errorItem);
00073 currentLine++;
00074 }
00075
else if(warning.search(*it)>=0){
00076 insertItem(i18n(
"Warning in %1 on Line %2").arg(warning.cap(1)).arg(warning.cap(2)));
00077 errorItem =
new ErrorItem();
00078 errorItem->
filename =
QString(warning.cap(1));
00079 errorItem->
line =
QString(warning.cap(2)).toInt();
00080
errorDict.insert(currentLine,errorItem);
00081 currentLine++;
00082 }
00083
else if(generalFatalError.search(*it)>=0){
00084 insertItem(i18n(
"%1 in %2 on Line %3")
00085 .arg(generalFatalError.cap(1))
00086 .arg(generalFatalError.cap(2))
00087 .arg((generalFatalError.cap(3))));
00088 errorItem =
new ErrorItem();
00089 errorItem->
filename =
QString(generalFatalError.cap(2));
00090 errorItem->
line =
QString(generalFatalError.cap(3)).toInt();
00091
errorDict.insert(currentLine,errorItem);
00092 currentLine++;
00093
00094 }
00095 }
00096 }
00097
#include "phperrorview.moc"