KDevelop API Documentation

compileerrorfilter.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 1999-2001 by Bernd Gehrmann and the KDevelop Team       *
00003  *   bernd@kdevelop.org                                                    *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  ***************************************************************************/
00011 
00012 #include "compileerrorfilter.h"
00013 #include "compileerrorfilter.moc"
00014 #include "makeitem.h"
00015 
00016 #include <kdebug.h>
00017 
00018 CompileErrorFilter::ErrorFormat::ErrorFormat( const char * regExp, int file, int line, int text )
00019     : expression( regExp )
00020     , fileGroup( file )
00021     , lineGroup( line )
00022     , textGroup( text )
00023 {
00024 }
00025 
00026 CompileErrorFilter::ErrorFormat::ErrorFormat( const char * regExp, int file, int line, int text, QString comp )
00027     : expression( regExp )
00028     , fileGroup( file )
00029     , lineGroup( line )
00030     , textGroup( text )
00031     , compiler( comp )
00032 {
00033 }
00034 
00035 
00036 CompileErrorFilter::CompileErrorFilter( OutputFilter& next )
00037     : OutputFilter( next )
00038 {
00039 }
00040 
00041 CompileErrorFilter::ErrorFormat* CompileErrorFilter::errorFormats()
00042 {
00044     static ErrorFormat formats[] = {
00045         // GCC - another case, eg. for #include "pixmap.xpm" which does not exists
00046         ErrorFormat( "([^: \t]+):([0-9]+):(?:[0-9]+):([^0-9]+)", 1, 2, 3 ),
00047         // GCC
00048         ErrorFormat( "([^: \t]+):([0-9]+):([^0-9]+)", 1, 2, 3 ),
00049         // ICC
00050         ErrorFormat( "([^: \\t]+)\\(([0-9]+)\\):([^0-9]+)", 1, 2, 3, "intel" ),
00051         //libtool link
00052         ErrorFormat( "(libtool):( link):( warning): ", 0, 0, 0 ),
00053         // Fortran
00054         ErrorFormat( "\"(.*)\", line ([0-9]+):(.*)", 1, 2, 3 ),
00055         // Jade
00056         ErrorFormat( "[a-zA-Z]+:([^: \t]+):([0-9]+):[0-9]+:[a-zA-Z]:(.*)", 1, 2, 3 ),
00057 
00058         ErrorFormat( 0, 0, 0, 0 ) // this one last
00059     };
00060 
00061     return formats;
00062 }
00063 
00064 void CompileErrorFilter::processLine( const QString& line )
00065 {
00066         bool hasmatch = false;
00067     QString file;
00068     int lineNum = 0;
00069     QString text;
00070     QString compiler;
00071     int i = 0;
00072     bool isWarning = false;
00073     ErrorFormat* errFormats = errorFormats();
00074     ErrorFormat* format = &errFormats[i];
00075     while( !format->expression.isEmpty() )
00076     {
00077         QRegExp regExp = format->expression;
00078 
00079         if ( regExp.search( line ) != -1 ) {
00080                     hasmatch = true;
00081                     file    = regExp.cap( format->fileGroup );
00082                     lineNum = regExp.cap( format->lineGroup ).toInt() - 1;
00083                     text    = regExp.cap( format->textGroup );
00084             compiler = format->compiler;
00085             if (regExp.cap(3).contains("warning", false))
00086                 isWarning = true;
00087             break;
00088         }
00089 
00090         format = &errFormats[++i];
00091     }
00092 
00093     if( hasmatch )
00094     {
00095         // Add hacks for error strings you want excluded here
00096         if( text.find( QString::fromLatin1("(Each undeclared identifier is reported only once") ) >= 0
00097             || text.find( QString::fromLatin1("for each function it appears in.)") ) >= 0 )
00098         hasmatch = false;
00099     }
00100 
00101     if ( hasmatch )
00102     {
00103         emit item( new ErrorItem( file, lineNum, text, line, isWarning, compiler ) );
00104     }
00105     else
00106     {
00107         OutputFilter::processLine( line );
00108     }
00109 }
KDE Logo
This file is part of the documentation for KDevelop Version 3.1.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 23 00:03:57 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003