KDevelop API Documentation

driver.h

Go to the documentation of this file.
00001 /* This file is part of KDevelop
00002     Copyright (C) 2002,2003 Roberto Raggi <roberto@kdevelop.org>
00003 
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Library General Public
00006     License as published by the Free Software Foundation; either
00007     version 2 of the License, or (at your option) any later version.
00008 
00009     This library is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012     Library General Public License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public License
00015     along with this library; see the file COPYING.LIB.  If not, write to
00016     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00017     Boston, MA 02111-1307, USA.
00018 */
00019 
00020 #ifndef DRIVER_H
00021 #define DRIVER_H
00022 
00023 #include "JavaAST.hpp"
00024 
00025 #include <qpair.h>
00026 #include <qvaluestack.h>
00027 #include <qstringlist.h>
00028 #include <qmap.h>
00029 
00030 class JavaLexer;
00031 class JavaRecognizer;
00032 
00033 class Problem
00034 {
00035 public:
00036     enum
00037     {
00038     Level_Error = 0,
00039     Level_Warning,
00040     Level_Todo,
00041     Level_Fixme
00042     };
00043 
00044 public:
00045     Problem() {}
00046     Problem( const Problem& source )
00047     : m_text( source.m_text ), m_line( source.m_line ),
00048       m_column( source.m_column ), m_level( source.m_level ) {}
00049     Problem( const QString& text, int line, int column, int level=Level_Error )
00050     : m_text( text ), m_line( line ), m_column( column ), m_level(level) {}
00051 
00052     Problem& operator = ( const Problem& source )
00053     {
00054     m_text = source.m_text;
00055     m_line = source.m_line;
00056     m_column = source.m_column;
00057     m_level = source.m_level;
00058     return( *this );
00059     }
00060 
00061     bool operator == ( const Problem& p ) const
00062     {
00063     return m_text == p.m_text && m_line == p.m_line && m_column == p.m_column && m_level == p.m_level;
00064     }
00065 
00066     QString text() const { return m_text; }
00067     int line() const { return m_line; }
00068     int column() const { return m_column; }
00069     int level() const { return m_level; }
00070 
00071 private:
00072     QString m_text;
00073     int m_line;
00074     int m_column;
00075     int m_level;
00076 };
00077 
00078 class SourceProvider
00079 {
00080 public:
00081     SourceProvider() {}
00082     virtual ~SourceProvider() {}
00083 
00084     virtual QString contents( const QString& fileName ) = 0;
00085     virtual bool isModified( const QString& fileName ) = 0;
00086 
00087 private:
00088     SourceProvider( const SourceProvider& source );
00089     void operator = ( const SourceProvider& source );
00090 };
00091 
00092 class Driver
00093 {
00094 public:
00095     Driver();
00096     virtual ~Driver();
00097 
00098     SourceProvider* sourceProvider();
00099     void setSourceProvider( SourceProvider* sourceProvider );
00100 
00101     virtual void reset();
00102 
00103     virtual void parseFile( const QString& fileName, bool onlyPreProcesss=false, bool force=false );
00104     virtual void fileParsed( const QString& fileName );
00105     virtual void remove( const QString& fileName );
00106 
00107     virtual void addProblem( const QString& fileName, const Problem& problem );
00108 
00109     QString currentFileName() const { return m_currentFileName; }
00110     RefJavaAST takeTranslationUnit( const QString& fileName );
00111     RefJavaAST translationUnit( const QString& fileName ) const;
00112     QValueList<Problem> problems( const QString& fileName ) const;
00113 
00114     QStringList includePaths() const { return m_includePaths; }
00115     virtual void addIncludePath( const QString &path );
00116 
00117     const QMap<QString, RefJavaAST> &parsedUnits() const { return m_parsedUnits; }
00118 
00119 protected:
00120     virtual void setupLexer( JavaLexer* lexer );
00121     virtual void setupParser( JavaRecognizer* parser );
00122 
00123 private:
00124     QValueList<Problem>& findOrInsertProblemList( const QString& fileName );
00125 
00126 private:
00127     QString m_currentFileName;
00128     QMap< QString, QValueList<Problem> > m_problems;
00129     QMap< QString, RefJavaAST > m_parsedUnits;
00130     QStringList m_includePaths;
00131     JavaLexer *lexer;
00132     SourceProvider* m_sourceProvider;
00133 
00134 private:
00135     Driver( const Driver& source );
00136     void operator = ( const Driver& source );
00137 };
00138 
00139 #endif
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:51 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003