summaryrefslogtreecommitdiffstats
path: root/languages/php/phpcodecompletion.h
blob: 3277a64d548be48ea4ee8ea442f25bd096eb9975 (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
/*
   Copyright (C) 2005 by Nicolas Escuder <[email protected]>
   Copyright (C) 2001 by [email protected]

   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 PHPCODECOMPLETION_H
#define PHPCODECOMPLETION_H

#include <codemodel.h>

#include <tqobject.h>
#include <kregexp.h>
#include <tdeparts/part.h>

#include <kdevmainwindow.h>
#include <kstatusbar.h>

#include <tdetexteditor/editinterface.h>
#include <tdetexteditor/viewcursorinterface.h>
#include <tdetexteditor/codecompletioninterface.h>
#include <tdetexteditor/selectioninterface.h>


class KDevCore;
class PHPSupportPart;
class PHPConfigData;

class FunctionCompletionEntry : public KTextEditor::CompletionEntry {
public:
   TQString prototype;
};

class PHPCodeCompletion : public TQObject {
   TQ_OBJECT
  

public:
   PHPCodeCompletion(PHPSupportPart *phpSupport, PHPConfigData *config);
   ~PHPCodeCompletion();
   void setActiveEditorPart(KParts::Part *part);

public slots:
   void cursorPositionChanged();

protected slots:  
   void argHintHided();
   void completionBoxHided();

protected:
   bool showCompletionBox(TQValueList<KTextEditor::CompletionEntry> list, unsigned long max);

   bool checkForVariable(TQString line, int col);
   bool checkForStaticFunction(TQString line, int col);
   bool checkForNew(TQString line, int col);
   bool checkForExtends(TQString line, int col);
   bool checkForGlobalFunction(TQString line, int col);

   bool checkForArgHint(TQString line, int col);

   TQValueList<KTextEditor::CompletionEntry> getClasses(TQString name);
   TQValueList<KTextEditor::CompletionEntry> getFunctionsAndVars(TQString classname, TQString str);
   TQStringList getArguments(TQString classname, TQString function);
   TQString getCurrentClassName();
   TQString getClassName(TQString varName, TQString classname);
   TQValueList<ClassDom> getClassByName(TQString classname);

   void readGlobalPHPFunctionsFile();
   void setStatusBar(TQString expr, TQString type);

 private:
   int m_currentLine;
   TQValueList<FunctionCompletionEntry> m_globalFunctions;

   PHPSupportPart* m_phpSupport;
   PHPConfigData* m_config;
   CodeModel* m_model;

   bool m_argWidgetShow;
   bool m_completionBoxShow;

   KTextEditor::EditInterface *m_editInterface;
   KTextEditor::CodeCompletionInterface *m_codeInterface;
   KTextEditor::ViewCursorInterface *m_cursorInterface;
   KTextEditor::SelectionInterface *m_selectionInterface;

   TQString findDeclaration(TQString name, int line = -1);
};

#endif