File indexing completed on 2024-03-24 16:04:42

0001 /*
0002     SPDX-FileCopyrightText: 2007 Piyush verma <piyush.verma@gmail.com>
0003     SPDX-FileCopyrightText: 2009 Niko Sams <niko.sams@gmail.com>
0004     SPDX-FileCopyrightText: 2010 Milian Wolff <mail@milianw.de>
0005 
0006     SPDX-License-Identifier: GPL-2.0-or-later
0007 */
0008 
0009 #ifndef KDEVPHPLANGUAGESUPPORT_H
0010 #define KDEVPHPLANGUAGESUPPORT_H
0011 
0012 #include <interfaces/iplugin.h>
0013 #include <language/interfaces/ilanguagesupport.h>
0014 #include <QVariant>
0015 
0016 namespace KDevelop
0017 {
0018 class IDocument;
0019 class IProject;
0020 class CodeHighlighting;
0021 class ReferencedTopDUContext;
0022 class ParseJob;
0023 class IndexedString;
0024 }
0025 
0026 namespace Php
0027 {
0028 
0029 class Highlighting;
0030 class Refactoring;
0031 
0032 /**
0033  * \brief Language Support plugin for PHP
0034  *
0035  * All internal PHP declarations can be found in a central document, hitherto called the
0036  * internal function file. See \p internalFunctionsFile().
0037  *
0038  * To access the DUContext, include duchain/helper.h and use:
0039  * \code
0040  *  DUChainWriteLocker lock(DUChain::lock());
0041  *  TopDUContext* ctx = DUChain::self()->chainForDocument(internalFunctionsFile());
0042  * \endcode
0043  *
0044  * To access the destination of the internal function file without linking against the LanguageSupport,
0045  * like is done in e.g. the PHP-Docs plugin, use:
0046  * \code
0047  *  IndexedString url(KStandardDirs::locate("data", "kdevphpsupport/phpfunctions.php"));
0048  * \endcode
0049  */
0050 class LanguageSupport : public KDevelop::IPlugin, public KDevelop::ILanguageSupport
0051 {
0052     Q_OBJECT
0053     Q_INTERFACES(KDevelop::ILanguageSupport)
0054 
0055 public:
0056     explicit LanguageSupport(QObject *parent, const QVariantList& args = QVariantList());
0057     ~LanguageSupport() override;
0058     /*Name Of the Language*/
0059     QString name() const override;
0060     /*Parsejob used by background parser to parse given Url*/
0061     KDevelop::ParseJob *createParseJob(const KDevelop::IndexedString& url) override;
0062 
0063     static LanguageSupport* self();
0064     /*the code highlighter*/
0065     KDevelop::ICodeHighlighting* codeHighlighting() const override;
0066 
0067     /**
0068      * @returns the ContextMenuExtension for the Php plugin.
0069      */
0070     KDevelop::ContextMenuExtension contextMenuExtension(KDevelop::Context* context, QWidget* parent) override;
0071 
0072     QPair<QWidget*, KTextEditor::Range> specialLanguageObjectNavigationWidget(const QUrl& url, const KTextEditor::Cursor& position) override;
0073     KTextEditor::Range specialLanguageObjectRange(const QUrl& url, const KTextEditor::Cursor& position) override;
0074 
0075 private:
0076     KDevelop::CodeHighlighting* m_highlighting;
0077     Refactoring *m_refactoring;
0078 
0079     QPair<QString, KTextEditor::Range>  wordUnderCursor(const QUrl& url, const KTextEditor::Cursor& position);
0080 };
0081 
0082 }
0083 
0084 #endif
0085