Commit 2af0f3f9 authored by Escuder Nicolas's avatar Escuder Nicolas

Kdevelop / PHP support : Backport New PHP Parser / code completition ...

CCMAIL: dymo@mk.ukrtelecom.ua
parent 2fb56705
......@@ -10,7 +10,7 @@ kde_module_LTLIBRARIES = libkdevphpsupport.la
libkdevphpsupport_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN)
libkdevphpsupport_la_LIBADD = $(top_builddir)/lib/libkdevelop.la $(top_builddir)/lib/widgets/libkdevwidgets.la $(LIB_KHTML)
libkdevphpsupport_la_SOURCES = phpsupportpart.cpp phpconfigwidgetbase.ui phpconfigparserwidgetbase.ui phpconfigwidget.cpp phpinfodlg.ui phphtmlview.cpp phpconfigparserwidget.cpp phperrorview.cpp phpconfigdata.cpp phpcodecompletion.cpp phpparser.cpp phpnewclassdlgbase.ui phpnewclassdlg.cpp
libkdevphpsupport_la_SOURCES = phpsupportpart.cpp phpconfigwidgetbase.ui phpconfigwidget.cpp phpinfodlg.ui phphtmlview.cpp phperrorview.cpp phpconfigdata.cpp phpcodecompletion.cpp phpparser.cpp phpnewclassdlgbase.ui phpnewclassdlg.cpp phpfile.cpp
METASOURCES = AUTO
......
/** \class PHPSupportPart
This is PHP language support plugin.
Put a more detailed description of your part in these lines. It can span
over several lines. You can even use some html commands in these lines like:
<code>This is code</code>, html links <a href="http://somelocation">link text</a>,
and images.
Support for the <a href="http://www.php.net">PHP Language</a>, you can
develop php script for web or php script for shell.
It's support checking of your script with problems report and also parse
all include files from your script.
\authors <a href="mailto:smeier AT kdevelop.org">Sandy Meier</a>
\authors <a href="mailto:n.escuder AT intra-links.com">Escuder Nicolas</a>
\maintainer <a href="mailto:smeier AT kdevelop.org">Sandy Meier</a>
\maintainer <a href="mailto:2nd maintainer AT provider.com">2nd maintainer full name</a>
...
\maintainer <a href="mailto:nth maintainer AT provider.com">nth maintainer full name</a>
\maintainer <a href="mailto:n.escuder AT intra-links.com">Escuder Nicolas</a>
\feature PHP language support
\feature Consult \ref LangSupportStatus for a up to date features/status of this programming language support part.
\bug bugs in <a href="http://bugs.kde.org/buglist.cgi?product=kdevelop&component=php+support&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&order=Bug+Number">php support component at Bugzilla database</a>
\bug Describe a the 1st bug that you know of, but probably hasn't been reported yet.
..
\bug Describe a the nth bug that you know of, but probably hasn't been reported yet.
\requirement Describe a the 1st requirement of your part.
\requirement Describe a the 2nd requirement of your part.
...
\requirement Describe a the nth requirement of your part.
\requirement PHP Cli Version or WebServer with php
\todo integrated preview (webserver support and execution with php.exe),including error message parser
\todo syntax check with php.exe
\todo extended classtools (new class,new function...) based on filetemplates
\todo debugger and profiler support dbg (http://dd.cron.ru/dbg)
\todo codecompletion (key words, functions (mysql_*), and current project)
\todo html form support (dialogs for generating html code, tables...)
\todo support for phpdoc
\todo documentation viewer for php (maybe plugins for the current docviewer) (tf)
\todo integrated filemanager with ftp client (maybe a konqueror part)
\todo code template factory (contains useful php code snippet like array_display,trace,validator)
\todo new 'character' based parser, the current is 'line' based
\faq <b>First frequenly asked question about your part ?</b> Answer.
\faq <b>Second frequenly asked question about your part ?</b> Answer.
...
\faq <b>Last frequenly asked question about your part ?</b> Answer.
\note First note text.
\note Second note text.
...
\note Last note text.
\warning First warning text.
\warning Second warning text.
...
\warning Last warning text.
\todo new functions list from php 5 documentation
*/
......@@ -70,7 +70,7 @@
<codeHelp>
<codeCompletion>true</codeCompletion>
<codeHinting>true</codeHinting>
<realtimeParsing>false</realtimeParsing>
<realtimeParsing>true</realtimeParsing>
</codeHelp>
</kdevphpsupport>
<kdevfilecreate>
......
This diff is collapsed.
/***************************************************************************
phpcodecompletion.h - description
-------------------
begin : Tue Jul 17 2001
copyright : (C) 2001 by Sandy Meier
email : smeier@kdevelop.org
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
/*
Copyright (C) 2005 by Nicolas Escuder <n.escuder@intra-links.com>
Copyright (C) 2001 by smeier@kdevelop.org
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
......@@ -24,6 +27,9 @@
#include <kregexp.h>
#include <kparts/part.h>
#include <kdevmainwindow.h>
#include <kstatusbar.h>
#include <ktexteditor/editinterface.h>
#include <ktexteditor/viewcursorinterface.h>
#include <ktexteditor/codecompletioninterface.h>
......@@ -34,58 +40,64 @@ class KDevCore;
class PHPSupportPart;
class PHPConfigData;
/**
*@author Sandy Meier
*/
class FunctionCompletionEntry : public KTextEditor::CompletionEntry {
public:
QString prototype;
public:
QString prototype;
};
class PHPCodeCompletion : public QObject {
Q_OBJECT
Q_OBJECT
public:
PHPCodeCompletion(PHPConfigData *config, KDevCore* core,CodeModel* model);
~PHPCodeCompletion();
void setActiveEditorPart(KParts::Part *part);
PHPCodeCompletion(PHPSupportPart *phpSupport, PHPConfigData *config);
~PHPCodeCompletion();
void setActiveEditorPart(KParts::Part *part);
public slots:
void cursorPositionChanged();
void cursorPositionChanged();
protected slots:
void argHintHided();
void completionBoxHided();
void argHintHided();
void completionBoxHided();
protected:
bool showCompletionBox(QValueList<KTextEditor::CompletionEntry> list, unsigned long max);
protected:
bool checkForVariable(QString lineStr,int col,int line);
bool checkForGlobalFunction(QString lineStr,int col);
bool checkForNewInstance(QString lineStr,int col,int line);
bool checkForVariable(QString line, int col);
bool checkForStaticFunction(QString line, int col);
bool checkForNew(QString line, int col);
bool checkForExtends(QString line, int col);
bool checkForGlobalFunction(QString line, int col);
bool checkForGlobalFunctionArgHint(QString lineStr,int col,int line);
bool checkForMethodArgHint(QString lineStr,int col,int line);
bool checkForNewInstanceArgHint(QString lineStr,int col,int line);
bool checkForArgHint(QString line, int col);
void readGlobalPHPFunctionsFile();
QValueList<KTextEditor::CompletionEntry> getClasses(QString name);
QValueList<KTextEditor::CompletionEntry> getFunctionsAndVars(QString classname, QString str);
QStringList getArguments(QString classname, QString function);
QString getCurrentClassName();
QString getClassName(QString varName, QString classname);
QValueList<ClassDom> getClassByName(QString classname);
void readGlobalPHPFunctionsFile();
void setStatusBar(QString expr, QString type);
QValueList<KTextEditor::CompletionEntry> getClassMethodsAndVariables(QString className);
QString getClassName(QString varName,QString maybeInstanceOf);
QString searchCurrentClassName();
QString searchClassNameForVariable(QString varName);
bool doGlobalMethodCompletion(QString methodStart);
private:
int m_currentLine;
QValueList<FunctionCompletionEntry> m_globalFunctions;
KDevCore* m_core;
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;
PHPConfigData* m_config;
int m_currentLine;
QValueList<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;
QString findDeclaration(QString name, int line = -1);
};
#endif
/***************************************************************************
phpconfigdata.cpp - description
-------------------
begin : Thu Jun 14 2001
copyright : (C) 2001 by
email :
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
/*
Copyright (C) 2005 by Nicolas Escuder <n.escuder@intra-links.com>
Copyright (C) 2001 by smeier@kdevelop.org
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.
*/
#include "kstandarddirs.h"
#include "phpconfigdata.h"
#include "domutil.h"
#include <iostream>
PHPConfigData::PHPConfigData(QDomDocument* dom){
// cerr << endl << "kdevelop (phpsupport): enter PHPConfigData::PHPConfigData";
document = dom;
invocationMode = (InvocationMode) DomUtil::readIntEntry(*dom, "/kdevphpsupport/general/invocationMode");
webURL = DomUtil::readEntry(*document, "/kdevphpsupport/webInvocation/weburl");
webFileMode = (WebFileMode)DomUtil::readIntEntry(*document, "/kdevphpsupport/webInvocation/webFileMode");
webDefaultFile = DomUtil::readEntry(*document, "/kdevphpsupport/webInvocation/defaultFile");
phpExePath = DomUtil::readEntry(*document, "/kdevphpsupport/shell/phpexe");
m_codeCompletion = DomUtil::readBoolEntry(*document,"kdevphpsupport/codeHelp/codeCompletion");
m_codeHinting = DomUtil::readBoolEntry(*document,"kdevphpsupport/codeHelp/codeHinting");;
m_realtimeParsing = DomUtil::readBoolEntry(*document,"kdevphpsupport/codeHelp/realtimeParsing");
PHPConfigData::PHPConfigData(QDomDocument* dom) {
QString file = KStandardDirs::findExe("php");
if (file.isEmpty())
file = "/usr/local/bin/php";
document = dom;
invocationMode = (InvocationMode) DomUtil::readIntEntry(*dom, "/kdevphpsupport/general/invocationMode", Web);
webURL = DomUtil::readEntry(*document, "/kdevphpsupport/webInvocation/weburl");
phpExePath = DomUtil::readEntry(*document, "/kdevphpsupport/shell/phpexe", file);
phpIniPath = DomUtil::readEntry(*document, "/kdevphpsupport/shell/phpini");
phpIncludePath = DomUtil::readEntry(*document, "/kdevphpsupport/options/phpincludepath");
phpStartupFile = DomUtil::readEntry(*document, "/kdevphpsupport/options/defaultFile");
phpStartupFileMode = (StartupFileMode)DomUtil::readIntEntry(*document, "/kdevphpsupport/options/startupFileMode", Current);
m_codeCompletion = DomUtil::readBoolEntry(*document,"kdevphpsupport/codeHelp/codeCompletion", true);
m_codeHinting = DomUtil::readBoolEntry(*document,"kdevphpsupport/codeHelp/codeHinting", true);
m_realtimeParsing = DomUtil::readBoolEntry(*document,"kdevphpsupport/codeHelp/realtimeParsing", true);
}
PHPConfigData::~PHPConfigData(){
PHPConfigData::~PHPConfigData() {
}
void PHPConfigData::storeConfig(){
DomUtil::writeIntEntry(*document, "/kdevphpsupport/general/invocationMode",(int) invocationMode);
void PHPConfigData::storeConfig() {
DomUtil::writeIntEntry(*document, "/kdevphpsupport/general/invocationMode",(int) invocationMode);
DomUtil::writeEntry(*document, "/kdevphpsupport/webInvocation/weburl",webURL);
DomUtil::writeEntry(*document, "/kdevphpsupport/shell/phpexe",phpExePath);
DomUtil::writeEntry(*document, "/kdevphpsupport/shell/phpini",phpIniPath);
DomUtil::writeEntry(*document, "/kdevphpsupport/webInvocation/weburl",webURL);
DomUtil::writeIntEntry(*document, "/kdevphpsupport/webInvocation/webFileMode",(int) webFileMode);
DomUtil::writeEntry(*document, "/kdevphpsupport/webInvocation/defaultFile",webDefaultFile);
DomUtil::writeEntry(*document, "/kdevphpsupport/options/phpincludepath",phpIncludePath);
DomUtil::writeEntry(*document, "/kdevphpsupport/options/defaultFile",phpStartupFile);
DomUtil::writeIntEntry(*document, "/kdevphpsupport/options/startupFileMode",(int) phpStartupFileMode);
DomUtil::writeEntry(*document, "/kdevphpsupport/shell/phpexe",phpExePath);
DomUtil::writeBoolEntry(*document,"kdevphpsupport/codeHelp/codeCompletion",m_codeCompletion);
DomUtil::writeBoolEntry(*document,"kdevphpsupport/codeHelp/codeHinting",m_codeHinting);
DomUtil::writeBoolEntry(*document,"kdevphpsupport/codeHelp/realtimeParsing",m_realtimeParsing);
emit configStored(); // inform all others
DomUtil::writeBoolEntry(*document,"kdevphpsupport/codeHelp/codeCompletion",m_codeCompletion);
DomUtil::writeBoolEntry(*document,"kdevphpsupport/codeHelp/codeHinting",m_codeHinting);
DomUtil::writeBoolEntry(*document,"kdevphpsupport/codeHelp/realtimeParsing",m_realtimeParsing);
emit configStored(); // inform all others
}
bool PHPConfigData::validateConfig(){
bool valid = false;
if(invocationMode == Web || invocationMode == Shell) {
valid = true;
}
if(valid){
if(invocationMode == Web){
if(!(!webURL.isEmpty() && (webFileMode == Default || webFileMode == Current))){
valid = false;
bool valid = false;
if (invocationMode == Web || invocationMode == Shell) {
valid = true;
}
if (valid) {
if (invocationMode == Web) {
if (!(!webURL.isEmpty() && (phpStartupFileMode == Default || phpStartupFileMode == Current))) {
valid = false;
}
}
}
if(invocationMode == Shell){
if(phpExePath.isEmpty()){
valid = false;
if (invocationMode == Shell) {
if (phpExePath.isEmpty()) {
valid = false;
}
}
}
}
return valid;
}
return valid;
}
#include "phpconfigdata.moc"
/***************************************************************************
begin : Thu Jun 14 2001
copyright : (C) 2001 by Sandy Meier
email : smeier@kdevelop.org
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
/*
Copyright (C) 2005 by Nicolas Escuder <n.escuder@intra-links.com>
Copyright (C) 2001 by smeier@kdevelop.org
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 PHPCONFIGDATA_H
#define PHPCONFIGDATA_H
......@@ -25,100 +29,127 @@
*/
class PHPConfigData : public QObject {
Q_OBJECT
signals:
void configStored();
signals:
void configStored();
public:
enum InvocationMode {Web=1,Shell=2};
enum WebFileMode {Current=1,Default=2};
PHPConfigData(QDomDocument* document);
~PHPConfigData();
/**
returns true if the configuration is ok, false if something is missing
*/
bool validateConfig();
/** write the configuration to the DOM document(project file)
enum InvocationMode {Web=1,Shell=2};
enum StartupFileMode {Current=1,Default=2};
PHPConfigData(QDomDocument* document);
~PHPConfigData();
/** returns true if the configuration is ok, false if something is missing
*/
bool validateConfig();
/** write the configuration to the DOM document(project file)
*/
void storeConfig();
InvocationMode getInvocationMode(){
return invocationMode;
}
void setInvocationMode(InvocationMode mode){
invocationMode = mode;
}
// web
WebFileMode getWebFileMode(){
return webFileMode;
}
QString getWebURL(){
return webURL;
}
QString getWebDefaultFile(){
return webDefaultFile;
}
void setWebFileMode(WebFileMode mode){
webFileMode = mode;
}
void setWebURL(QString weburl){
webURL = weburl;
}
void setWebDefaultFile(QString defaultFile){
webDefaultFile = defaultFile;
}
// shell
QString getPHPExecPath(){
return phpExePath;
}
void setPHPExePath(QString path){
phpExePath = path;
}
// code help
void setCodeCompletion(bool enable){
m_codeCompletion = enable;
}
bool getCodeCompletion(){
return m_codeCompletion;
}
void setCodeHinting(bool enable){
m_codeHinting = enable;
}
bool getCodeHinting(){
return m_codeHinting;
}
void setRealtimeParsing(bool enable){
m_realtimeParsing = enable;
}
bool getRealtimeParsing(){
return m_realtimeParsing;
}
private:
QDomDocument* document;
InvocationMode invocationMode;
// web
WebFileMode webFileMode;
QString webURL;
QString webDefaultFile;
// shell
QString phpExePath;
// code help
bool m_codeCompletion;
bool m_codeHinting;
bool m_realtimeParsing;
void storeConfig();
InvocationMode getInvocationMode() {
return invocationMode;
}
void setInvocationMode(InvocationMode mode) {
invocationMode = mode;
}
// web
QString getWebURL() {
return webURL;
}
void setWebURL(QString weburl) {
webURL = weburl;
}
// shell
QString getPHPExecPath() {
return phpExePath;
}
void setPHPExePath(QString path) {
phpExePath = path;
}
// config
QString getPHPIniPath() {
return phpIniPath;
}
void setPHPIniPath(QString path) {
phpIniPath = path;
}
// options
QString getPHPIncludePath() {
return phpIncludePath;
}
void setPHPIncludePath(QString path) {
phpIncludePath = path;
}
QString getStartupFile() {
return phpStartupFile;
}
void setStartupFile(QString defaultFile) {
phpStartupFile = defaultFile;
}
StartupFileMode getStartupFileMode() {
return phpStartupFileMode;
}
void setStartupFileMode(StartupFileMode mode) {
phpStartupFileMode = mode;
}
// code help
void setCodeCompletion(bool enable) {
m_codeCompletion = enable;
}
bool getCodeCompletion() {
return m_codeCompletion;
}
void setCodeHinting(bool enable) {
m_codeHinting = enable;
}
bool getCodeHinting() {
return m_codeHinting;
}
void setRealtimeParsing(bool enable) {
m_realtimeParsing = enable;
}
bool getRealtimeParsing() {
return m_realtimeParsing;
}
private:
QDomDocument* document;
InvocationMode invocationMode;
// web
QString webURL;
// shell
QString phpExePath;
QString phpIniPath;
QString phpStartupFile;
// options
QString phpIncludePath;
QString phpDefaultFile;
StartupFileMode phpStartupFileMode;
// code help
bool m_codeCompletion;
bool m_codeHinting;
bool m_realtimeParsing;
};
#endif