diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,17 +4,18 @@ set(KDEVPHP_VERSION_MAJOR 5) set(KDEVPHP_VERSION_MINOR 1) -set(KDEVPHP_VERSION_PATCH 1) +set(KDEVPHP_VERSION_PATCH 40) # 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) +find_package (ECM "5.14.0" REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH}) include(KDECompilerSettings NO_POLICY_SCOPE) include(ECMAddTests) +include(ECMQtDeclareLoggingCategory) include(KDEInstallDirs) include(KDECMakeSettings) include(GenerateExportHeader) @@ -47,10 +48,14 @@ phplanguagesupport.cpp phpparsejob.cpp phphighlighting.cpp - phpdebug.cpp codegen/refactoring.cpp ) +ecm_qt_declare_logging_category(kdevphplanguagesupport_PART_SRCS + HEADER phpdebug.h + IDENTIFIER PHP + CATEGORY_NAME "kdevelop.languages.php" +) kdevplatform_add_plugin(kdevphplanguagesupport JSON kdevphpsupport.json SOURCES ${kdevphplanguagesupport_PART_SRCS}) @@ -68,4 +73,7 @@ # 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) +# kdebugsettings file +install(FILES kdevphpsupport.categories DESTINATION ${KDE_INSTALL_CONFDIR}) + feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/codegen/refactoring.h b/codegen/refactoring.h --- a/codegen/refactoring.h +++ b/codegen/refactoring.h @@ -33,7 +33,7 @@ class Refactoring : public KDevelop::BasicRefactoring { public: - explicit Refactoring(QObject *parent = NULL); + explicit Refactoring(QObject *parent = nullptr); }; } // End of namespace Php diff --git a/completion/CMakeLists.txt b/completion/CMakeLists.txt --- a/completion/CMakeLists.txt +++ b/completion/CMakeLists.txt @@ -10,7 +10,11 @@ model.cpp helpers.cpp codemodelitem.cpp - completiondebug.cpp +) +ecm_qt_declare_logging_category(completion_SRCS + HEADER completiondebug.h + IDENTIFIER COMPLETION + CATEGORY_NAME "kdevelop.languages.php.completion" ) add_library( kdevphpcompletion SHARED ${completion_SRCS} ) diff --git a/completion/completiondebug.h b/completion/completiondebug.h deleted file mode 100644 --- a/completion/completiondebug.h +++ /dev/null @@ -1,26 +0,0 @@ -/* This file is part of KDevelop - - Copyright 2014 Milian Wolff - - 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 -Q_DECLARE_LOGGING_CATEGORY(COMPLETION) - -#endif /* COMPLETIONDEBUG_H */ diff --git a/completion/completiondebug.cpp b/completion/completiondebug.cpp deleted file mode 100644 --- a/completion/completiondebug.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* This file is part of KDevelop - - Copyright 2014 Milian Wolff - - 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") diff --git a/completion/context.h b/completion/context.h --- a/completion/context.h +++ b/completion/context.h @@ -72,12 +72,12 @@ CodeCompletionContext(KDevelop::DUContextPointer context, const QString& text, const QString& followingText, const KDevelop::CursorInRevision& position, int depth = 0); - ~CodeCompletionContext(); + ~CodeCompletionContext() override; /// Computes the full set of completion items, using the information retrieved earlier. /// Should only be called on the first context, parent contexts are included in the computations. /// @param abort is checked regularly, and if it is false, the computation is aborted. - virtual QList completionItems(bool& abort, bool fullCompletion = true); + QList completionItems(bool& abort, bool fullCompletion = true) override; enum MemberAccessOperation { NoMemberAccess, ///With NoMemberAccess, a global completion should be done diff --git a/completion/context.cpp b/completion/context.cpp --- a/completion/context.cpp +++ b/completion/context.cpp @@ -504,6 +504,7 @@ case Parser::Token_DOUBLE_CAST: case Parser::Token_DOUBLE_QUOTE: case Parser::Token_ECHO: + case Parser::Token_ELLIPSIS: case Parser::Token_ENCAPSED_AND_WHITESPACE: case Parser::Token_EXIT: case Parser::Token_INC: @@ -960,7 +961,7 @@ m_parentContext = new CodeCompletionContext(m_duContext, m_position, lastToken, m_depth + 1); if (!m_parentContext->isValid()) { - m_parentContext = 0; + m_parentContext = nullptr; m_valid = false; return; } @@ -1056,11 +1057,11 @@ } foreach (const AbstractType::Ptr &type, types) { const IdentifiedType* idType = dynamic_cast(type.data()); - Declaration* declaration = 0; + Declaration* declaration = nullptr; if (idType) { declaration = idType->declaration(m_duContext->topContext()); } - DUContext* ctx = 0; + DUContext* ctx = nullptr; if (declaration) { ctx = declaration->logicalInternalContext(m_duContext->topContext()); } @@ -1330,7 +1331,7 @@ } } } else if (m_memberAccessOperation == BackslashAccess || m_memberAccessOperation == NamespaceChoose) { - DUContext* ctx = 0; + DUContext* ctx = nullptr; if (m_namespace.isEmpty()) { ctx = m_duContext->topContext(); } else { @@ -1362,7 +1363,7 @@ qCDebug(COMPLETION) << "containers: " << containers.count(); if (!containers.isEmpty()) { // get the parent class when we are inside a method declaration - ClassDeclaration* currentClass = 0; + ClassDeclaration* currentClass = nullptr; if (m_duContext->owner() && m_duContext->owner()->isFunctionDeclaration() && m_duContext->parentContext() && m_duContext->parentContext()->owner()) { currentClass = dynamic_cast(m_duContext->parentContext()->owner()); @@ -1476,7 +1477,7 @@ continue; } uint count = 0; - const CodeModelItem* foundItems = 0; + const CodeModelItem* foundItems = nullptr; CodeModel::self().items(url, count, foundItems); for (uint i = 0; i < count; ++i) { CodeModelItem::Kind k = foundItems[i].kind; @@ -1516,7 +1517,7 @@ foreach(QSet urlSets, completionFiles()) { foreach(const IndexedString &url, urlSets) { uint count = 0; - const CompletionCodeModelItem* foundItems = 0; + const CompletionCodeModelItem* foundItems = nullptr; CompletionCodeModel::self().items(url, count, foundItems); for (uint i = 0; i < count; ++i) { if (abort) return items; @@ -1553,7 +1554,7 @@ if ( !decl->isFunctionDeclaration() ) { if ( ClassDeclaration* classDec = dynamic_cast(decl) ) { // search for ctor - decl = 0; + decl = nullptr; foreach ( Declaration* dec, classDec->internalContext()->findDeclarations(Identifier("__construct")) ) { if ( dec->isFunctionDeclaration() ) { decl = dec; diff --git a/completion/implementationitem.cpp b/completion/implementationitem.cpp --- a/completion/implementationitem.cpp +++ b/completion/implementationitem.cpp @@ -223,7 +223,7 @@ { // get argument list QString arguments; - createArgumentList(*this, arguments, 0, true); + createArgumentList(*this, arguments, nullptr, true); replText += arguments; } diff --git a/completion/item.cpp b/completion/item.cpp --- a/completion/item.cpp +++ b/completion/item.cpp @@ -151,7 +151,7 @@ case CodeCompletionModel::Arguments: if (FunctionType::Ptr functionType = dec->type()) { QString ret; - createArgumentList(*this, ret, 0); + createArgumentList(*this, ret, nullptr); return ret; } break; diff --git a/completion/keyworditem.h b/completion/keyworditem.h --- a/completion/keyworditem.h +++ b/completion/keyworditem.h @@ -44,10 +44,10 @@ : NormalDeclarationCompletionItem(KDevelop::DeclarationPointer(), context, 0), m_keyword(keyword), m_replacement(customReplacement) {} - virtual void execute(KTextEditor::View* view, + void execute(KTextEditor::View* view, const KTextEditor::Range& word) override; - virtual QVariant data(const QModelIndex& index, + QVariant data(const QModelIndex& index, int role, const KDevelop::CodeCompletionModel* model) const override; diff --git a/completion/model.h b/completion/model.h --- a/completion/model.h +++ b/completion/model.h @@ -43,8 +43,8 @@ Q_OBJECT public: - CodeCompletionModel(QObject* parent = 0); - virtual ~CodeCompletionModel(); + CodeCompletionModel(QObject* parent = nullptr); + ~CodeCompletionModel() override; bool shouldAbortCompletion(KTextEditor::View* view, const KTextEditor::Range &range, diff --git a/completion/tests/test_completion.cpp b/completion/tests/test_completion.cpp --- a/completion/tests/test_completion.cpp +++ b/completion/tests/test_completion.cpp @@ -113,7 +113,7 @@ TestCodeCompletionContext(KDevelop::DUContextPointer context, const QString& text, const QString& followingText, const CursorInRevision &position, int depth = 0) : CodeCompletionContext(context, text, followingText, position, depth) { } protected: - QList > completionFiles() { + QList > completionFiles() override { QList > ret; QSet set; set << IndexedString("file:///internal/projecttest0"); @@ -287,7 +287,7 @@ NormalDeclarationCompletionItem* item2 = dynamic_cast(item.data()); QString ret; - createArgumentList(*item2, ret, 0); + createArgumentList(*item2, ret, nullptr); QCOMPARE(ret, QString("(A $a, null $b = null)")); } { @@ -1207,7 +1207,7 @@ NormalDeclarationCompletionItem* item2 = dynamic_cast(item.data()); QString ret; - createArgumentList(*item2, ret, 0); + createArgumentList(*item2, ret, nullptr); QCOMPARE(ret, QString("(string $bar)")); } { @@ -1222,7 +1222,7 @@ NormalDeclarationCompletionItem* item2 = dynamic_cast(item.data()); QString ret; - createArgumentList(*item2, ret, 0); + createArgumentList(*item2, ret, nullptr); QCOMPARE(ret, QString("(bool $asdf)")); } } @@ -1262,7 +1262,7 @@ NormalDeclarationCompletionItem* item2 = dynamic_cast(item.data()); QString ret; - createArgumentList(*item2, ret, 0); + createArgumentList(*item2, ret, nullptr); QCOMPARE(ret, QString("(mixed $a, int $b = 1)")); } } diff --git a/completion/worker.h b/completion/worker.h --- a/completion/worker.h +++ b/completion/worker.h @@ -42,7 +42,7 @@ explicit CodeCompletionWorker(CodeCompletionModel* parent); protected: - virtual KDevelop::CodeCompletionContext* createCompletionContext(KDevelop::DUContextPointer context, + KDevelop::CodeCompletionContext* createCompletionContext(KDevelop::DUContextPointer context, const QString &contextText, const QString &followingText, const KDevelop::CursorInRevision& position) const override; diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -7,13 +7,17 @@ ########## Documentation Plugin ##### set(kdevphpdocs_SRCS - phpdocsdebug.cpp phpdocumentationwidget.cpp phpdocumentation.cpp phpdocsplugin.cpp phpdocsmodel.cpp ${kdevphpdocs_settings_SRCS} ) +ecm_qt_declare_logging_category(kdevphpdocs_SRCS + HEADER phpdocsdebug.h + IDENTIFIER DOCS + CATEGORY_NAME "kdevelop.languages.php.docs" +) kdevplatform_add_plugin(kdevphpdocs JSON kdevphpdocs.json SOURCES ${kdevphpdocs_SRCS}) diff --git a/docs/kcm_kdevphpdocs.desktop.cmake b/docs/kcm_kdevphpdocs.desktop.cmake --- a/docs/kcm_kdevphpdocs.desktop.cmake +++ b/docs/kcm_kdevphpdocs.desktop.cmake @@ -16,6 +16,7 @@ Name[ca@valencia]=Documentació de PHP Name[cs]=Dokumentace PHP Name[de]=PHP-Dokumentation +Name[el]=PHP τεκμηρίωση Name[en_GB]=PHP Documentation Name[es]=Documentación de PHP Name[et]=PHP dokumentatsioon diff --git a/docs/kdevphpdocs.json b/docs/kdevphpdocs.json --- a/docs/kdevphpdocs.json +++ b/docs/kdevphpdocs.json @@ -12,11 +12,11 @@ "Description[ca]": "Aquest connector integra la documentació en línia de PHP.net.", "Description[de]": "Dieses Modul integriert die Online-Dokumentation von PHP.net.", "Description[es]": "Este complemento integra la documentación en línea de PHP.net.", - "Description[et]": "See plugin lõimib PHP veebidokumentatsiooni.", "Description[fi]": "Tämä liitännäinen integroi PHP.net-dokumentaation.", "Description[fr]": "Ce module intègre la documentation en ligne de PHP.net.", - "Description[gl]": "Esta extensión integra a documentación en liña de PHP.net.", + "Description[gl]": "Esta extensión integra a documentación en liña de PHP.net", "Description[it]": "Questa estensione integra la documentazione online di PHP.net.", + "Description[ko]": "PHP.net 온라인 문서를 통합합니다.", "Description[nl]": "Deze plugin integreert PHP.net online-documentatie.", "Description[pl]": "Wtyczka ta integruje dokumentację internetową PHP.net.", "Description[pt]": "Este 'plugin' integra-se com a documentação 'online' do PHP.net.", @@ -26,20 +26,20 @@ "Description[sv]": "Insticksprogrammet integrerar Internet-dokumentationen från PHP.net.", "Description[uk]": "За допомогою цього додатка можна інтегрувати документацію PHP.net.", "Description[x-test]": "xxThis plugin integrates PHP.net online documentation.xx", - "Description[zh_CN]": "此插件集成了 PHP.net 的在线文档。", + "Icon": "application-x-php", "Id": "kdevphpdocs", "License": "GPL", "Name": "PHP Documentation", "Name[ca@valencia]": "Documentació de PHP", "Name[ca]": "Documentació de PHP", "Name[cs]": "Dokumentace PHP", "Name[de]": "PHP-Dokumentation", "Name[es]": "Documentación de PHP", - "Name[et]": "PHP dokumentatsioon", "Name[fi]": "PHP-dokumentaatio", "Name[fr]": "Documentation PHP", "Name[gl]": "Documentación de PHP", "Name[it]": "Documentazione PHP", + "Name[ko]": "PHP 문서", "Name[nl]": "PHP-documentatie", "Name[pl]": "Dokumentacja PHP", "Name[pt]": "Documentação de PHP", @@ -50,7 +50,6 @@ "Name[sv]": "PHP-dokumentation", "Name[uk]": "Документація з PHP", "Name[x-test]": "xxPHP Documentationxx", - "Name[zh_CN]": "PHP 文档", "ServiceTypes": [ "KDevelop/Plugin" ] diff --git a/docs/phpdocsconfig.h b/docs/phpdocsconfig.h --- a/docs/phpdocsconfig.h +++ b/docs/phpdocsconfig.h @@ -37,8 +37,8 @@ Q_OBJECT public: - explicit PhpDocsConfig(QWidget *parent = 0, const QVariantList &args = QVariantList()); - virtual ~PhpDocsConfig(); + explicit PhpDocsConfig(QWidget *parent = nullptr, const QVariantList &args = QVariantList()); + ~PhpDocsConfig() override; void save() override; diff --git a/docs/phpdocsdebug.h b/docs/phpdocsdebug.h deleted file mode 100644 --- a/docs/phpdocsdebug.h +++ /dev/null @@ -1,27 +0,0 @@ -/* This file is part of KDevelop - - Copyright 2015 Kevin Funk - - 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 PHPDOCSDEBUG_H -#define PHPDOCSDEBUG_H - -#include - -Q_DECLARE_LOGGING_CATEGORY(DOCS) - -#endif /* PHPDOCSDEBUG_H */ diff --git a/docs/phpdocsdebug.cpp b/docs/phpdocsdebug.cpp deleted file mode 100644 --- a/docs/phpdocsdebug.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* This file is part of KDevelop - - Copyright 2015 Kevin Funk - - 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 "phpdocsdebug.h" - -Q_LOGGING_CATEGORY(DOCS, "kdevelop.languages.php.docs") diff --git a/docs/phpdocsmodel.h b/docs/phpdocsmodel.h --- a/docs/phpdocsmodel.h +++ b/docs/phpdocsmodel.h @@ -39,8 +39,8 @@ Q_OBJECT public: - explicit PhpDocsModel(QObject* parent = 0); - ~PhpDocsModel(); + explicit PhpDocsModel(QObject* parent = nullptr); + ~PhpDocsModel() override; enum CustomDataRoles { /// returns the Declaration that a given index in the model represents diff --git a/docs/phpdocsplugin.h b/docs/phpdocsplugin.h --- a/docs/phpdocsplugin.h +++ b/docs/phpdocsplugin.h @@ -36,7 +36,7 @@ public: explicit PhpDocsPlugin(QObject *parent, const QVariantList & args= QVariantList()); - ~PhpDocsPlugin(); + ~PhpDocsPlugin() override; KDevelop::IDocumentation::Ptr documentationForDeclaration (KDevelop::Declaration* dec) const override; QAbstractListModel* indexModel() const override; diff --git a/docs/phpdocumentation.h b/docs/phpdocumentation.h --- a/docs/phpdocumentation.h +++ b/docs/phpdocumentation.h @@ -38,11 +38,11 @@ Q_OBJECT public: explicit PhpDocumentation(const QUrl& url, const QString& name, const QByteArray& description, PhpDocsPlugin* parent); - ~PhpDocumentation(); + ~PhpDocumentation() override; QString name() const override; QString description() const override; - QWidget* documentationWidget(KDevelop::DocumentationFindWidget* findWidget, QWidget* parent = 0) override; + QWidget* documentationWidget(KDevelop::DocumentationFindWidget* findWidget, QWidget* parent = nullptr) override; KDevelop::IDocumentationProvider* provider() const override; private: diff --git a/docs/phpdocumentationwidget.h b/docs/phpdocumentationwidget.h --- a/docs/phpdocumentationwidget.h +++ b/docs/phpdocumentationwidget.h @@ -40,8 +40,8 @@ public: explicit PhpDocumentationWidget(KDevelop::DocumentationFindWidget* find, const QUrl &url, - PhpDocsPlugin* provider, QWidget* parent = 0); - ~PhpDocumentationWidget(); + PhpDocsPlugin* provider, QWidget* parent = nullptr); + ~PhpDocumentationWidget() override; private slots: /// used to inject some custom CSS to alter the remote php.net site diff --git a/docs/phpdocumentationwidget.cpp b/docs/phpdocumentationwidget.cpp --- a/docs/phpdocumentationwidget.cpp +++ b/docs/phpdocumentationwidget.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include @@ -52,7 +53,7 @@ , m_provider(provider) { m_part = new KDevelop::StandardDocumentationView(find, this); - m_part->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); + m_part->setDelegateLinks(true); addWidget(m_part); addWidget(m_loading); @@ -62,8 +63,11 @@ progressbar->setMaximum(100); progressbar->setAlignment(Qt::AlignCenter); +// temporary disabled for initial porting to QWidget-only StandardDocumentationView +#if 0 connect( m_part, &KDevelop::StandardDocumentationView::loadProgress, progressbar, &QProgressBar::setValue ); +#endif QVBoxLayout* layout = new QVBoxLayout; layout->addStretch(); @@ -73,20 +77,27 @@ layout->addWidget(progressbar); layout->addStretch(); m_loading->setLayout(layout); +// temporary disabled for initial porting to QWidget-only StandardDocumentationView +#if 0 setCurrentWidget(m_loading); +#endif +// instead directly show part + setCurrentWidget(m_part); connect(m_part, &KDevelop::StandardDocumentationView::linkClicked, this, &PhpDocumentationWidget::linkClicked); +// temporary disabled for initial porting to QWidget-only StandardDocumentationView +#if 0 connect(m_part, &KDevelop::StandardDocumentationView::loadFinished, this, &PhpDocumentationWidget::documentLoaded); - +#endif m_part->load( url ); } PhpDocumentationWidget::~PhpDocumentationWidget() { // make sure we don't get called by any of the m_part signals on shutdown, see also: // https://codereview.qt-project.org/#/c/83800/ - disconnect(m_part, 0, this, 0); + disconnect(m_part, nullptr, this, nullptr); } void PhpDocumentationWidget::linkClicked(const QUrl& url) @@ -97,10 +108,10 @@ void PhpDocumentationWidget::documentLoaded() { - m_part->settings()->setUserStyleSheetUrl(QUrl::fromLocalFile(m_styleSheet->fileName())); + m_part->setOverrideCss(QUrl::fromLocalFile(m_styleSheet->fileName())); setCurrentWidget(m_part); removeWidget(m_loading); delete m_loading; - m_loading = 0; + m_loading = nullptr; } diff --git a/duchain/CMakeLists.txt b/duchain/CMakeLists.txt --- a/duchain/CMakeLists.txt +++ b/duchain/CMakeLists.txt @@ -29,7 +29,11 @@ navigation/includenavigationcontext.cpp navigation/magicconstantnavigationcontext.cpp completioncodemodel.cpp - duchaindebug.cpp +) +ecm_qt_declare_logging_category(duchain_SRCS + HEADER duchaindebug.h + IDENTIFIER DUCHAIN + CATEGORY_NAME "kdevelop.languages.php.duchain" ) add_library( kdevphpduchain SHARED ${duchain_SRCS} ) diff --git a/duchain/builders/contextbuilder.h b/duchain/builders/contextbuilder.h --- a/duchain/builders/contextbuilder.h +++ b/duchain/builders/contextbuilder.h @@ -45,44 +45,44 @@ public: ContextBuilder(); - virtual ~ContextBuilder(); + ~ContextBuilder() override; - virtual KDevelop::ReferencedTopDUContext build(const KDevelop::IndexedString& url, AstNode* node, + KDevelop::ReferencedTopDUContext build(const KDevelop::IndexedString& url, AstNode* node, KDevelop::ReferencedTopDUContext updateContext - = KDevelop::ReferencedTopDUContext()); + = KDevelop::ReferencedTopDUContext()) override; bool hadUnresolvedIdentifiers() const; EditorIntegrator* editor() const; protected: - virtual KDevelop::DUContext* newContext(const KDevelop::RangeInRevision& range); - virtual KDevelop::TopDUContext* newTopContext(const KDevelop::RangeInRevision& range, KDevelop::ParsingEnvironmentFile* file = 0); + KDevelop::DUContext* newContext(const KDevelop::RangeInRevision& range) override; + KDevelop::TopDUContext* newTopContext(const KDevelop::RangeInRevision& range, KDevelop::ParsingEnvironmentFile* file = nullptr) override; - virtual void startVisiting(AstNode* node); - virtual void setContextOnNode(AstNode* node, KDevelop::DUContext* ctx); - virtual KDevelop::DUContext* contextFromNode(AstNode* node); - virtual KDevelop::RangeInRevision editorFindRange(AstNode* fromRange, AstNode* toRange = 0); + void startVisiting(AstNode* node) override; + void setContextOnNode(AstNode* node, KDevelop::DUContext* ctx) override; + KDevelop::DUContext* contextFromNode(AstNode* node) override; + KDevelop::RangeInRevision editorFindRange(AstNode* fromRange, AstNode* toRange = nullptr) override; /// Find Cursor for start of a node, useful to limit findLocalDeclarations() searches. KDevelop::CursorInRevision startPos( AstNode* node); - virtual KDevelop::QualifiedIdentifier identifierForNode(IdentifierAst* id); + KDevelop::QualifiedIdentifier identifierForNode(IdentifierAst* id) override; KDevelop::QualifiedIdentifier identifierForNode(VariableIdentifierAst* id); IdentifierPair identifierPairForNode(IdentifierAst* id); QString stringForNode(IdentifierAst* node) const; QString stringForNode(VariableIdentifierAst* node) const; - virtual void visitClassDeclarationStatement(ClassDeclarationStatementAst*); - virtual void visitInterfaceDeclarationStatement(InterfaceDeclarationStatementAst* node); - virtual void visitTraitDeclarationStatement(TraitDeclarationStatementAst* node); - virtual void visitClassStatement(ClassStatementAst *node); - virtual void visitFunctionDeclarationStatement(FunctionDeclarationStatementAst* node); - virtual void visitClosure(ClosureAst* node); - virtual void visitUnaryExpression(UnaryExpressionAst* node); + void visitClassDeclarationStatement(ClassDeclarationStatementAst*) override; + void visitInterfaceDeclarationStatement(InterfaceDeclarationStatementAst* node) override; + void visitTraitDeclarationStatement(TraitDeclarationStatementAst* node) override; + void visitClassStatement(ClassStatementAst *node) override; + void visitFunctionDeclarationStatement(FunctionDeclarationStatementAst* node) override; + void visitClosure(ClosureAst* node) override; + void visitUnaryExpression(UnaryExpressionAst* node) override; /** * don't overload in other builders, use @c openNamespace and @c closeNamespace instead. */ - virtual void visitNamespaceDeclarationStatement(NamespaceDeclarationStatementAst* node); + void visitNamespaceDeclarationStatement(NamespaceDeclarationStatementAst* node) override; virtual void openNamespace(NamespaceDeclarationStatementAst* parent, IdentifierAst* node, const IdentifierPair& identifier, const KDevelop::RangeInRevision& range); virtual void closeNamespace(NamespaceDeclarationStatementAst* parent, IdentifierAst* node, const IdentifierPair& identifier); diff --git a/duchain/builders/contextbuilder.cpp b/duchain/builders/contextbuilder.cpp --- a/duchain/builders/contextbuilder.cpp +++ b/duchain/builders/contextbuilder.cpp @@ -27,18 +27,19 @@ #include #include #include +#include #include #include #include #include "../editorintegrator.h" #include "../helper.h" -#include "../duchaindebug.h" #include "../phpducontext.h" #include "../parser/parsesession.h" #include "../parser/phpast.h" +#include using namespace KDevelop; @@ -48,7 +49,7 @@ ContextBuilder::ContextBuilder() : m_isInternalFunctions(false), m_reportErrors(true), m_mapAst(false), m_hadUnresolvedIdentifiers(false), - m_editor(0), m_openNamespaces(0) + m_editor(nullptr), m_openNamespaces(nullptr) { } @@ -132,7 +133,7 @@ visitNode(node); if (m_openNamespaces) { closeNamespaces(m_openNamespaces); - m_openNamespaces = 0; + m_openNamespaces = nullptr; } } @@ -297,7 +298,7 @@ visitParameterList(node->parameters); closeContext(); - DUContext* imported = 0; + DUContext* imported = nullptr; if ( node->lexicalVars ) { imported = openContext(node->lexicalVars, DUContext::Other); Q_ASSERT(!imported->inSymbolTable()); @@ -327,7 +328,7 @@ // close existing namespace context if (m_openNamespaces) { closeNamespaces(m_openNamespaces); - m_openNamespaces = 0; + m_openNamespaces = nullptr; } if ( !node->namespaceNameSequence ) { @@ -397,7 +398,7 @@ findDeclarationImport(ClassDeclarationType, identifierForNamespace(identifier, m_editor)).data() ); if (currentClass && baseClass) { - if (DUContext* baseContext = baseClass->logicalInternalContext(0)) { + if (DUContext* baseContext = baseClass->logicalInternalContext(nullptr)) { // prevent circular context imports which could lead to segfaults if (!baseContext->imports(currentContext()) && !currentContext()->imports(baseContext)) { currentContext()->addImportedParentContext(baseContext); diff --git a/duchain/builders/declarationbuilder.h b/duchain/builders/declarationbuilder.h --- a/duchain/builders/declarationbuilder.h +++ b/duchain/builders/declarationbuilder.h @@ -56,61 +56,62 @@ m_editor = editor; m_findVariable.find = false; } - virtual KDevelop::ReferencedTopDUContext build(const KDevelop::IndexedString& url, AstNode* node, + KDevelop::ReferencedTopDUContext build(const KDevelop::IndexedString& url, AstNode* node, KDevelop::ReferencedTopDUContext updateContext - = KDevelop::ReferencedTopDUContext()); + = KDevelop::ReferencedTopDUContext()) override; - virtual void startVisiting(AstNode* node); + void startVisiting(AstNode* node) override; protected: - virtual void visitClassDeclarationStatement(ClassDeclarationStatementAst *node); - virtual void visitInterfaceDeclarationStatement(InterfaceDeclarationStatementAst *node); - virtual void visitTraitDeclarationStatement(TraitDeclarationStatementAst *node); - virtual void visitClassStatement(ClassStatementAst *node); + void visitClassDeclarationStatement(ClassDeclarationStatementAst *node) override; + void visitInterfaceDeclarationStatement(InterfaceDeclarationStatementAst *node) override; + void visitTraitDeclarationStatement(TraitDeclarationStatementAst *node) override; + void visitClassStatement(ClassStatementAst *node) override; virtual void importTraitMethods(ClassStatementAst *node); - virtual void visitClassExtends(ClassExtendsAst *node); - virtual void visitClassImplements(ClassImplementsAst *node); - virtual void visitParameter(ParameterAst *node); - virtual void visitFunctionDeclarationStatement(FunctionDeclarationStatementAst *node); - virtual void visitClassVariable(ClassVariableAst *node); - virtual void visitConstantDeclaration(ConstantDeclarationAst *node); - virtual void visitTraitAliasStatement(TraitAliasStatementAst *node); + void visitClassExtends(ClassExtendsAst *node) override; + void visitClassImplements(ClassImplementsAst *node) override; + void visitParameterList(ParameterListAst *node) override; + void visitParameter(ParameterAst *node) override; + void visitFunctionDeclarationStatement(FunctionDeclarationStatementAst *node) override; + void visitClassVariable(ClassVariableAst *node) override; + void visitConstantDeclaration(ConstantDeclarationAst *node) override; + void visitTraitAliasStatement(TraitAliasStatementAst *node) override; virtual void createTraitAliasDeclarations(TraitAliasStatementAst *node, KDevelop::DeclarationPointer dec); - virtual void visitOuterTopStatement(OuterTopStatementAst* node); - virtual void visitAssignmentExpression(AssignmentExpressionAst* node); - virtual void visitAssignmentExpressionEqual(AssignmentExpressionEqualAst *node); - virtual void visitVariable(VariableAst* node); - virtual void visitFunctionCall(FunctionCallAst* node); - virtual void visitFunctionCallParameterList(FunctionCallParameterListAst* node); - virtual void visitFunctionCallParameterListElement(FunctionCallParameterListElementAst* node); - virtual void visitStatement(StatementAst* node); - virtual void visitStaticVar(StaticVarAst* node); - virtual void visitGlobalVar(GlobalVarAst* node); - virtual void visitCatchItem(CatchItemAst *node); - virtual void visitUnaryExpression( UnaryExpressionAst* node ); - virtual void visitAssignmentListElement(AssignmentListElementAst* node); - virtual void openNamespace(NamespaceDeclarationStatementAst* parent, IdentifierAst* node, const IdentifierPair& identifier, const KDevelop::RangeInRevision& range); - virtual void closeNamespace(NamespaceDeclarationStatementAst* parent, IdentifierAst* node, const IdentifierPair& identifier); - virtual void visitUseNamespace(UseNamespaceAst* node); - virtual void visitClosure(ClosureAst* node); - virtual void visitLexicalVar(LexicalVarAst* node); + void visitOuterTopStatement(OuterTopStatementAst* node) override; + void visitAssignmentExpression(AssignmentExpressionAst* node) override; + void visitAssignmentExpressionEqual(AssignmentExpressionEqualAst *node) override; + void visitVariable(VariableAst* node) override; + void visitFunctionCall(FunctionCallAst* node) override; + void visitFunctionCallParameterList(FunctionCallParameterListAst* node) override; + void visitFunctionCallParameterListElement(FunctionCallParameterListElementAst* node) override; + void visitStatement(StatementAst* node) override; + void visitStaticVar(StaticVarAst* node) override; + void visitGlobalVar(GlobalVarAst* node) override; + void visitCatchItem(CatchItemAst *node) override; + void visitUnaryExpression( UnaryExpressionAst* node ) override; + void visitAssignmentListElement(AssignmentListElementAst* node) override; + void openNamespace(NamespaceDeclarationStatementAst* parent, IdentifierAst* node, const IdentifierPair& identifier, const KDevelop::RangeInRevision& range) override; + void closeNamespace(NamespaceDeclarationStatementAst* parent, IdentifierAst* node, const IdentifierPair& identifier) override; + void visitUseNamespace(UseNamespaceAst* node) override; + void visitClosure(ClosureAst* node) override; + void visitLexicalVar(LexicalVarAst* node) override; /// checks whether the body is empty (i.e. equals ";" instead of "{...}") bool isEmptyMethodBody(const MethodBodyAst* body) const { return !body || !body->statements; } - virtual void closeDeclaration(); - void classContextOpened(KDevelop::DUContext* context); + void closeDeclaration() override; + void classContextOpened(KDevelop::DUContext* context) override; - virtual void supportBuild(AstNode* node, KDevelop::DUContext* context = 0); - virtual void closeContext(); + void supportBuild(AstNode* node, KDevelop::DUContext* context = nullptr) override; + void closeContext() override; /// don't forget to closeDeclaration() afterwards /// set m_currentModifers to your likings and reset it afterwards void openClassMemberDeclaration(AstNode* node, const KDevelop::QualifiedIdentifier& name); - virtual void updateCurrentType(); + void updateCurrentType() override; private: /// because the predeclarationbuilder runs before us, @@ -142,6 +143,10 @@ int m_functionCallParameterPos; /// Type of the current function, will only be set inside function calls. KDevelop::FunctionType::Ptr m_currentFunctionType; + /// The AstNode of the previous function declaration argument + ParameterAst *m_functionDeclarationPreviousArgument; + /// The AstNode of the previous function call argument + FunctionCallParameterListElementAst *m_functionCallPreviousArgument; unsigned int m_currentModifers; QString m_lastTopStatementComment; diff --git a/duchain/builders/declarationbuilder.cpp b/duchain/builders/declarationbuilder.cpp --- a/duchain/builders/declarationbuilder.cpp +++ b/duchain/builders/declarationbuilder.cpp @@ -46,10 +46,10 @@ #include "../parser/parsesession.h" #include "../helper.h" -#include "../duchaindebug.h" #include "../expressionvisitor.h" #include "predeclarationbuilder.h" +#include #define ifDebug(x) @@ -61,7 +61,7 @@ DeclarationBuilder::FindVariableResults::FindVariableResults() : find(true) , isArray(false) -, node(0) +, node(nullptr) { } @@ -214,7 +214,7 @@ ClassDeclaration* DeclarationBuilder::openTypeDeclaration(IdentifierAst* name, ClassDeclarationData::ClassType type) { - ClassDeclaration* classDec = m_types.value(name->string, 0); + ClassDeclaration* classDec = m_types.value(name->string, nullptr); Q_ASSERT(classDec); isGlobalRedeclaration(identifierForNode(name), name, ClassDeclarationType); Q_ASSERT(classDec->classType() == type); @@ -410,8 +410,8 @@ break; } - QVector declarations = dec.data()->internalContext()->localDeclarations(0); - QVector localDeclarations = currentContext()->localDeclarations(0); + QVector declarations = dec.data()->internalContext()->localDeclarations(nullptr); + QVector localDeclarations = currentContext()->localDeclarations(nullptr); ifDebug(qCDebug(DUCHAIN) << "Importing from" << dec.data()->identifier().toString() << "to" << currentContext()->localScopeIdentifier().toString();) @@ -762,14 +762,24 @@ } } +void DeclarationBuilder::visitParameterList(ParameterListAst* node) +{ + PushValue push(m_functionDeclarationPreviousArgument, 0); + + DeclarationBuilderBase::visitParameterList(node); +} + void DeclarationBuilder::visitParameter(ParameterAst *node) { AbstractFunctionDeclaration* funDec = dynamic_cast(currentDeclaration()); Q_ASSERT(funDec); + if (node->defaultValue) { QString symbol = m_editor->parseSession()->symbol(node->defaultValue); funDec->addDefaultParameter(IndexedString(symbol)); - if ( node->parameterType && symbol.compare(QLatin1String("null"), Qt::CaseInsensitive) != 0 ) { + if (node->isVariadic != -1) { + reportError(i18n("Variadic parameter cannot have a default value"), node->defaultValue); + } else if ( node->parameterType && symbol.compare(QLatin1String("null"), Qt::CaseInsensitive) != 0 ) { reportError(i18n("Default value for parameters with a class type hint can only be NULL."), node->defaultValue); } } else if ( !node->defaultValue && funDec->defaultParametersSize() ) { @@ -784,14 +794,21 @@ } DeclarationBuilderBase::visitParameter(node); + + if (m_functionDeclarationPreviousArgument && m_functionDeclarationPreviousArgument->isVariadic != -1) { + reportError(i18n("Only the last parameter can be variadic."), m_functionDeclarationPreviousArgument); + } + closeDeclaration(); + + m_functionDeclarationPreviousArgument = node; } void DeclarationBuilder::visitFunctionDeclarationStatement(FunctionDeclarationStatementAst* node) { isGlobalRedeclaration(identifierForNode(node->functionName), node->functionName, FunctionDeclarationType); - FunctionDeclaration* dec = m_functions.value(node->functionName->string, 0); + FunctionDeclaration* dec = m_functions.value(node->functionName->string, nullptr); Q_ASSERT(dec); // seems like we have to set that, else the usebuilder crashes @@ -992,7 +1009,7 @@ // check if this variable is already declared { - QList< Declaration* > decs = parentCtx->findDeclarations(identifier.first(), startPos(node), 0, DUContext::DontSearchInParent); + QList< Declaration* > decs = parentCtx->findDeclarations(identifier.first(), startPos(node), nullptr, DUContext::DontSearchInParent); if ( !decs.isEmpty() ) { QList< Declaration* >::const_iterator it = decs.constEnd() - 1; while ( true ) { @@ -1093,7 +1110,7 @@ } ///TODO: if we can't find anything here we might have to use the findDeclarationImport helper } - return 0; + return nullptr; } ///TODO: we need to handle assignment to array-members properly @@ -1146,7 +1163,7 @@ if ( dec ) { m_currentFunctionType = dec->type(); } else { - m_currentFunctionType = 0; + m_currentFunctionType = nullptr; } DeclarationBuilderBase::visitFunctionCall(node); @@ -1200,12 +1217,10 @@ void DeclarationBuilder::visitFunctionCallParameterList(FunctionCallParameterListAst* node) { - int oldPos = m_functionCallParameterPos; - m_functionCallParameterPos = 0; + PushValue push(m_functionCallPreviousArgument, 0); + PushValue pos(m_functionCallParameterPos, 0); DeclarationBuilderBase::visitFunctionCallParameterList(node); - - m_functionCallParameterPos = oldPos; } void DeclarationBuilder::visitFunctionCallParameterListElement(FunctionCallParameterListElementAst* node) @@ -1228,6 +1243,12 @@ } } + if (m_functionCallPreviousArgument && m_functionCallPreviousArgument->isVariadic != -1 && node->isVariadic == -1) { + reportError(i18n("Cannot use positional argument after argument unpacking"), node); + } + + m_functionCallPreviousArgument = node; + ++m_functionCallParameterPos; } @@ -1249,7 +1270,7 @@ ///TODO: support something like: foo($var[0]) if ( !m_findVariable.isArray ) { - DUContext *ctx = 0; + DUContext *ctx = nullptr; if ( m_findVariable.parentIdentifier.isEmpty() ) { ctx = currentContext(); } else { @@ -1400,7 +1421,7 @@ void DeclarationBuilder::openNamespace(NamespaceDeclarationStatementAst* parent, IdentifierAst* node, const IdentifierPair& identifier, const RangeInRevision& range) { - NamespaceDeclaration* dec = m_namespaces.value(node->string, 0); + NamespaceDeclaration* dec = m_namespaces.value(node->string, nullptr); Q_ASSERT(dec); DeclarationBuilderBase::setEncountered(dec); openDeclarationInternal(dec); diff --git a/duchain/builders/predeclarationbuilder.h b/duchain/builders/predeclarationbuilder.h --- a/duchain/builders/predeclarationbuilder.h +++ b/duchain/builders/predeclarationbuilder.h @@ -58,23 +58,23 @@ m_editor = editor; } - virtual ~PreDeclarationBuilder(); + ~PreDeclarationBuilder() override; /// make it accessible to the declaration builder bool didRecompile() { return recompiling(); } protected: // virtual void visitNode(AstNode* node); - virtual void visitClassDeclarationStatement(ClassDeclarationStatementAst *node); - virtual void visitInterfaceDeclarationStatement(InterfaceDeclarationStatementAst *node); - virtual void visitTraitDeclarationStatement(TraitDeclarationStatementAst *node); - virtual void visitFunctionDeclarationStatement(FunctionDeclarationStatementAst *node); - virtual void visitClassVariable(ClassVariableAst* node); - virtual void openNamespace(NamespaceDeclarationStatementAst* parent, IdentifierAst* node, const IdentifierPair& identifier, const KDevelop::RangeInRevision& range); - virtual void closeNamespace(NamespaceDeclarationStatementAst* parent, IdentifierAst* node, const IdentifierPair& identifier); + void visitClassDeclarationStatement(ClassDeclarationStatementAst *node) override; + void visitInterfaceDeclarationStatement(InterfaceDeclarationStatementAst *node) override; + void visitTraitDeclarationStatement(TraitDeclarationStatementAst *node) override; + void visitFunctionDeclarationStatement(FunctionDeclarationStatementAst *node) override; + void visitClassVariable(ClassVariableAst* node) override; + void openNamespace(NamespaceDeclarationStatementAst* parent, IdentifierAst* node, const IdentifierPair& identifier, const KDevelop::RangeInRevision& range) override; + void closeNamespace(NamespaceDeclarationStatementAst* parent, IdentifierAst* node, const IdentifierPair& identifier) override; - virtual void closeDeclaration(); - virtual void closeContext(); + void closeDeclaration() override; + void closeContext() override; private: QHash* m_types; QHash* m_functions; diff --git a/duchain/builders/predeclarationbuilder.cpp b/duchain/builders/predeclarationbuilder.cpp --- a/duchain/builders/predeclarationbuilder.cpp +++ b/duchain/builders/predeclarationbuilder.cpp @@ -35,7 +35,7 @@ #include "../declarations/variabledeclaration.h" #include "../declarations/namespacedeclaration.h" #include "../types/structuretype.h" -#include "../duchaindebug.h" +#include using namespace KDevelop; diff --git a/duchain/builders/typebuilder.h b/duchain/builders/typebuilder.h --- a/duchain/builders/typebuilder.h +++ b/duchain/builders/typebuilder.h @@ -45,23 +45,23 @@ { public: TypeBuilder(); - ~TypeBuilder(); + ~TypeBuilder() override; protected: - virtual void visitClassDeclarationStatement(ClassDeclarationStatementAst* node); - virtual void visitInterfaceDeclarationStatement(InterfaceDeclarationStatementAst* node); - virtual void visitTraitDeclarationStatement(TraitDeclarationStatementAst* node); - virtual void visitClassStatement(ClassStatementAst *node); - virtual void visitClassVariable(ClassVariableAst *node); - virtual void visitConstantDeclaration(ConstantDeclarationAst* node); - virtual void visitParameter(ParameterAst *node); - virtual void visitFunctionDeclarationStatement(FunctionDeclarationStatementAst* node); - virtual void visitClosure(ClosureAst* node); - - virtual void visitStatement(StatementAst* node); - virtual void visitAssignmentExpression(AssignmentExpressionAst* node); - virtual void visitStaticVar(StaticVarAst *node); - virtual void visitCatchItem(CatchItemAst *node); + void visitClassDeclarationStatement(ClassDeclarationStatementAst* node) override; + void visitInterfaceDeclarationStatement(InterfaceDeclarationStatementAst* node) override; + void visitTraitDeclarationStatement(TraitDeclarationStatementAst* node) override; + void visitClassStatement(ClassStatementAst *node) override; + void visitClassVariable(ClassVariableAst *node) override; + void visitConstantDeclaration(ConstantDeclarationAst* node) override; + void visitParameter(ParameterAst *node) override; + void visitFunctionDeclarationStatement(FunctionDeclarationStatementAst* node) override; + void visitClosure(ClosureAst* node) override; + + void visitStatement(StatementAst* node) override; + void visitAssignmentExpression(AssignmentExpressionAst* node) override; + void visitStaticVar(StaticVarAst *node) override; + void visitCatchItem(CatchItemAst *node) override; /// The declaration builder implements this and updates /// the type of the current declaration diff --git a/duchain/builders/typebuilder.cpp b/duchain/builders/typebuilder.cpp --- a/duchain/builders/typebuilder.cpp +++ b/duchain/builders/typebuilder.cpp @@ -29,7 +29,7 @@ #include "../declarations/classdeclaration.h" #include "../types/integraltypeextended.h" #include "../types/structuretype.h" -#include "../duchaindebug.h" +#include #include "editorintegrator.h" #include "parsesession.h" @@ -357,7 +357,9 @@ void TypeBuilder::visitParameter(ParameterAst *node) { AbstractType::Ptr type; - if (node->parameterType) { + if (node->isVariadic != -1) { + type = AbstractType::Ptr(new IntegralType(IntegralType::TypeArray)); + } else if (node->parameterType) { //don't use openTypeFromName as it uses cursor for findDeclarations DeclarationPointer decl = findDeclarationImport(ClassDeclarationType, identifierForNamespace(node->parameterType, editor())); @@ -508,7 +510,7 @@ } } - AstNode *foreachNode = 0; + AstNode *foreachNode = nullptr; if (node->foreachVar) { foreachNode = node->foreachVar; } else if (node->foreachExpr) { @@ -528,7 +530,7 @@ ///FIXME: this is just a hack for https://bugs.kde.org/show_bug.cgi?id=269369 /// a proper fix needs full fledged two-pass, i.e. get rid of PreDeclarationBuilder // 0 == global lookup and the delcaration is found again... - classDec = dynamic_cast(type->declaration(0)); + classDec = dynamic_cast(type->declaration(nullptr)); } if (classDec) { /// Qualified identifier for 'iterator' diff --git a/duchain/builders/usebuilder.h b/duchain/builders/usebuilder.h --- a/duchain/builders/usebuilder.h +++ b/duchain/builders/usebuilder.h @@ -49,25 +49,25 @@ */ void newCheckedUse(Php::AstNode* node, const KDevelop::DeclarationPointer& declaration, bool reportNotFound = false); - virtual KDevelop::ReferencedTopDUContext build(const KDevelop::IndexedString& url, AstNode* node, + KDevelop::ReferencedTopDUContext build(const KDevelop::IndexedString& url, AstNode* node, KDevelop::ReferencedTopDUContext updateContext - = KDevelop::ReferencedTopDUContext()); + = KDevelop::ReferencedTopDUContext()) override; protected: - virtual void visitParameter(ParameterAst *node); - virtual void visitClassImplements(ClassImplementsAst *node); - virtual void visitClassExtends(ClassExtendsAst *node); - virtual void visitClassStatement(ClassStatementAst *node); - virtual void visitTraitAliasStatement(TraitAliasStatementAst *node); - virtual void visitTraitAliasIdentifier(TraitAliasIdentifierAst *node); - virtual void visitExpr(ExprAst* node); - virtual void visitGlobalVar(GlobalVarAst* node); - virtual void visitStaticScalar(StaticScalarAst* node); - virtual void visitStatement(StatementAst* node); - virtual void visitCatchItem(CatchItemAst* node); - virtual void visitUnaryExpression( UnaryExpressionAst* node ); - virtual void visitUseNamespace(UseNamespaceAst* node); - virtual void openNamespace(NamespaceDeclarationStatementAst* parent, IdentifierAst* node, const IdentifierPair& identifier, const KDevelop::RangeInRevision& range); + void visitParameter(ParameterAst *node) override; + void visitClassImplements(ClassImplementsAst *node) override; + void visitClassExtends(ClassExtendsAst *node) override; + void visitClassStatement(ClassStatementAst *node) override; + void visitTraitAliasStatement(TraitAliasStatementAst *node) override; + void visitTraitAliasIdentifier(TraitAliasIdentifierAst *node) override; + void visitExpr(ExprAst* node) override; + void visitGlobalVar(GlobalVarAst* node) override; + void visitStaticScalar(StaticScalarAst* node) override; + void visitStatement(StatementAst* node) override; + void visitCatchItem(CatchItemAst* node) override; + void visitUnaryExpression( UnaryExpressionAst* node ) override; + void visitUseNamespace(UseNamespaceAst* node) override; + void openNamespace(NamespaceDeclarationStatementAst* parent, IdentifierAst* node, const IdentifierPair& identifier, const KDevelop::RangeInRevision& range) override; private: void buildNamespaceUses(Php::NamespacedIdentifierAst* node, Php::DeclarationType lastType = Php::ClassDeclarationType); diff --git a/duchain/builders/usebuilder.cpp b/duchain/builders/usebuilder.cpp --- a/duchain/builders/usebuilder.cpp +++ b/duchain/builders/usebuilder.cpp @@ -25,7 +25,7 @@ #include "editorintegrator.h" #include "expressionvisitor.h" #include "parsesession.h" -#include "../duchaindebug.h" +#include using namespace KDevelop; @@ -40,7 +40,7 @@ } protected: - virtual void usingDeclaration(AstNode* node, const DeclarationPointer& decl) { + void usingDeclaration(AstNode* node, const DeclarationPointer& decl) override { m_builder->newCheckedUse(node, decl); } diff --git a/duchain/completioncodemodel.cpp b/duchain/completioncodemodel.cpp --- a/duchain/completioncodemodel.cpp +++ b/duchain/completioncodemodel.cpp @@ -351,7 +351,7 @@ }else{ ifDebug( qCDebug(DUCHAIN) << "found no index"; ) count = 0; - items = 0; + items = nullptr; } } diff --git a/duchain/declarations/classdeclaration.h b/duchain/declarations/classdeclaration.h --- a/duchain/declarations/classdeclaration.h +++ b/duchain/declarations/classdeclaration.h @@ -55,9 +55,9 @@ ClassDeclaration(const KDevelop::RangeInRevision &range, KDevelop::DUContext *context); ClassDeclaration(ClassDeclarationData &data); ClassDeclaration(ClassDeclarationData &data, const KDevelop::RangeInRevision &range, KDevelop::DUContext *context); - ~ClassDeclaration(); + ~ClassDeclaration() override; - virtual QString toString() const; + QString toString() const override; void setPrettyName(const KDevelop::IndexedString& name); KDevelop::IndexedString prettyName() const; @@ -68,7 +68,7 @@ Identity = 85 }; - virtual KDevelop::Declaration* clonePrivate() const; + KDevelop::Declaration* clonePrivate() const override; private: DUCHAIN_DECLARE_DATA(ClassDeclaration) }; diff --git a/duchain/declarations/classmethoddeclaration.h b/duchain/declarations/classmethoddeclaration.h --- a/duchain/declarations/classmethoddeclaration.h +++ b/duchain/declarations/classmethoddeclaration.h @@ -59,23 +59,23 @@ ClassMethodDeclaration(const KDevelop::RangeInRevision &range, KDevelop::DUContext *context); ClassMethodDeclaration(ClassMethodDeclarationData &data); ClassMethodDeclaration(ClassMethodDeclarationData &data, const KDevelop::RangeInRevision &range, KDevelop::DUContext *context); - ~ClassMethodDeclaration(); + ~ClassMethodDeclaration() override; /// overwritten to check for __construct() method - virtual bool isConstructor() const; + bool isConstructor() const override; /// overwritten to check for __destruct() method - virtual bool isDestructor() const; + bool isDestructor() const override; - virtual QString toString() const; + QString toString() const override; void setPrettyName(const KDevelop::IndexedString& name); KDevelop::IndexedString prettyName() const; enum { Identity = 84 }; - virtual KDevelop::Declaration* clonePrivate() const; + KDevelop::Declaration* clonePrivate() const override; private: DUCHAIN_DECLARE_DATA(ClassMethodDeclaration) }; diff --git a/duchain/declarations/classmethoddeclaration.cpp b/duchain/declarations/classmethoddeclaration.cpp --- a/duchain/declarations/classmethoddeclaration.cpp +++ b/duchain/declarations/classmethoddeclaration.cpp @@ -23,7 +23,7 @@ #include #include -#include "../duchaindebug.h" +#include using namespace KDevelop; diff --git a/duchain/declarations/functiondeclaration.h b/duchain/declarations/functiondeclaration.h --- a/duchain/declarations/functiondeclaration.h +++ b/duchain/declarations/functiondeclaration.h @@ -55,18 +55,18 @@ FunctionDeclaration(const KDevelop::RangeInRevision &range, KDevelop::DUContext *context); FunctionDeclaration(FunctionDeclarationData &data); FunctionDeclaration(FunctionDeclarationData &data, const KDevelop::RangeInRevision &range, KDevelop::DUContext *context); - ~FunctionDeclaration(); + ~FunctionDeclaration() override; - virtual QString toString() const; + QString toString() const override; void setPrettyName(const KDevelop::IndexedString& name); KDevelop::IndexedString prettyName() const; enum { Identity = 86 }; - virtual KDevelop::Declaration* clonePrivate() const; + KDevelop::Declaration* clonePrivate() const override; private: DUCHAIN_DECLARE_DATA(FunctionDeclaration) }; diff --git a/duchain/declarations/namespacealiasdeclaration.h b/duchain/declarations/namespacealiasdeclaration.h --- a/duchain/declarations/namespacealiasdeclaration.h +++ b/duchain/declarations/namespacealiasdeclaration.h @@ -54,18 +54,18 @@ NamespaceAliasDeclaration(const NamespaceAliasDeclaration& rhs); NamespaceAliasDeclaration(const KDevelop::RangeInRevision& range, KDevelop::DUContext* context); NamespaceAliasDeclaration(NamespaceAliasDeclarationData& data); - virtual ~NamespaceAliasDeclaration(); + ~NamespaceAliasDeclaration() override; - virtual QString toString() const; + QString toString() const override; void setPrettyName(const KDevelop::IndexedString& name); KDevelop::IndexedString prettyName() const; enum { Identity = 88 }; - virtual KDevelop::Declaration* clonePrivate() const; + KDevelop::Declaration* clonePrivate() const override; private: DUCHAIN_DECLARE_DATA(NamespaceAliasDeclaration) }; diff --git a/duchain/declarations/namespacedeclaration.h b/duchain/declarations/namespacedeclaration.h --- a/duchain/declarations/namespacedeclaration.h +++ b/duchain/declarations/namespacedeclaration.h @@ -53,18 +53,18 @@ NamespaceDeclaration(const NamespaceDeclaration &rhs); NamespaceDeclaration(const KDevelop::RangeInRevision &range, KDevelop::DUContext *parentContext); NamespaceDeclaration(NamespaceDeclarationData &data); - virtual ~NamespaceDeclaration(); + ~NamespaceDeclaration() override; - virtual QString toString() const; + QString toString() const override; void setPrettyName(const KDevelop::IndexedString& name); KDevelop::IndexedString prettyName() const; enum { Identity = 87 }; - virtual KDevelop::Declaration* clonePrivate() const; + KDevelop::Declaration* clonePrivate() const override; private: DUCHAIN_DECLARE_DATA(NamespaceDeclaration) }; diff --git a/duchain/declarations/traitmemberaliasdeclaration.h b/duchain/declarations/traitmemberaliasdeclaration.h --- a/duchain/declarations/traitmemberaliasdeclaration.h +++ b/duchain/declarations/traitmemberaliasdeclaration.h @@ -54,9 +54,9 @@ TraitMemberAliasDeclaration(const TraitMemberAliasDeclaration& rhs); TraitMemberAliasDeclaration(const KDevelop::RangeInRevision& range, KDevelop::DUContext* context); TraitMemberAliasDeclaration(TraitMemberAliasDeclarationData& dd); - ~TraitMemberAliasDeclaration(); + ~TraitMemberAliasDeclaration() override; - QString toString() const; + QString toString() const override; /** * Set the declaration that is aliased by this declaration. @@ -81,7 +81,7 @@ private: DUCHAIN_DECLARE_DATA(TraitMemberAliasDeclaration) - virtual KDevelop::Declaration* clonePrivate() const; + KDevelop::Declaration* clonePrivate() const override; }; } diff --git a/duchain/declarations/traitmethodaliasdeclaration.h b/duchain/declarations/traitmethodaliasdeclaration.h --- a/duchain/declarations/traitmethodaliasdeclaration.h +++ b/duchain/declarations/traitmethodaliasdeclaration.h @@ -38,9 +38,9 @@ TraitMethodAliasDeclaration(const KDevelop::RangeInRevision &range, KDevelop::DUContext *context); TraitMethodAliasDeclaration(TraitMethodAliasDeclarationData &data); TraitMethodAliasDeclaration(TraitMethodAliasDeclarationData &data, const KDevelop::RangeInRevision &range, KDevelop::DUContext *context); - ~TraitMethodAliasDeclaration(); + ~TraitMethodAliasDeclaration() override; - virtual QString toString() const; + QString toString() const override; /** * Set the declaration that is aliased by this declaration. @@ -74,7 +74,7 @@ Identity = 131 }; - virtual KDevelop::Declaration* clonePrivate() const; + KDevelop::Declaration* clonePrivate() const override; private: DUCHAIN_DECLARE_DATA(TraitMethodAliasDeclaration) }; diff --git a/duchain/declarations/variabledeclaration.h b/duchain/declarations/variabledeclaration.h --- a/duchain/declarations/variabledeclaration.h +++ b/duchain/declarations/variabledeclaration.h @@ -57,13 +57,13 @@ VariableDeclaration(const KDevelop::RangeInRevision& range, KDevelop::DUContext* context); VariableDeclaration(VariableDeclarationData& data); VariableDeclaration(VariableDeclarationData& data, const KDevelop::RangeInRevision&); - virtual ~VariableDeclaration(); + ~VariableDeclaration() override; bool isSuperglobal() const; void setSuperglobal(bool superglobal); - virtual uint additionalIdentity() const; - virtual KDevelop::DeclarationId id(bool forceDirect = false) const; + uint additionalIdentity() const override; + KDevelop::DeclarationId id(bool forceDirect = false) const override; enum { Identity = 83 diff --git a/duchain/duchaindebug.h b/duchain/duchaindebug.h deleted file mode 100644 --- a/duchain/duchaindebug.h +++ /dev/null @@ -1,26 +0,0 @@ -/* This file is part of KDevelop - - Copyright 2014 Milian Wolff - - 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 DUCHAINDEBUG_H -#define DUCHAINDEBUG_H - -#include -Q_DECLARE_LOGGING_CATEGORY(DUCHAIN) - -#endif /* DUCHAINDEBUG_H */ diff --git a/duchain/duchaindebug.cpp b/duchain/duchaindebug.cpp deleted file mode 100644 --- a/duchain/duchaindebug.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* This file is part of KDevelop - - Copyright 2014 Milian Wolff - - 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 "duchaindebug.h" - -Q_LOGGING_CATEGORY(DUCHAIN, "kdevelop.languages.php.duchain") diff --git a/duchain/dumptypes.h b/duchain/dumptypes.h --- a/duchain/dumptypes.h +++ b/duchain/dumptypes.h @@ -22,39 +22,41 @@ #include #include "phpduchainexport.h" +#include + namespace Php { class KDEVPHPDUCHAIN_EXPORT DumpTypes : protected KDevelop::TypeVisitor { public: DumpTypes(); - virtual ~DumpTypes(); + ~DumpTypes() override; void dump(const KDevelop::AbstractType* type); protected: - virtual bool preVisit(const KDevelop::AbstractType * type); - virtual void postVisit(const KDevelop::AbstractType *); + bool preVisit(const KDevelop::AbstractType * type) override; + void postVisit(const KDevelop::AbstractType *) override; - virtual void visit(const KDevelop::IntegralType *); + void visit(const KDevelop::IntegralType *) override; - virtual bool visit(const KDevelop::AbstractType *); + bool visit(const KDevelop::AbstractType *) override; - virtual bool visit(const KDevelop::PointerType * type); - virtual void endVisit(const KDevelop::PointerType *); + bool visit(const KDevelop::PointerType * type) override; + void endVisit(const KDevelop::PointerType *) override; - virtual bool visit(const KDevelop::ReferenceType * type); - virtual void endVisit(const KDevelop::ReferenceType *); + bool visit(const KDevelop::ReferenceType * type) override; + void endVisit(const KDevelop::ReferenceType *) override; - virtual bool visit(const KDevelop::FunctionType * type); - virtual void endVisit(const KDevelop::FunctionType *); + bool visit(const KDevelop::FunctionType * type) override; + void endVisit(const KDevelop::FunctionType *) override; - virtual bool visit(const KDevelop::StructureType * type); - virtual void endVisit(const KDevelop::StructureType *); + bool visit(const KDevelop::StructureType * type) override; + void endVisit(const KDevelop::StructureType *) override; - virtual bool visit(const KDevelop::ArrayType * type); - virtual void endVisit(const KDevelop::ArrayType *); + bool visit(const KDevelop::ArrayType * type) override; + void endVisit(const KDevelop::ArrayType *) override; private: bool seen(const KDevelop::AbstractType* type); diff --git a/duchain/expressionparser.cpp b/duchain/expressionparser.cpp --- a/duchain/expressionparser.cpp +++ b/duchain/expressionparser.cpp @@ -56,7 +56,7 @@ ParseSession* session = new ParseSession(); session->setContents(expression); Parser* parser = session->createParser(Parser::DefaultState); - ExprAst* ast = 0; + ExprAst* ast = nullptr; if (!parser->parseExpr(&ast)) { qCDebug(DUCHAIN) << "Failed to parse \"" << expression << "\""; delete session; diff --git a/duchain/expressionvisitor.h b/duchain/expressionvisitor.h --- a/duchain/expressionvisitor.h +++ b/duchain/expressionvisitor.h @@ -48,30 +48,30 @@ void setCreateProblems(bool v); void setOffset(const KDevelop::CursorInRevision& offset); - virtual void visitNode(AstNode *node); + void visitNode(AstNode *node) override; protected: KDevelop::DeclarationPointer processVariable( VariableIdentifierAst* variable); - void visitAssignmentExpression(AssignmentExpressionAst *node); - virtual void visitArrayIndexSpecifier(ArrayIndexSpecifierAst* node); - void visitCompoundVariableWithSimpleIndirectReference(CompoundVariableWithSimpleIndirectReferenceAst *node); - void visitVarExpressionNewObject(VarExpressionNewObjectAst *node); - virtual void visitVarExpressionArray(VarExpressionArrayAst *node); - virtual void visitClosure(ClosureAst* node); - void visitFunctionCall(FunctionCallAst* node); - void visitConstantOrClassConst(ConstantOrClassConstAst *node); - void visitScalar(ScalarAst *node); - void visitStaticScalar(StaticScalarAst *node); - void visitEncapsVar(EncapsVarAst *node); - void visitVariableProperty(VariablePropertyAst *node); - void visitStaticMember(StaticMemberAst* node); - void visitUnaryExpression(UnaryExpressionAst* node); - void visitAdditiveExpressionRest(AdditiveExpressionRestAst* node); - void visitVariable(VariableAst* node); - void visitFunctionCallParameterList( FunctionCallParameterListAst* node ); - void visitFunctionCallParameterListElement(FunctionCallParameterListElementAst* node); - void visitRelationalExpression(RelationalExpressionAst* node); + void visitAssignmentExpression(AssignmentExpressionAst *node) override; + void visitArrayIndexSpecifier(ArrayIndexSpecifierAst* node) override; + void visitCompoundVariableWithSimpleIndirectReference(CompoundVariableWithSimpleIndirectReferenceAst *node) override; + void visitVarExpressionNewObject(VarExpressionNewObjectAst *node) override; + void visitVarExpressionArray(VarExpressionArrayAst *node) override; + void visitClosure(ClosureAst* node) override; + void visitFunctionCall(FunctionCallAst* node) override; + void visitConstantOrClassConst(ConstantOrClassConstAst *node) override; + void visitScalar(ScalarAst *node) override; + void visitStaticScalar(StaticScalarAst *node) override; + void visitEncapsVar(EncapsVarAst *node) override; + void visitVariableProperty(VariablePropertyAst *node) override; + void visitStaticMember(StaticMemberAst* node) override; + void visitUnaryExpression(UnaryExpressionAst* node) override; + void visitAdditiveExpressionRest(AdditiveExpressionRestAst* node) override; + void visitVariable(VariableAst* node) override; + void visitFunctionCallParameterList( FunctionCallParameterListAst* node ) override; + void visitFunctionCallParameterListElement(FunctionCallParameterListElementAst* node) override; + void visitRelationalExpression(RelationalExpressionAst* node) override; QString stringForNode(AstNode* id); KDevelop::QualifiedIdentifier identifierForNode(IdentifierAst* id); diff --git a/duchain/expressionvisitor.cpp b/duchain/expressionvisitor.cpp --- a/duchain/expressionvisitor.cpp +++ b/duchain/expressionvisitor.cpp @@ -43,7 +43,7 @@ ExpressionVisitor::ExpressionVisitor(EditorIntegrator* editor) : m_editor(editor), m_createProblems(false), - m_offset(CursorInRevision::invalid()), m_currentContext(0), + m_offset(CursorInRevision::invalid()), m_currentContext(nullptr), m_isAssignmentExpressionEqual(false), m_inDefine(false) { @@ -374,7 +374,7 @@ ///TODO: DUContext pointer? DUContext* ExpressionVisitor::findClassContext(IdentifierAst* className) { - DUContext* context = 0; + DUContext* context = nullptr; DeclarationPointer declaration = findDeclarationImport(ClassDeclarationType, className); usingDeclaration(className, declaration); if (declaration) { @@ -390,7 +390,7 @@ ///TODO: DUContext pointer? DUContext* ExpressionVisitor::findClassContext(NamespacedIdentifierAst* className) { - DUContext* context = 0; + DUContext* context = nullptr; const QualifiedIdentifier id = identifierForNamespace(className, m_editor); DeclarationPointer declaration = findDeclarationImport(ClassDeclarationType, id); usingDeclaration(className->namespaceNameSequence->back()->element, declaration); @@ -805,15 +805,15 @@ CursorInRevision position, DUContext::SearchFlag flag) { QList decls = context->findDeclarations(identifier, position, - 0, flag); + nullptr, flag); for (int i = decls.count() - 1; i >= 0; i--) { Declaration *dec = decls.at(i); if (dec->kind() == Declaration::Instance && dynamic_cast(dec)) { return dec; } } - return NULL; + return nullptr; } } diff --git a/duchain/helper.cpp b/duchain/helper.cpp --- a/duchain/helper.cpp +++ b/duchain/helper.cpp @@ -112,7 +112,7 @@ } else if (declarationType == ClassDeclarationType && id == parentQId) { //there can be just one Class-Context imported DUChainReadLocker lock; - DUContext* classCtx = 0; + DUContext* classCtx = nullptr; if (currentContext->type() == DUContext::Class) { classCtx = currentContext; } else if (currentContext->parentContext() && currentContext->parentContext()->type() == DUContext::Class) { @@ -181,7 +181,7 @@ { ifDebug(qCDebug(DUCHAIN) << "PST: " << id.toString() << declarationType;) uint nr; - const IndexedDeclaration* declarations = 0; + const IndexedDeclaration* declarations = nullptr; DUChainWriteLocker wlock; PersistentSymbolTable::self().declarations(id, nr, declarations); ifDebug(qCDebug(DUCHAIN) << "found declarations:" << nr;) @@ -257,12 +257,12 @@ class ScalarExpressionVisitor : public DefaultVisitor { public: - ScalarExpressionVisitor() : m_node(0) {} + ScalarExpressionVisitor() : m_node(nullptr) {} CommonScalarAst* node() const { return m_node; } private: - virtual void visitCommonScalar(CommonScalarAst* node) { + void visitCommonScalar(CommonScalarAst* node) override { m_node = node; } CommonScalarAst* m_node; diff --git a/duchain/navigation/declarationnavigationcontext.h b/duchain/navigation/declarationnavigationcontext.h --- a/duchain/navigation/declarationnavigationcontext.h +++ b/duchain/navigation/declarationnavigationcontext.h @@ -28,17 +28,17 @@ class DeclarationNavigationContext : public KDevelop::AbstractDeclarationNavigationContext { public: - DeclarationNavigationContext(KDevelop::DeclarationPointer decl, KDevelop::TopDUContextPointer topContext, KDevelop::AbstractNavigationContext* previousContext = 0); + DeclarationNavigationContext(KDevelop::DeclarationPointer decl, KDevelop::TopDUContextPointer topContext, KDevelop::AbstractNavigationContext* previousContext = nullptr); protected: KDevelop::NavigationContextPointer registerChild(KDevelop::DeclarationPointer declaration); - virtual KDevelop::QualifiedIdentifier prettyQualifiedIdentifier( KDevelop::DeclarationPointer decl ) const; - virtual void htmlClass(); - virtual void htmlAdditionalNavigation(); + KDevelop::QualifiedIdentifier prettyQualifiedIdentifier( KDevelop::DeclarationPointer decl ) const override; + void htmlClass() override; + void htmlAdditionalNavigation() override; - void makeLink( const QString& name, KDevelop::DeclarationPointer declaration, KDevelop::NavigationAction::Type actionType ); + void makeLink( const QString& name, KDevelop::DeclarationPointer declaration, KDevelop::NavigationAction::Type actionType ) override; - virtual QString declarationKind(KDevelop::DeclarationPointer decl); + QString declarationKind(KDevelop::DeclarationPointer decl) override; }; } diff --git a/duchain/navigation/declarationnavigationcontext.cpp b/duchain/navigation/declarationnavigationcontext.cpp --- a/duchain/navigation/declarationnavigationcontext.cpp +++ b/duchain/navigation/declarationnavigationcontext.cpp @@ -46,14 +46,14 @@ NavigationContextPointer DeclarationNavigationContext::registerChild(DeclarationPointer declaration) { - return AbstractDeclarationNavigationContext::registerChild(new DeclarationNavigationContext(declaration, m_topContext, this)); + return AbstractDeclarationNavigationContext::registerChild(new DeclarationNavigationContext(declaration, topContext(), this)); } void DeclarationNavigationContext::htmlClass() { - StructureType::Ptr klass = m_declaration->abstractType().cast(); + StructureType::Ptr klass = declaration()->abstractType().cast(); Q_ASSERT(klass); - ClassDeclaration* classDecl = dynamic_cast(klass->declaration(m_topContext.data())); + ClassDeclaration* classDecl = dynamic_cast(klass->declaration(topContext().data())); if (classDecl) { // write class modifier switch (classDecl->classModifier()) { @@ -76,15 +76,15 @@ modifyHtml() += QStringLiteral("class "); } // write class identifier - eventuallyMakeTypeLinks(m_declaration->abstractType()); + eventuallyMakeTypeLinks(declaration()->abstractType()); // write inheritance if (classDecl->baseClassesSize() > 0) { AbstractType::Ptr extends; QList implements; FOREACH_FUNCTION(const BaseClassInstance& base, classDecl->baseClasses) { StructureType::Ptr stype = base.baseClass.type(); if (stype) { - ClassDeclaration *classDecl = dynamic_cast(stype->declaration(m_topContext.data())); + ClassDeclaration *classDecl = dynamic_cast(stype->declaration(topContext().data())); if (classDecl) { if (classDecl->classType() == ClassDeclarationData::Interface) { implements.append(base.baseClass.abstractType()); @@ -119,7 +119,7 @@ void DeclarationNavigationContext::htmlAdditionalNavigation() { - if (auto member = dynamic_cast(m_declaration.data())) { + if (auto member = dynamic_cast(declaration().data())) { Declaration *dec = member->aliasedDeclaration().data(); if (dec && dec->context() && dec->context()->owner()) { modifyHtml() += i18n("Use of %1 from %2
") @@ -132,7 +132,7 @@ NavigationAction(DeclarationPointer(dec->context()->owner()), KDevelop::NavigationAction::NavigateDeclaration))); } - } else if (auto member = dynamic_cast(m_declaration.data())) { + } else if (auto member = dynamic_cast(declaration().data())) { Declaration *dec = member->aliasedDeclaration().data(); if (dec && dec->context() && dec->context()->owner()) { modifyHtml() += i18n("Use of %1 from %2
") diff --git a/duchain/navigation/magicconstantnavigationcontext.h b/duchain/navigation/magicconstantnavigationcontext.h --- a/duchain/navigation/magicconstantnavigationcontext.h +++ b/duchain/navigation/magicconstantnavigationcontext.h @@ -29,8 +29,8 @@ MagicConstantNavigationContext(KDevelop::TopDUContextPointer topContext, const KTextEditor::Cursor& position, const QString& constant); - virtual QString name() const; - virtual QString html(bool shorten = false); + QString name() const override; + QString html(bool shorten = false) override; private: KDevelop::CursorInRevision m_position; QString m_constant; diff --git a/duchain/navigation/magicconstantnavigationcontext.cpp b/duchain/navigation/magicconstantnavigationcontext.cpp --- a/duchain/navigation/magicconstantnavigationcontext.cpp +++ b/duchain/navigation/magicconstantnavigationcontext.cpp @@ -23,15 +23,16 @@ #include #include #include +#include using namespace KDevelop; namespace Php { MagicConstantNavigationContext::MagicConstantNavigationContext(TopDUContextPointer topContext, const KTextEditor::Cursor& position, const QString& constant) - : AbstractNavigationContext(topContext, 0), m_position(position.line(), position.column()), m_constant(constant) + : AbstractNavigationContext(topContext, nullptr), m_position(position.line(), position.column()), m_constant(constant) { } @@ -47,7 +48,7 @@ ctx = ctx->parentContext(); } if ( !ctx || ctx->type() != type ) { - return 0; + return nullptr; } else { return ctx; } @@ -64,18 +65,18 @@ QString value; ///TODO: php 5.3: __DIR__, __NAMESPACE__ if ( m_constant == QLatin1String("__FILE__") ) { - value = m_topContext->url().str().toHtmlEscaped(); + value = topContext()->url().str().toHtmlEscaped(); } else if ( m_constant == QLatin1String("__LINE__") ) { value.setNum(m_position.line + 1); } else if ( m_constant == QLatin1String("__CLASS__") ) { - if ( DUContext* ctx = findContext(m_topContext, m_position, DUContext::Class) ) { + if ( DUContext* ctx = findContext(topContext(), m_position, DUContext::Class) ) { value = codeHighlight(ctx->localScopeIdentifier().toString().toHtmlEscaped()); } else { value = commentHighlight(i18n("empty (not inside a class)")); } } else if ( m_constant == QLatin1String("__METHOD__") ) { CursorInRevision pos = m_position; - while ( DUContext* ctx = findContext(m_topContext, pos, DUContext::Other) ) { + while ( DUContext* ctx = findContext(topContext(), pos, DUContext::Other) ) { if ( !ctx->parentContext() ) { break; } @@ -94,16 +95,16 @@ } } else if ( m_constant == QLatin1String("__FUNCTION__") ) { CursorInRevision pos = m_position; - if ( DUContext* ctx = findContext(m_topContext, pos, DUContext::Other) ) { + if ( DUContext* ctx = findContext(topContext(), pos, DUContext::Other) ) { if ( ctx->owner() && ctx->owner()->type() ) { value = codeHighlight(ctx->localScopeIdentifier().toString().toHtmlEscaped()); } } if ( value.isEmpty() ) { value = commentHighlight(i18n("empty (not inside a function)")); } } else if ( m_constant == QLatin1String("__NAMESPACE__") ) { - if ( DUContext* ctx = findContext(m_topContext, m_position, DUContext::Namespace) ) { + if ( DUContext* ctx = findContext(topContext(), m_position, DUContext::Namespace) ) { if ( ctx->owner() && ctx->owner()->kind() == Declaration::Namespace ) { value = codeHighlight(ctx->localScopeIdentifier().toString().toHtmlEscaped()); } diff --git a/duchain/navigation/navigationwidget.cpp b/duchain/navigation/navigationwidget.cpp --- a/duchain/navigation/navigationwidget.cpp +++ b/duchain/navigation/navigationwidget.cpp @@ -29,47 +29,43 @@ const QString& htmlPrefix, const QString& htmlSuffix, KDevelop::AbstractNavigationWidget::DisplayHints hints) : AbstractNavigationWidget() - , m_declaration(declaration) { - m_topContext = topContext; setDisplayHints(hints); initBrowser(400); //The first context is registered so it is kept alive by the shared-pointer mechanism - m_startContext = NavigationContextPointer(new DeclarationNavigationContext(declaration, m_topContext)); - m_startContext->setPrefixSuffix(htmlPrefix, htmlSuffix); - setContext(m_startContext); + auto context = NavigationContextPointer(new DeclarationNavigationContext(declaration, topContext)); + context->setPrefixSuffix(htmlPrefix, htmlSuffix); + setContext(context); } NavigationWidget::NavigationWidget(const IncludeItem& includeItem, KDevelop::TopDUContextPointer topContext, const QString& htmlPrefix, const QString& htmlSuffix, KDevelop::AbstractNavigationWidget::DisplayHints hints) : AbstractNavigationWidget() { - m_topContext = topContext; setDisplayHints(hints); initBrowser(200); //The first context is registered so it is kept alive by the shared-pointer mechanism - m_startContext = NavigationContextPointer(new IncludeNavigationContext(includeItem, m_topContext)); - m_startContext->setPrefixSuffix( htmlPrefix, htmlSuffix ); - setContext( m_startContext ); + auto context = NavigationContextPointer(new IncludeNavigationContext(includeItem, topContext)); + context->setPrefixSuffix(htmlPrefix, htmlSuffix); + setContext(context); } NavigationWidget::NavigationWidget(TopDUContextPointer topContext, KTextEditor::Cursor position, const QString& constant, KDevelop::AbstractNavigationWidget::DisplayHints hints) : AbstractNavigationWidget() { - m_topContext = topContext; setDisplayHints(hints); initBrowser(200); //The first context is registered so it is kept alive by the shared-pointer mechanism - m_startContext = NavigationContextPointer(new MagicConstantNavigationContext(topContext, position, constant)); - setContext( m_startContext ); + auto context = NavigationContextPointer(new MagicConstantNavigationContext(topContext, position, constant)); + setContext(context); } QString NavigationWidget::shortDescription(KDevelop::Declaration* declaration) diff --git a/duchain/phpducontext.h b/duchain/phpducontext.h --- a/duchain/phpducontext.h +++ b/duchain/phpducontext.h @@ -59,7 +59,7 @@ static_cast(this)->d_func_dynamic()->setClassId(this); } - virtual QWidget* createNavigationWidget(KDevelop::Declaration* decl, KDevelop::TopDUContext* topContext, + QWidget* createNavigationWidget(KDevelop::Declaration* decl, KDevelop::TopDUContext* topContext, const QString& htmlPrefix, const QString& htmlSuffix, KDevelop::AbstractNavigationWidget::DisplayHints hints) const override; diff --git a/duchain/phpducontext.cpp b/duchain/phpducontext.cpp --- a/duchain/phpducontext.cpp +++ b/duchain/phpducontext.cpp @@ -42,8 +42,8 @@ QWidget* PhpDUContext::createNavigationWidget(Declaration* decl, TopDUContext* topContext, const QString& htmlPrefix, const QString& htmlSuffix, KDevelop::AbstractNavigationWidget::DisplayHints hints) const { - if (decl == 0) { - return 0; + if (decl == nullptr) { + return nullptr; } else if ( decl->kind() == Declaration::Import ) { QUrl u( decl->identifier().toString() ); IncludeItem i; @@ -63,12 +63,12 @@ QWidget* PhpDUContext::createNavigationWidget(Declaration* decl, TopDUContext* topContext, const QString& htmlPrefix, const QString& htmlSuffix, KDevelop::AbstractNavigationWidget::DisplayHints hints) const { - if (decl == 0) { + if (decl == nullptr) { if (owner()) return new NavigationWidget(DeclarationPointer(owner()), TopDUContextPointer(topContext ? topContext : this->topContext()), htmlPrefix, htmlSuffix, hints); else - return 0; + return nullptr; } else { return new NavigationWidget(DeclarationPointer(decl), TopDUContextPointer(topContext ? topContext : this->topContext()), htmlPrefix, htmlSuffix, hints); diff --git a/duchain/tests/benchmarks.cpp b/duchain/tests/benchmarks.cpp --- a/duchain/tests/benchmarks.cpp +++ b/duchain/tests/benchmarks.cpp @@ -54,7 +54,7 @@ QBENCHMARK { ParseSession session = ParseSession(); session.setContents(file->readAll()); - StartAst* ast = 0; + StartAst* ast = nullptr; session.parse(&ast); } delete file; @@ -66,7 +66,7 @@ ParseSession session; session.setContents(file->readAll()); delete file; - StartAst* ast = 0; + StartAst* ast = nullptr; session.parse(&ast); EditorIntegrator editor(&session); QBENCHMARK { @@ -85,7 +85,7 @@ session.setContents(file->readAll()); delete file; - StartAst* ast = 0; + StartAst* ast = nullptr; session.parse(&ast); EditorIntegrator editor(&session); DeclarationBuilder builder(&editor); diff --git a/duchain/tests/duchain.h b/duchain/tests/duchain.h --- a/duchain/tests/duchain.h +++ b/duchain/tests/duchain.h @@ -37,6 +37,7 @@ void declareClass(); void classMemberVar(); void declareTypehintFunction(); + void declareVariadicFunction(); void declareTypehintArrayFunction(); void declareTypehintCallableFunction(); void returnTypeClass(); @@ -152,6 +153,7 @@ void useThisAsArray(); void wrongUseOfThisAsArray(); void staticFunctionClassPhp54(); + void functionArgumentUnpacking(); }; } diff --git a/duchain/tests/duchain.cpp b/duchain/tests/duchain.cpp --- a/duchain/tests/duchain.cpp +++ b/duchain/tests/duchain.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -607,6 +608,28 @@ QCOMPARE(StructureType::Ptr::dynamicCast(fType->returnType())->qualifiedIdentifier(), QualifiedIdentifier("a")); } +void TestDUChain::declareVariadicFunction() +{ + // 0 1 2 3 4 5 6 7 + // 01234567890123456789012345678901234567890123456789012345678901234567890123456789 + QByteArray method("localDeclarations().first()->type(); + QVERIFY(fun); + QCOMPARE(fun->arguments().count(), 1); + QVERIFY(IntegralType::Ptr::dynamicCast(fun->arguments().first())); + QVERIFY(IntegralType::Ptr::dynamicCast(fun->arguments().first())->dataType() == IntegralType::TypeArray); + + IntegralType::Ptr type = top->childContexts().first()->localDeclarations().first()->type(); + QVERIFY(type); + QVERIFY(type->dataType() == IntegralType::TypeArray); +} + void TestDUChain::declareTypehintArrayFunction() { // 0 1 2 3 4 5 6 7 @@ -1479,15 +1502,15 @@ void TestDUChain::largeNumberOfDeclarations() { - TopDUContext* top = new TopDUContext(IndexedString(QUrl(QStringLiteral("file:///internal/testurl"))), RangeInRevision(0, 0, 6000, 0), 0); + TopDUContext* top = new TopDUContext(IndexedString(QUrl(QStringLiteral("file:///internal/testurl"))), RangeInRevision(0, 0, 6000, 0), nullptr); DUChain::self()->addDocumentChain(top); DUChainReleaser releaseTop(top); DUChainWriteLocker lock(DUChain::lock()); for (int i = 0; i < 6000; ++i) { RangeInRevision newRange(i, 0, i, 1); Declaration* dec = new Declaration(newRange, top); dec->setIdentifier(Identifier(QStringLiteral("dec%0").arg(i))); - dec->setAbstractType(AbstractType::Ptr(0)); + dec->setAbstractType(AbstractType::Ptr(nullptr)); } } @@ -1645,10 +1668,10 @@ { DUChainWriteLocker lock(DUChain::lock()); - TopDUContext* top1 = new TopDUContext(IndexedString(QUrl(QStringLiteral("file:///internal/testfile1"))), RangeInRevision(0, 0, 0, 10), 0); + TopDUContext* top1 = new TopDUContext(IndexedString(QUrl(QStringLiteral("file:///internal/testfile1"))), RangeInRevision(0, 0, 0, 10), nullptr); DUChainReleaser releaseTop1(top1); DUChain::self()->addDocumentChain(top1); - TopDUContext* top2 = new TopDUContext(IndexedString(QUrl(QStringLiteral("file:///internal/testfile2"))), RangeInRevision(0, 0, 0, 10), 0); + TopDUContext* top2 = new TopDUContext(IndexedString(QUrl(QStringLiteral("file:///internal/testfile2"))), RangeInRevision(0, 0, 0, 10), nullptr); DUChainReleaser releaseTop2(top2); DUChain::self()->addDocumentChain(top2); @@ -3021,3 +3044,22 @@ ClassDeclaration* classDec = dynamic_cast(dec); QCOMPARE(classDec->uses().count(),1); } + +void TestDUChain::functionArgumentUnpacking() +{ + // 0 1 2 3 4 5 6 7 + // 01234567890123456789012345678901234567890123456789012345678901234567890123456789 + QByteArray method("problems().isEmpty()); + QCOMPARE(top->localDeclarations().count(),3); +} diff --git a/duchain/tests/duchaintestbase.h b/duchain/tests/duchaintestbase.h --- a/duchain/tests/duchaintestbase.h +++ b/duchain/tests/duchaintestbase.h @@ -71,7 +71,7 @@ protected: KDevelop::TopDUContext* parse(const QByteArray& unit, DUChainTestBase::DumpAreas dump = DumpAreas(DumpAll), - QUrl url = {}, KDevelop::TopDUContext* update = 0); + QUrl url = {}, KDevelop::TopDUContext* update = nullptr); KDevelop::TopDUContext* parseAdditionalFile(const KDevelop::IndexedString& fileName, const QByteArray& contents); diff --git a/duchain/tests/duchaintestbase.cpp b/duchain/tests/duchaintestbase.cpp --- a/duchain/tests/duchaintestbase.cpp +++ b/duchain/tests/duchaintestbase.cpp @@ -119,7 +119,7 @@ { ParseSession session; session.setContents(contents); - StartAst* ast = 0; + StartAst* ast = nullptr; if (!session.parse(&ast)) qFatal("can't parse"); EditorIntegrator editor(&session); @@ -150,10 +150,10 @@ ParseSession session; session.setContents(unit); - StartAst* ast = 0; + StartAst* ast = nullptr; if (!session.parse(&ast)) { qDebug() << "Parse failed"; - return 0; + return nullptr; } if (dump & DumpAST) { diff --git a/duchain/tests/expressionparser.h b/duchain/tests/expressionparser.h --- a/duchain/tests/expressionparser.h +++ b/duchain/tests/expressionparser.h @@ -62,6 +62,9 @@ void classMemberOnInstantiation(); void classNameConstant_data(); void classNameConstant(); + void invalidVariadicFunction_data(); + void invalidVariadicFunction(); + void invalidArgumentUnpacking(); }; } diff --git a/duchain/tests/expressionparser.cpp b/duchain/tests/expressionparser.cpp --- a/duchain/tests/expressionparser.cpp +++ b/duchain/tests/expressionparser.cpp @@ -661,5 +661,38 @@ QCOMPARE(IntegralType::Ptr::staticCast(res.type())->dataType(), static_cast(IntegralType::TypeString)); } +void TestExpressionParser::invalidVariadicFunction_data() +{ + QTest::addColumn("code"); + + QTest::newRow("defaultValue") << "problems().isEmpty()); +} + +void TestExpressionParser::invalidArgumentUnpacking() +{ + // 0 1 2 3 4 5 6 7 + // 01234567890123456789012345678901234567890123456789012345678901234567890123456789 + QByteArray method("problems().isEmpty()); +} + } diff --git a/duchain/types/integraltypeextended.h b/duchain/types/integraltypeextended.h --- a/duchain/types/integraltypeextended.h +++ b/duchain/types/integraltypeextended.h @@ -50,13 +50,13 @@ /// Constructor using raw data. \param data internal data. IntegralTypeExtended(IntegralTypeExtendedData& data); - virtual QString toString() const; + QString toString() const override; - virtual KDevelop::AbstractType* clone() const; + KDevelop::AbstractType* clone() const override; - virtual bool equals(const KDevelop::AbstractType* rhs) const; + bool equals(const KDevelop::AbstractType* rhs) const override; - virtual uint hash() const; + uint hash() const override; enum { ///TODO: is that value OK? @@ -78,7 +78,7 @@ template<> inline Php::IntegralTypeExtended* fastCast(AbstractType* from) { if ( !from || from->whichType() != AbstractType::TypeIntegral ) { - return 0; + return nullptr; } else { return dynamic_cast(from); } diff --git a/duchain/types/structuretype.h b/duchain/types/structuretype.h --- a/duchain/types/structuretype.h +++ b/duchain/types/structuretype.h @@ -23,6 +23,8 @@ #include #include +#include + #include "phpduchainexport.h" namespace Php @@ -65,11 +67,11 @@ void setPrettyName(const KDevelop::IndexedString& name); KDevelop::IndexedString prettyName() const; - virtual QString toString() const; + QString toString() const override; - virtual KDevelop::AbstractType* clone() const; + KDevelop::AbstractType* clone() const override; - virtual uint hash() const; + uint hash() const override; enum { ///TODO: is that value OK? @@ -91,7 +93,7 @@ template<> inline Php::StructureType* fastCast(AbstractType* from) { if ( !from || from->whichType() != AbstractType::TypeStructure ) { - return 0; + return nullptr; } else { return dynamic_cast(from); } diff --git a/kdevphpsupport.categories b/kdevphpsupport.categories new file mode 100644 --- /dev/null +++ b/kdevphpsupport.categories @@ -0,0 +1,10 @@ +# KDebugSettings data file +# Format: +# lognamedescription + +kdevelop.languages.php KDevelop plugin: PHP language support +kdevelop.languages.php.completion KDevelop plugin: PHP language support - codecompletion +kdevelop.languages.php.docs KDevelop plugin: PHP language support - documentation +kdevelop.languages.php.duchain KDevelop plugin: PHP language support - duchain +kdevelop.languages.php.parser KDevelop plugin: PHP language support - parser +kdevelop.languages.php.testprovider KDevelop plugin: PHP language support - testprovider diff --git a/kdevphpsupport.json b/kdevphpsupport.json --- a/kdevphpsupport.json +++ b/kdevphpsupport.json @@ -7,11 +7,11 @@ "Description[cs]": "Podpora jazyka PHP", "Description[de]": "Sprachunterstützung für PHP", "Description[es]": "Implementación del lenguaje PHP", - "Description[et]": "PHP keele toetus", "Description[fi]": "PHP-kielituki", "Description[fr]": "Prise en charge du langage PHP", - "Description[gl]": "Compatibilidade coa linguaxe PHP.", + "Description[gl]": "Soporte da linguaxe PHP", "Description[it]": "Supporto al linguaggio PHP", + "Description[ko]": "PHP 언어 지원", "Description[nl]": "Ondersteuning van de PHP-taal", "Description[pl]": "Obsługa języka PHP", "Description[pt]": "Suporte da Linguagem PHP", @@ -31,11 +31,11 @@ "Name[cs]": "Podpora jazyka PHP", "Name[de]": "Sprachunterstützung für PHP", "Name[es]": "Implementación del lenguaje PHP", - "Name[et]": "PHP keele toetus", "Name[fi]": "PHP-kielituki", "Name[fr]": "Prise en charge du langage PHP", - "Name[gl]": "Compatibilidade coa linguaxe PHP", + "Name[gl]": "Soporte da linguaxe PHP", "Name[it]": "Supporto al linguaggio PHP", + "Name[ko]": "PHP 언어 지원", "Name[nl]": "Ondersteuning van de PHP-taal", "Name[pl]": "Obsługa języka PHP", "Name[pt]": "Suporte da Linguagem PHP", @@ -46,7 +46,7 @@ "Name[sv]": "PHP-språkstöd", "Name[uk]": "Підтримка мови PHP", "Name[x-test]": "xxPHP Language Supportxx", - "Name[zh_CN]": "Php 语言支持", + "Name[zh_CN]": "PHP 语言支持", "ServiceTypes": [ "KDevelop/Plugin" ] diff --git a/parser/CMakeLists.txt b/parser/CMakeLists.txt --- a/parser/CMakeLists.txt +++ b/parser/CMakeLists.txt @@ -3,13 +3,17 @@ set(parser_STAT_SRCS phplexer.cpp parsesession.cpp - parserdebug.cpp ) kdevpgqt_generate(parser_SRCS php NAMESPACE Php DEBUG_VISITOR TOKEN_TEXT "${php_SOURCE_DIR}/parser/php.g" "${php_SOURCE_DIR}/parser/phplexer.h" ) +ecm_qt_declare_logging_category(parser_SRCS + HEADER parserdebug.h + IDENTIFIER PARSER + CATEGORY_NAME "kdevelop.languages.php.parser" +) add_library(kdevphpparser SHARED ${parser_SRCS} ${parser_STAT_SRCS}) diff --git a/parser/parserdebug.h b/parser/parserdebug.h deleted file mode 100644 --- a/parser/parserdebug.h +++ /dev/null @@ -1,26 +0,0 @@ -/* This file is part of KDevelop - - Copyright 2014 Milian Wolff - - 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 PARSERDEBUG_H -#define PARSERDEBUG_H - -#include -Q_DECLARE_LOGGING_CATEGORY(PARSER) - -#endif /* PARSERDEBUG_H */ diff --git a/parser/parserdebug.cpp b/parser/parserdebug.cpp deleted file mode 100644 --- a/parser/parserdebug.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* This file is part of KDevelop - - Copyright 2014 Milian Wolff - - 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 "parserdebug.h" - -Q_LOGGING_CATEGORY(PARSER, "kdevelop.languages.php.parser") diff --git a/parser/parsesession.h b/parser/parsesession.h --- a/parser/parsesession.h +++ b/parser/parsesession.h @@ -43,7 +43,7 @@ void setContents(const QString& contents); void setCurrentDocument(const KDevelop::IndexedString& filename); KDevelop::IndexedString currentDocument() const; - bool readFile(const QString& filename, const char* charset = 0); + bool readFile(const QString& filename, const char* charset = nullptr); void setDebug(bool); TokenStream* tokenStream() const; QString contents() const; diff --git a/parser/parsesession.cpp b/parser/parsesession.cpp --- a/parser/parsesession.cpp +++ b/parser/parsesession.cpp @@ -32,6 +32,7 @@ #include #include #include +#include namespace Php { @@ -134,7 +135,7 @@ qCDebug(PARSER) << "Successfully parsed"; *ast = phpAst; } else { - *ast = 0; + *ast = nullptr; parser->expectedSymbol(AstNode::StartKind, QStringLiteral("start")); qCDebug(PARSER) << "Couldn't parse content"; } diff --git a/parser/php.g b/parser/php.g --- a/parser/php.g +++ b/parser/php.g @@ -266,7 +266,7 @@ INC ("++"), DEC ("--"), BANG ("!"), QUESTION ("?"), COLON (":"), BIT_AND ("&"), BIT_OR("|"), BIT_XOR ("^"), SL ("<<"), SR (">>"), MUL("*"), DIV("/"), MOD ("%"), - TILDE ("~"), DOLLAR ("$"), EXP ("**"), + TILDE ("~"), DOLLAR ("$"), EXP ("**"), ELLIPSIS ("..."), LOGICAL_OR ("logical or"), LOGICAL_AND ("logical and"), LOGICAL_XOR ("logical xor") ;; -- literals and identifiers: @@ -599,7 +599,7 @@ #parameters=functionCallParameterListElement @ COMMA | 0 -> functionCallParameterList ;; - (BIT_AND variable=variable) | expr=expr + (BIT_AND variable=variable) | (isVariadic=ELLIPSIS variable=variable) | expr=expr -> functionCallParameterListElement ;; #element=assignmentListElement @COMMA @@ -880,7 +880,7 @@ -> parameterList ;; (parameterType=namespacedIdentifier | arrayType=ARRAY | callableType=CALLABLE | 0) (isRef=BIT_AND | 0) - variable=variableIdentifier (ASSIGN defaultValue=staticScalar | 0) + (isVariadic=ELLIPSIS | 0) variable=variableIdentifier (ASSIGN defaultValue=staticScalar | 0) -> parameter ;; value=commonScalar @@ -1020,7 +1020,7 @@ [: #include -#include +#include namespace Php { diff --git a/parser/phplexer.cpp b/parser/phplexer.cpp --- a/parser/phplexer.cpp +++ b/parser/phplexer.cpp @@ -545,6 +545,9 @@ if ((it + 1)->unicode() == '=') { m_curpos++; token = Parser::Token_CONCAT_ASSIGN; + } else if ((it + 1)->unicode() == '.' && (it + 2)->unicode() == '.') { + m_curpos = m_curpos + 2; + token = Parser::Token_ELLIPSIS; } else { token = Parser::Token_CONCAT; } diff --git a/parser/test/lexertest.h b/parser/test/lexertest.h --- a/parser/test/lexertest.h +++ b/parser/test/lexertest.h @@ -68,6 +68,7 @@ void testTypeHintsOnFunction(); void testExponentiation(); void testExceptionFinally(); + void testEllipsis(); protected: TokenStream* tokenize(const QString& unit, bool debug = false, int initialState = Lexer::HtmlState); diff --git a/parser/test/lexertest.cpp b/parser/test/lexertest.cpp --- a/parser/test/lexertest.cpp +++ b/parser/test/lexertest.cpp @@ -510,6 +510,24 @@ COMPARE_TOKEN(ts, 18, Parser::Token_RBRACE, 1, 26, 1, 26); } +void LexerTest::testEllipsis() +{ + QScopedPointer ts(tokenize(QStringLiteral("size(), 11); + + COMPARE_TOKEN(ts, 0, Parser::Token_OPEN_TAG, 0, 0, 0, 5); + COMPARE_TOKEN(ts, 1, Parser::Token_FUNCTION, 1, 0, 1, 7); + COMPARE_TOKEN(ts, 2, Parser::Token_WHITESPACE, 1, 8, 1, 8); + COMPARE_TOKEN(ts, 3, Parser::Token_STRING, 1, 9, 1, 11); + COMPARE_TOKEN(ts, 4, Parser::Token_LPAREN, 1, 12, 1, 12); + COMPARE_TOKEN(ts, 5, Parser::Token_ELLIPSIS, 1, 13, 1, 15); + COMPARE_TOKEN(ts, 6, Parser::Token_VARIABLE, 1, 16, 1, 20); + COMPARE_TOKEN(ts, 7, Parser::Token_RPAREN, 1, 21, 1, 21); + COMPARE_TOKEN(ts, 8, Parser::Token_WHITESPACE, 1, 22, 1, 22); + COMPARE_TOKEN(ts, 9, Parser::Token_LBRACE, 1, 23, 1, 23); + COMPARE_TOKEN(ts, 10, Parser::Token_RBRACE, 1, 24, 1, 24); +} + TokenStream* LexerTest::tokenize(const QString& unit, bool debug, int initialState) { TokenStream* tokenStream = new TokenStream; diff --git a/phpdebug.h b/phpdebug.h deleted file mode 100644 --- a/phpdebug.h +++ /dev/null @@ -1,26 +0,0 @@ -/* This file is part of KDevelop - - Copyright 2014 Milian Wolff - - 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 PHPDEBUG_H -#define PHPDEBUG_H - -#include -Q_DECLARE_LOGGING_CATEGORY(PHP) - -#endif /* PHPDEBUG_H */ diff --git a/phpdebug.cpp b/phpdebug.cpp deleted file mode 100644 --- a/phpdebug.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* This file is part of KDevelop - - Copyright 2014 Milian Wolff - - 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 "phpdebug.h" - -Q_LOGGING_CATEGORY(PHP, "kdevelop.languages.php") diff --git a/phphighlighting.h b/phphighlighting.h --- a/phphighlighting.h +++ b/phphighlighting.h @@ -29,7 +29,7 @@ { public: Highlighting(QObject* parent); - virtual KDevelop::CodeHighlightingInstance* createInstance() const; + KDevelop::CodeHighlightingInstance* createInstance() const override; }; } diff --git a/phphighlighting.cpp b/phphighlighting.cpp --- a/phphighlighting.cpp +++ b/phphighlighting.cpp @@ -30,8 +30,8 @@ class HighlightingInstance : public CodeHighlightingInstance { public: HighlightingInstance(const CodeHighlighting* highlighting); - virtual Types typeForDeclaration(KDevelop::Declaration* decl, KDevelop::DUContext* context) const; - virtual bool useRainbowColor( Declaration* dec ) const; + Types typeForDeclaration(KDevelop::Declaration* decl, KDevelop::DUContext* context) const override; + bool useRainbowColor( Declaration* dec ) const override; }; HighlightingInstance::HighlightingInstance(const CodeHighlighting* highlighting) diff --git a/phplanguagesupport.h b/phplanguagesupport.h --- a/phplanguagesupport.h +++ b/phplanguagesupport.h @@ -65,7 +65,7 @@ public: explicit LanguageSupport(QObject *parent, const QVariantList& args = QVariantList()); - virtual ~LanguageSupport(); + ~LanguageSupport() override; /*Name Of the Language*/ QString name() const override; /*Parsejob used by background parser to parse given Url*/ diff --git a/phplanguagesupport.cpp b/phplanguagesupport.cpp --- a/phplanguagesupport.cpp +++ b/phplanguagesupport.cpp @@ -169,7 +169,7 @@ if (TopDUContext* top = standardContext(url)) { return new NavigationWidget(TopDUContextPointer(top), position, word.first); } else { - return 0; + return nullptr; } } return ILanguageSupport::specialLanguageObjectNavigationWidget(url, position); diff --git a/phpparsejob.h b/phpparsejob.h --- a/phpparsejob.h +++ b/phpparsejob.h @@ -46,13 +46,13 @@ }; explicit ParseJob(const KDevelop::IndexedString& url, KDevelop::ILanguageSupport* LanguageSupport); - virtual ~ParseJob(); + ~ParseJob() override; void setParentJob(ParseJob *job); protected: LanguageSupport* php() const; - virtual void run(ThreadWeaver::JobPointer self, ThreadWeaver::Thread *thread); + void run(ThreadWeaver::JobPointer self, ThreadWeaver::Thread *thread) override; private: ParseJob *m_parentJob; ///< parent job if this one is an include diff --git a/phpparsejob.cpp b/phpparsejob.cpp --- a/phpparsejob.cpp +++ b/phpparsejob.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include "editorintegrator.h" #include "parsesession.h" @@ -54,7 +55,7 @@ ParseJob::ParseJob(const IndexedString& url, ILanguageSupport* languageSupport) : KDevelop::ParseJob(url, languageSupport) -, m_parentJob(0) +, m_parentJob(nullptr) { } @@ -101,7 +102,7 @@ session.setCurrentDocument(document()); // 2) parse - StartAst* ast = 0; + StartAst* ast = nullptr; bool matched = session.parse(&ast); if (abortRequested() || ICore::self()->shuttingDown()) { diff --git a/testprovider/CMakeLists.txt b/testprovider/CMakeLists.txt --- a/testprovider/CMakeLists.txt +++ b/testprovider/CMakeLists.txt @@ -5,7 +5,11 @@ phpunittestsuite.cpp phpunitrunjob.cpp testdoxdelegate.cpp - testproviderdebug.cpp +) +ecm_qt_declare_logging_category(kdevphpunitprovider_PLUGIN_SRCS + HEADER testproviderdebug.h + IDENTIFIER TESTPROVIDER + CATEGORY_NAME "kdevelop.languages.php.testprovider" ) add_library(kdevphpunitprovider MODULE ${kdevphpunitprovider_PLUGIN_SRCS}) diff --git a/testprovider/phpunitprovider.h b/testprovider/phpunitprovider.h --- a/testprovider/phpunitprovider.h +++ b/testprovider/phpunitprovider.h @@ -26,6 +26,8 @@ #include #include +#include + #include class QVariant; diff --git a/testprovider/phpunitrunjob.h b/testprovider/phpunitrunjob.h --- a/testprovider/phpunitrunjob.h +++ b/testprovider/phpunitrunjob.h @@ -35,11 +35,11 @@ { Q_OBJECT public: - PhpUnitRunJob(PhpUnitTestSuite* suite, const QStringList& cases, KDevelop::OutputJob::OutputJobVerbosity verbosity, QObject* parent = 0); - virtual void start(); + PhpUnitRunJob(PhpUnitTestSuite* suite, const QStringList& cases, KDevelop::OutputJob::OutputJobVerbosity verbosity, QObject* parent = nullptr); + void start() override; protected: - virtual bool doKill(); + bool doKill() override; private slots: void processFinished(KJob* job); diff --git a/testprovider/phpunitrunjob.cpp b/testprovider/phpunitrunjob.cpp --- a/testprovider/phpunitrunjob.cpp +++ b/testprovider/phpunitrunjob.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -41,11 +42,11 @@ PhpUnitRunJob::PhpUnitRunJob(PhpUnitTestSuite* suite, const QStringList& cases, KDevelop::OutputJob::OutputJobVerbosity verbosity, QObject* parent) : KJob(parent) -, m_process(0) +, m_process(nullptr) , m_suite(suite) , m_cases(cases) -, m_job(0) -, m_outputJob(0) +, m_job(nullptr) +, m_outputJob(nullptr) , m_verbosity(verbosity) { } @@ -58,7 +59,7 @@ qCDebug(TESTPROVIDER) << "got mode and type:" << type << type->id() << mode << mode->id(); Q_ASSERT(type && mode); - KDevelop::ILauncher* launcher = 0; + KDevelop::ILauncher* launcher = nullptr; foreach (KDevelop::ILauncher *l, type->launchers()) { //qCDebug(TESTPROVIDER) << "available launcher" << l << l->id() << l->supportedModes(); @@ -69,7 +70,7 @@ } Q_ASSERT(launcher); - KDevelop::ILaunchConfiguration* ilaunch = 0; + KDevelop::ILaunchConfiguration* ilaunch = nullptr; QList launchConfigurations = KDevelop::ICore::self()->runController()->launchConfigurations(); foreach (KDevelop::ILaunchConfiguration *l, launchConfigurations) { if (l->type() == type && l->config().readEntry("ConfiguredByPhpUnit", false)) { @@ -80,7 +81,7 @@ if (!ilaunch) { ilaunch = KDevelop::ICore::self()->runController()->createLaunchConfiguration( type, qMakePair( mode->id(), launcher->id() ), - 0, //TODO add project + nullptr, //TODO add project i18n("PHPUnit") ); ilaunch->config().writeEntry("ConfiguredByPhpUnit", true); //qCDebug(TESTPROVIDER) << "created config, launching"; diff --git a/testprovider/phpunittestsuite.h b/testprovider/phpunittestsuite.h --- a/testprovider/phpunittestsuite.h +++ b/testprovider/phpunittestsuite.h @@ -38,7 +38,7 @@ public: PhpUnitTestSuite(const QString& name, const QUrl& url, const KDevelop::IndexedDeclaration& suiteDeclaration, const QStringList& cases, const QHash< QString, KDevelop::IndexedDeclaration >& caseDeclarations, KDevelop::IProject* project); - virtual ~PhpUnitTestSuite(); + ~PhpUnitTestSuite() override; KJob* launchCase(const QString& testCase, TestJobVerbosity verbosity) override; KJob* launchCases(const QStringList& testCases, TestJobVerbosity verbosity) override; diff --git a/testprovider/phpunittestsuite.cpp b/testprovider/phpunittestsuite.cpp --- a/testprovider/phpunittestsuite.cpp +++ b/testprovider/phpunittestsuite.cpp @@ -83,7 +83,7 @@ IndexedDeclaration PhpUnitTestSuite::caseDeclaration(const QString& testCase) const { - return m_caseDeclarations.value(testCase, IndexedDeclaration(0)); + return m_caseDeclarations.value(testCase, IndexedDeclaration(nullptr)); } diff --git a/testprovider/testdoxdelegate.h b/testprovider/testdoxdelegate.h --- a/testprovider/testdoxdelegate.h +++ b/testprovider/testdoxdelegate.h @@ -28,9 +28,9 @@ { public: - explicit TestDoxDelegate(QObject* parent = 0); - virtual ~TestDoxDelegate(); - virtual void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const; + explicit TestDoxDelegate(QObject* parent = nullptr); + ~TestDoxDelegate() override; + void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override; private: void highlight(QStyleOptionViewItem& option, const KStatefulBrush& brush, bool bold = true) const; diff --git a/testprovider/testproviderdebug.h b/testprovider/testproviderdebug.h deleted file mode 100644 --- a/testprovider/testproviderdebug.h +++ /dev/null @@ -1,26 +0,0 @@ -/* This file is part of KDevelop - - Copyright 2014 Milian Wolff - - 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 TESTPROVIDERDEBUG_H -#define TESTPROVIDERDEBUG_H - -#include -Q_DECLARE_LOGGING_CATEGORY(TESTPROVIDER) - -#endif /* TESTPROVIDERDEBUG_H */ diff --git a/testprovider/testproviderdebug.cpp b/testprovider/testproviderdebug.cpp deleted file mode 100644 --- a/testprovider/testproviderdebug.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* This file is part of KDevelop - - Copyright 2014 Milian Wolff - - 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 "testproviderdebug.h" - -Q_LOGGING_CATEGORY(TESTPROVIDER, "kdevelop.languages.php.testprovider")