Commit 2e74b748 authored by Ralf Habacker's avatar Ralf Habacker

Import kdev-php 5.2.1

CCBUG:388428
parent f7963609
Authors
=======
Niko Sams <niko.sams@gmail.com>
- started the project
- maintainer
Milian Wolff <mail@milianw.de>
- various contributions
- comaintainer
cmake_minimum_required(VERSION 2.8.12)
project(php)
set(KDEVPHP_VERSION_MAJOR 5)
set(KDEVPHP_VERSION_MINOR 1)
set(KDEVPHP_VERSION_PATCH 2)
# KDevplatform dependency version
set( KDEVPLATFORM_VERSION "${KDEVPHP_VERSION_MAJOR}.${KDEVPHP_VERSION_MINOR}.${KDEVPHP_VERSION_PATCH}" )
configure_file( "${php_SOURCE_DIR}/kdevphpversion.h.cmake" "${php_BINARY_DIR}/kdevphpversion.h" @ONLY )
find_package (ECM 0.0.9 REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH})
include(KDECompilerSettings NO_POLICY_SCOPE)
include(ECMAddTests)
include(KDEInstallDirs)
include(KDECMakeSettings)
include(GenerateExportHeader)
include(FeatureSummary)
find_package(Qt5 REQUIRED Core Widgets Test WebKitWidgets)
find_package(KF5 REQUIRED COMPONENTS Archive ThreadWeaver TextEditor I18n ItemModels KCMUtils)
find_package(KDevPlatform ${KDEVPLATFORM_VERSION} REQUIRED)
find_package(KDevelop-PG-Qt REQUIRED)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wdocumentation")
endif()
add_definitions( -DKDE_DEFAULT_DEBUG_AREA=9043 )
add_definitions( -DTRANSLATION_DOMAIN=\"kdevphp\" )
include_directories(
${KDEVPGQT_INCLUDE_DIR}
)
add_subdirectory(app_templates)
add_subdirectory(parser)
add_subdirectory(duchain)
add_subdirectory(completion)
add_subdirectory(testprovider)
add_subdirectory(docs)
set(kdevphplanguagesupport_PART_SRCS
phplanguagesupport.cpp
phpparsejob.cpp
phphighlighting.cpp
phpdebug.cpp
codegen/refactoring.cpp
)
kdevplatform_add_plugin(kdevphplanguagesupport JSON kdevphpsupport.json
SOURCES ${kdevphplanguagesupport_PART_SRCS})
target_link_libraries(kdevphplanguagesupport
KDev::Interfaces
KDev::Language
kdevphpduchain
kdevphpparser
kdevphpcompletion
KF5::I18n
KF5::TextEditor
)
# 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)
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
This diff is collapsed.
#! /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 -o -name \*.kcfg`
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[ar]=تطبيق PHP بسيط
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[nb]=Et enkelt PHP-program
Name[nds]=Eenfach PHP-Programm
Name[nl]=Eenvoudig PHP-programma
Name[pl]=Prosty program 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 v PHP-ju
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[ar]=ولّد بناء ملفّات (filestructure) لبدء تطبيق PHP
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[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]=Generuj strukturę plików, aby rozpocząć program 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 začetek 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=%{APPNAME}.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.
*/
#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 */
if(BUILD_TESTING)
add_subdirectory(tests)
endif()
set(completion_SRCS
worker.cpp
item.cpp
implementationitem.cpp
includefileitem.cpp
keyworditem.cpp
context.cpp
model.cpp
helpers.cpp
codemodelitem.cpp
completiondebug.cpp
)
add_library( kdevphpcompletion SHARED ${completion_SRCS} )
generate_export_header( kdevphpcompletion EXPORT_MACRO_NAME KDEVPHPCOMPLETION_EXPORT
EXPORT_FILE_NAME phpcompletionexport.h)
target_link_libraries(kdevphpcompletion LINK_PRIVATE
KDev::Language
KDev::Interfaces
KDev::Project
kdevphpduchain
kdevphpparser
)
install(TARGETS kdevphpcompletion 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.h>
#include <ktexteditor/view.h>
#include <language/duchain/duchain.h>
#include <language/duchain/duchainlock.h>
#include <language/duchain/declaration.h>
#include <language/duchain/duchainutils.h>
#include <language/duchain/abstractfunctiondeclaration.h>
#include <language/codecompletion/codecompletionmodel.h>
#include <language/codecompletion/codecompletionhelper.h>
#include <navigation/navigationwidget.h>
#include "completiondebug.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()) {
qCDebug(COMPLETION) << "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 QStringLiteral("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::View* view, const KTextEditor::Range& word)
{
KTextEditor::Document *document = view->document();
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(view, 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
#define PHPCOMPLETIONCODEMODELITEM_H
#include <language/codecompletion/codecompletionitem.h>
#include <language/duchain/parsingenvironment.h>
#include <serialization/indexedstring.h>
#include "../duchain/completioncodemodel.h"
#include "context.h"
namespace Php
{
struct CompletionCodeModelItem;
class CodeCompletionContext;
class KDEVPHPCOMPLETION_EXPORT CodeModelCompletionItem : public KDevelop::CompletionTreeItem
{
public:
explicit CodeModelCompletionItem(const KDevelop::ParsingEnvironmentFilePointer &, const CompletionCodeModelItem &item);
QVariant data(const QModelIndex& index, int role, const KDevelop::CodeCompletionModel* model) const override;
KTextEditor::CodeCompletionModel::CompletionProperties completionProperties() const override;
void execute(KTextEditor::View* View, const KTextEditor::Range& word) override;
KDevelop::DeclarationPointer declaration() const override;
protected:
CompletionCodeModelItem m_item;
KDevelop::ParsingEnvironmentFilePointer m_env;
mutable KDevelop::DeclarationPointer m_decl;
};
}
#endif
/* This file is part of KDevelop
Copyright 2014 Milian Wolff <mail@milianw.de>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 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 Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "completiondebug.h"
Q_LOGGING_CATEGORY(COMPLETION, "kdevelop.languages.php.completion")
/* This file is part of KDevelop
Copyright 2014 Milian Wolff <mail@milianw.de>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 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 Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef COMPLETIONDEBUG_H
#define COMPLETIONDEBUG_H
#include <QLoggingCategory>
Q_DECLARE_LOGGING_CATEGORY(COMPLETION)
#endif /* COMPLETIONDEBUG_H */
This diff is collapsed.
/*
Copyright 2007 David Nolden <david.nolden.kdevelop@art-master.de>
Copyright 2008 Hamish Rodda <rodda@kde.org>
Copyright 2008 Niko Sams <niko.sams@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public