summaryrefslogtreecommitdiffstats
path: root/languages/php/phpfile.h
blob: 647be68a63f6051e5f59d71b7c33b6f337053e01 (plain)
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*
   Copyright (C) 2005 by Nicolas Escuder <n.escuder@intra-links.com>

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   version 2, License as published by the Free Software Foundation.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
   Boston, MA 02110-1301, USA.
*/

#ifndef PHPFILE_H
#define PHPFILE_H

#include <tdeapplication.h>
#include <tqstring.h>
#include <tqstringlist.h>
#include <tqfileinfo.h>
#include <tqregexp.h>
#include <tqthread.h>

#include <urlutil.h>
#include <kprocess.h>
#include <kdebug.h>

#include <tdevproject.h>
#include <tdevlanguagesupport.h>
#include <tdevpartcontroller.h>

#include <tdetexteditor/editinterface.h>
#include <tdetexteditor/document.h>

#include "phpsupportpart.h"
#include "phperrorview.h"
#include "phpparser.h"
#include "phpsupport_event.h"

/**
@author Escuder Nicolas
*/
class PHPFile : public TQObject {
Q_OBJECT
  

public:
   PHPFile(PHPSupportPart *phpSupport, const TQString& fileName);
   ~PHPFile();

   TQStringList getContents();

   bool isModified();
   void setModified(bool value);
   TQString fileName();
   void Analyse();
   void ParseStdout(TQString phpOutput);
/*
   ClassDom classByName(TQString filename, TQString classname);
   TQValueList<ClassDom> classByName(TQString classname);
*/

/*
private slots:
    void slotReceivedPHPCheckStderr (TDEProcess* proc, char* buffer, int buflen);
    void slotReceivedPHPCheckStdout (TDEProcess* proc, char* buffer, int buflen);
    void slotPHPCheckExited (TDEProcess* proc);
*/
private:
   TQStringList readFromEditor();
   TQStringList readFromDisk();

   bool ParseClass(TQString line, int lineNo);
   bool ParseFunction(TQString line, int lineNo);
   bool ParseVariable(TQString line, int lineNo);

   bool ParseThisMember(TQString line, int lineNo);
   bool ParseMember(TQString line, int lineNo);
   bool ParseReturn(TQString line, int lineNo);
   bool ParseTodo(TQString line, int lineNo);
   bool ParseFixme(TQString line, int lineNo);

   void ParseSource();
   void PHPCheck();

   void postEvent(FileParseEvent *event);

   bool AddClass(TQString name, TQString extends, int start);
   bool SetClass(TQString arguments);
   bool CloseClass(int end);

   bool AddFunction(TQString name, TQString arguments, int start);
   bool SetFunction(TQString name, TQString arguments = "");
   bool CloseFunction(int end);

   bool AddVariable(TQString name, TQString type, int position, bool classvar = FALSE);
   bool SetVariable(TQString arguments);

   bool AddTodo(TQString arguments, int position);
   bool AddFixme(TQString arguments, int position);

   PHPSupportPart *m_part;

   bool modified;

   bool inClass;
   bool inMethod;

   TQFileInfo* m_fileinfo;
   TQStringList m_contents;
   TQString m_phpCheckOutput;
//   KShellProcess* phpCheckProc;
};

#endif