languages/java/driver.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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
This file is part of the documentation for KDevelop Version 3.0.4.