Commit b64583e7 authored by Ralf Habacker's avatar Ralf Habacker

import kdev-php version 1.7.3

parent 47ecabb6
Authors
=======
Niko Sams <niko.sams@gmail.com>
- started the project
- maintainer
Milian Wolff <mail@milianw.de>
- various contributions
- comaintainer
PROJECT(php)
cmake_minimum_required(VERSION 2.8.9)
set(KDEVPHP_VERSION_MAJOR 1)
set(KDEVPHP_VERSION_MINOR 7)
set(KDEVPHP_VERSION_PATCH 3)
# KDevplatform dependency version
set( KDEVPLATFORM_VERSION "1.${KDEVPHP_VERSION_MINOR}.${KDEVPHP_VERSION_PATCH}" )
configure_file( "${php_SOURCE_DIR}/kdevphpversion.h.cmake" "${php_BINARY_DIR}/kdevphpversion.h" @ONLY )
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${php_SOURCE_DIR}/cmake/)
enable_testing()
#To properly find kdevelop-pg add -DKDEVPG_DATA_DIR=<kdevpg-install-path>/share to the
#cmake run if you installed it in a different directory than this plugin
#TODO: a cmake run is needed after changing one of the CMakeLists.txt, make will
#complain about the FindKDevelop-PG.cmake file not findable.
find_package(KDE4 REQUIRED)
find_package(KDevPlatform ${KDEVPLATFORM_VERSION} REQUIRED)
include_directories(${KDEVPLATFORM_INCLUDE_DIR})
include_directories(
${KDE4_INCLUDES}
${KDE4_INCLUDE_DIR}/threadweaver
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/duchain
${CMAKE_CURRENT_SOURCE_DIR}/parser
${CMAKE_CURRENT_BINARY_DIR}/parser
)
add_definitions( -DKDE_DEFAULT_DEBUG_AREA=9043 )
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
find_package(KDevelop-PG-Qt REQUIRED)
include_directories(
${CMAKE_BINARY_DIR}/parser
${KDEVPGQT_INCLUDE_DIR}
)
add_subdirectory(app_templates)
add_subdirectory(parser)
add_subdirectory(duchain)
add_subdirectory(completion)
add_subdirectory(testprovider)
set(kdevphplanguagesupport_PART_SRCS
phplanguagesupport.cpp
phpparsejob.cpp
phphighlighting.cpp
codegen/refactoring.cpp
)
kde4_add_plugin(kdevphplanguagesupport ${kdevphplanguagesupport_PART_SRCS})
target_link_libraries(kdevphplanguagesupport
${KDE4_KDEUI_LIBS}
${KDEVPLATFORM_INTERFACES_LIBRARIES}
${KDEVPLATFORM_LANGUAGE_LIBRARIES}
${KDE4_THREADWEAVER_LIBRARIES}
${KDE4_KTEXTEDITOR_LIBS}
kdev4phpduchain
kdev4phpparser
kdev4phpcompletion
)
install(TARGETS kdevphplanguagesupport DESTINATION ${PLUGIN_INSTALL_DIR})
configure_file(kdevphpsupport.desktop.cmake ${CMAKE_CURRENT_BINARY_DIR}/kdevphpsupport.desktop)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kdevphpsupport.desktop DESTINATION ${SERVICES_INSTALL_DIR})
# not writeable so that the refactoring actions get hidden
install(FILES phpfunctions.php DESTINATION ${DATA_INSTALL_DIR}/kdevphpsupport PERMISSIONS OWNER_READ GROUP_READ WORLD_READ)
include(CTest)
# CTestCustom.cmake has to be in the CTEST_BINARY_DIR.
# in the KDE build system, this is the same as CMAKE_BINARY_DIR.
configure_file(${CMAKE_SOURCE_DIR}/CTestCustom.cmake ${CMAKE_BINARY_DIR}/CTestCustom.cmake)
This diff is collapsed.
## This file should be placed in the root directory of your project.
## Then modify the CMakeLists.txt file in the root directory of your
## project to incorporate the testing dashboard.
## # The following are required to uses Dart and the Cdash dashboard
## ENABLE_TESTING()
## INCLUDE(CTest)
set(CTEST_PROJECT_NAME "KDevelop-PHP")
set(CTEST_NIGHTLY_START_TIME "00:05:00 GMT")
set(CTEST_DROP_METHOD "http")
set(CTEST_DROP_SITE "my.cdash.org")
set(CTEST_DROP_LOCATION "/submit.php?project=KDevelop-PHP")
set(CTEST_DROP_SITE_CDASH TRUE)
# This file contains all the specific settings that will be used
# when running 'make Experimental'
# Change the maximum warnings that will be displayed
# on the report page (default 50)
set(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 1000)
# Warnings that will be ignored
set(CTEST_CUSTOM_WARNING_EXCEPTION
${CTEST_CUSTOM_WARNING_EXCEPTION}
# "/path/to/subfolder/"
)
# Errors that will be ignored
set(CTEST_CUSTOM_ERROR_EXCEPTION
${CTEST_CUSTOM_ERROR_EXCEPTION}
# "ICECC"
# "Segmentation fault"
# "GConf Error"
# "Client failed to connect to the D-BUS daemon"
# "Failed to connect to socket"
)
# No coverage for these files
set(CTEST_CUSTOM_COVERAGE_EXCLUDE ".moc$" "moc_" "ui_")
#! /bin/sh
#This file outputs in a separate line each file with a .desktop syntax
#that needs to be translated but has a non .desktop extension
find -name \*.kdevtemplate -print
You want to start hacking on the PHP plugin for KDevelop?
No problem, go ahead! You might want to get in touch with
Niko Sams (nsams) and me, Milian Wolff (milian). Currently
we are the ones maintaining the plugin.
What you have to respect when you write patches:
- adhere to the kdelibs coding style,
see the following about more information:
http://techbase.kde.org/Policies/Kdelibs_Coding_Style
- try to write meaningful comments. Especially non-trivial parts
must be commented to ease maintanance
#!/bin/sh
files=`find . -name \*.rc -o -name \*.ui`
if [ "x$files" != "x" ]; then
$EXTRACTRC $files >> rc.cpp
fi
$XGETTEXT `find . -name \*.cc -o -name \*.cpp -o -name \*.h` -o $podir/kdevphp.pot
rm -f rc.cpp
we maintain our todo on techbase, see:
http://techbase.kde.org/Projects/Quanta/Feature_Plan_4
set(apptemplate_DIRS
simple_phpapp
)
kdevplatform_add_app_templates(${apptemplate_DIRS})
<?php
/**
* Documentation, License etc.
*
* @package %{APPNAME}
*/
# KDE Config File
[General]
Name=Simple PHP Application
Name[bs]=Prosta PHP aplikacija
Name[ca]=Una aplicació PHP senzilla
Name[ca@valencia]=Una aplicació PHP senzilla
Name[cs]=Jednoduchá aplikace PHP
Name[da]=Et simpelt PHP-program
Name[de]=Eine einfache PHP-Anwendung
Name[el]=Απλή εφαρμογή PHP
Name[en_GB]=Simple PHP Application
Name[es]=Aplicación PHP sencilla
Name[et]=Lihtne PHP rakendus
Name[fi]=Yksinkertainen PHP-sovellus
Name[fr]=Application simple PHP
Name[ga]=Feidhmchlár Simplí PHP
Name[gl]=Aplicativo simple en PHP
Name[hu]=Egyszerű PHP alkalmazás
Name[it]=Semplice applicazione in PHP
Name[ja]=簡単な PHP アプリケーション
Name[kk]=Қарапайым PHP қолданбасы
Name[ko]=간단한 PHP 프로그램
Name[lt]=Paprasta PHP programa
Name[mr]=सोपा पीएचपी अनुप्रयोग
Name[ms]=Aplikasi PHP Mudah
Name[nb]=Et enkelt PHP-program
Name[nds]=Eenfach PHP-Programm
Name[nl]=Eenvoudig PHP-programma
Name[pl]=Prosta aplikacja PHP
Name[pt]=Aplicação Simples de PHP
Name[pt_BR]=Aplicativo PHP simples
Name[ru]=Простое приложение на PHP
Name[sk]=Jednoduchá PHP aplikácia
Name[sl]=Preprost program PHP
Name[sv]=Enkelt PHP-program
Name[tr]=Basit PHP Uygulaması
Name[ug]=ئاددىي PHP پروگراممىسى
Name[uk]=Проста програма мовою PHP
Name[x-test]=xxSimple PHP Applicationxx
Name[zh_CN]=简单的 PHP 应用程序
Name[zh_TW]=簡單的 PHP 應用程式
Category=PHP
Comment=Generate filestructure to start a PHP application
Comment[bs]=Generiši datotečnu strukturu za početak PHP aplikacija
Comment[ca]=Genera l'estructura de fitxers per a iniciar una aplicació PHP
Comment[ca@valencia]=Genera l'estructura de fitxers per a iniciar una aplicació PHP
Comment[cs]=Vygenerovat strukturu souborů pro započetí aplikace PHP
Comment[da]=Generér filstruktur til at påbegynde en PHP-applikation
Comment[de]=Dateistruktur erstellen, auf deren Basis eine PHP-Anwendung erstellt werden kann
Comment[el]=Δημιουργία δομής αρχείων για την εκκίνηση εφαρμογής σε PHP
Comment[en_GB]=Generate filestructure to start a PHP application
Comment[es]=Generar una estructura de archivos para iniciar una aplicación PHP
Comment[et]=Failistruktuuri genereerimine PHP rakenduse tarbeks
Comment[fi]=Generoi PHP-sovelluksen käynnistämiseen tarvittavan tiedostorakenteen
Comment[fr]=Générer une structure de fichiers pour lancer une application PHP
Comment[ga]=Cruthaigh struchtúr comhad chun feidhmchlár PHP a thosú
Comment[gl]=Xera a estrutura de ficheiros para comezar un aplicativo en PHP
Comment[hu]=Fájlstruktúrát hoz létre egy PHP alkalmazás elkezdéséhez
Comment[it]=Genera una struttura di file per inizializzare un'applicazione in PHP
Comment[ja]=PHP アプリケーションを始めるためのファイル構造を生成
Comment[kk]=PHP қолданбасын бастайтын файл құрылымын құру
Comment[ko]=PHP 프로그램을 시작할 파일 구조 생성
Comment[lt]=Generuoti failo struktūrą, kad paleisti PHP programą
Comment[mr]=पीएचपी अनुप्रयोग सुरु करण्याकरिता फाईल स्ट्रक्चर निर्माण करतो.
Comment[ms]=Jana struktur fail untuk memulakan aplikasi PHP
Comment[nb]=Generer filstruktur for å starte et PHP-program
Comment[nds]=De Dateistruktuur för't Starten vun en PHP-Programm opstellen
Comment[nl]=Genereer een bestandsstructuur om een PHP-programma te starten
Comment[pl]=Tworzy strukturę plików do rozpoczęcia projektu PHP
Comment[pt]=Gera uma estrutura de ficheiros para iniciar uma aplicação em PHP
Comment[pt_BR]=Gera a estrutura de arquivos para iniciar um aplicativo PHP
Comment[ru]=Подготавливает структуру файлов для создания приложения на PHP
Comment[sk]=Generovať súborovú štruktúru na spustenie PHP aplikácie
Comment[sl]=Ustvari datotečno zgradbo za zagon programa PHP
Comment[sv]=Skapa filstruktur för att påbörja ett PHP-program
Comment[tr]=Bir PHP uygulaması başlatmak için dosya yapısını oluştur
Comment[ug]=ھۆججەت قۇرۇلمىسىنى ھاسىل قىلىپ PHP پروگراممىسىنى باشلا
Comment[uk]=Створення початкової файлової структури програми мовою PHP
Comment[x-test]=xxGenerate filestructure to start a PHP applicationxx
Comment[zh_CN]=生成文件结构以开发 PHP 应用程序
Comment[zh_TW]=開始寫一個 PHP 應用程式的一般檔案結構
ShowFilesAfterGeneration=%{dest}/%{APPNAMELC}.php
#
# Find the KDevelop Platform modules and sets various variables accordingly
#
# Example usage of this module:
# find_package(KDevPlatform 1.0.0 REQUIRED)
#
# The version number and REQUIRED flag are optional. You can set CMAKE_PREFIX_PATH
# variable to help it find the required files and directories
# KDEVPLATFORM_FOUND - set to TRUE if the platform was found and the version is compatible FALSE otherwise
#
# KDEVPLATFORM_VERSION - The version number of kdevplatform
# KDEVPLATFORM_VERSION_MAJOR - The major version number of kdevplatform
# KDEVPLATFORM_VERSION_MINOR - The minor version number of kdevplatform
# KDEVPLATFORM_VERSION_PATCH - The patch version number of kdevplatform
# KDEVPLATFORM_INCLUDE_DIR - include dir of the platform, for example /usr/include/kdevplatform
# KDEVPLATFORM_INTERFACES_LIBRARIES - interfaces module library
# KDEVPLATFORM_LANGUAGE_LIBRARIES - language module library
# KDEVPLATFORM_OUTPUTVIEW_LIBRARIES - outputview module library
# KDEVPLATFORM_PROJECT_LIBRARIES - project module library
# KDEVPLATFORM_SUBLIME_LIBRARIES - sublime module library
# KDEVPLATFORM_SHELL_LIBRARIES - shell module library
# KDEVPLATFORM_TESTS_LIBRARIES - library to write tests for plugins,
# contains some useful tools and a way to replace parts of Core
# classes with custom implementations
# KDEVPLATFORM_UTIL_LIBRARIES - util module library
# KDEVPLATFORM_VCS_LIBRARIES - vcs module library
# KDEVPLATFORM_SOURCEFORMATTER_LIBRARIES - source formatter library
# KDEVPLATFORM_DEBUGGER_LIBRARIES - debugger module library
#
# The following macros are added (from KDevPlatformMacros.cmake):
#
# KDEVPLATFORM_ADD_APP_TEMPLATES( template1 ... templateN )
# Use this to get packaged template archives for the given templates.
# Parameters should be the directories containing the templates.
#
# Copyright 2007 Andreas Pakulat <apaku@gmx.de>
# Redistribution and use is allowed according to the terms of the BSD license.
set(_KDevPlatform_FIND_QUIETLY ${KDevPlatform_FIND_QUIETLY})
find_package( KDevPlatform ${KDevPlatform_FIND_VERSION} NO_MODULE )
set(KDevPlatform_FIND_QUIETLY ${_KDevPlatform_FIND_QUIETLY})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(KDevPlatform DEFAULT_MSG KDevPlatform_CONFIG )
/* This file is part of KDevelop
*
* Copyright 2014 Miquel Sabaté <mikisabate@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <QtCore/QObject>
#include <codegen/refactoring.h>
namespace Php
{
Refactoring::Refactoring(QObject *parent)
: BasicRefactoring(parent)
{
/* There's nothing to do here. */
}
} // End of namespace Php
/* This file is part of KDevelop
*
* Copyright 2014 Miquel Sabaté <mikisabate@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef REFACTORING_H
#define REFACTORING_H
#include <interfaces/context.h>
#include <language/codegen/basicrefactoring.h>
namespace Php
{
class Refactoring : public KDevelop::BasicRefactoring
{
public:
explicit Refactoring(QObject *parent = NULL);
};
} // End of namespace Php
#endif /* REFACTORING_H */
add_subdirectory(tests)
include_directories(${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
)
set(completion_SRCS
worker.cpp
item.cpp
implementationitem.cpp
includefileitem.cpp
keyworditem.cpp
context.cpp
model.cpp
helpers.cpp
codemodelitem.cpp
)
kde4_add_library( kdev4phpcompletion SHARED ${completion_SRCS} )
# hack to make ../parser/phpdebugvisitor.h (generated at compile time)
# use the correct EXPORT tags when compiling in MinGW
if (MINGW)
add_definitions(-DMAKE_KDEV4PHPPARSER_LIB)
endif (MINGW)
target_link_libraries(kdev4phpcompletion LINK_PRIVATE
${KDE4_KDECORE_LIBS}
${KDEVPLATFORM_LANGUAGE_LIBRARIES}
${KDE4_KTEXTEDITOR_LIBS}
${KDEVPLATFORM_INTERFACES_LIBRARIES}
${KDEVPLATFORM_PROJECT_LIBRARIES}
${KDE4_KIO_LIBS}
kdev4phpduchain
kdev4phpparser
)
install(TARGETS kdev4phpcompletion DESTINATION ${INSTALL_TARGETS_DEFAULT_ARGS})
/*
* KDevelop Php Code Completion Support
*
* Copyright 2010 Niko Sams <niko.sams@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "codemodelitem.h"
#include <KTextEditor/Document>
#include <language/duchain/duchain.h>
#include <language/duchain/duchainlock.h>
#include <language/codecompletion/codecompletionmodel.h>
#include <language/duchain/declaration.h>
#include <language/duchain/duchainutils.h>
#include <navigation/navigationwidget.h>
#include <language/codecompletion/codecompletionhelper.h>
#include <language/duchain/abstractfunctiondeclaration.h>
using namespace KDevelop;
namespace Php
{
CodeModelCompletionItem::CodeModelCompletionItem(const ParsingEnvironmentFilePointer &env, const CompletionCodeModelItem &item)
: CompletionTreeItem(), m_item(item), m_env(env)
{
}
QVariant CodeModelCompletionItem::data(const QModelIndex& index, int role, const KDevelop::CodeCompletionModel* model) const
{
DUChainReadLocker lock(DUChain::lock(), 500);
if (!lock.locked()) {
kDebug() << "Failed to lock the du-chain in time";
return QVariant();
}
switch (role) {
case Qt::DisplayRole:
switch (index.column()) {
case KDevelop::CodeCompletionModel::Name:
return QVariant(m_item.prettyName.str());
case KDevelop::CodeCompletionModel::Prefix:
return QString("class");
}
break;
case Qt::DecorationRole:
if( index.column() == CodeCompletionModel::Icon ) {
CodeCompletionModel::CompletionProperties p = completionProperties();
lock.unlock();
return DUChainUtils::iconForProperties(p);
}
break;
case CodeCompletionModel::IsExpandable:
return QVariant(true);
case CodeCompletionModel::ExpandingWidget: {
if (!declaration()) return QVariant();
QWidget *nav = new NavigationWidget(declaration(), model->currentTopContext());
model->addNavigationWidget(this, nav);
QVariant v;
v.setValue<QWidget*>(nav);
return v;
}
}
return QVariant();
}
CodeCompletionModel::CompletionProperties CodeModelCompletionItem::completionProperties() const
{
CodeCompletionModel::CompletionProperties ret = CodeCompletionModel::Class;
return ret;
}
void CodeModelCompletionItem::execute(KTextEditor::Document* document, const KTextEditor::Range& word)
{
document->replaceText(word, m_item.prettyName.str());
if (declaration() && dynamic_cast<AbstractFunctionDeclaration*>(declaration().data())) {
//Do some intelligent stuff for functions with the parens:
KTextEditor::Cursor pos = word.start();
pos.setColumn(pos.column() + m_item.prettyName.length());
insertFunctionParenText(document, pos, declaration());
}
}
DeclarationPointer CodeModelCompletionItem::declaration() const
{
if (!m_decl) {
KDevelop::DUChainReadLocker lock(KDevelop::DUChain::lock());
QList<Declaration*> decls = m_env->topContext()->findDeclarations(m_item.id);
if (decls.isEmpty()) return DeclarationPointer();
m_decl = decls.first();
}
return m_decl;
}
}
/*
* KDevelop Php Code Completion Support
*
* Copyright 2010 Niko Sams <niko.sams@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef PHPCOMPLETIONCODEMODELITEM_H