File indexing completed on 2024-05-19 04:39:20

0001 /*
0002     SPDX-FileCopyrightText: 2006 Adam Treat <treat@kde.org>
0003     SPDX-FileCopyrightText: 2007 Andreas Pakulat <apaku@gmx.org>
0004     SPDX-FileCopyrightText: 2008 David Nolden <david.nolden.kdevelop@art-master.de>
0005 
0006     SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 
0009 #ifndef KDEVPLATFORM_EDITORCONTEXT_H
0010 #define KDEVPLATFORM_EDITORCONTEXT_H
0011 
0012 #include "codecontext.h"
0013 
0014 namespace KTextEditor {
0015 class View;
0016 class Cursor;
0017 }
0018 
0019 class QUrl;
0020 
0021 namespace KDevelop {
0022 class EditorContextPrivate;
0023 
0024 /**A context for the KTextEditor.*/
0025 class KDEVPLATFORMLANGUAGE_EXPORT EditorContext
0026     : public DeclarationContext
0027 {
0028 public:
0029     /**
0030      * Builds a context for a KTextEditor part.
0031      * @param view The view for the editor context.
0032      * @param position The cursor position.
0033      */
0034     EditorContext(KTextEditor::View* view, const KTextEditor::Cursor& position);
0035 
0036     /**Destructor.*/
0037     ~EditorContext() override;
0038 
0039     EditorContext(const EditorContext&) = delete;
0040     EditorContext& operator=(const EditorContext&) = delete;
0041 
0042     int type() const override;
0043 
0044     /**@return The url for the file which this context was invoked for.*/
0045     QUrl url() const;
0046     QList<QUrl> urls() const override;
0047 
0048     /**@return The cursor position.*/
0049     KTextEditor::Cursor position() const;
0050 
0051     /**@return A QString with the content of the line which this context was
0052         invoked for.*/
0053     QString currentLine() const;
0054 
0055     /**@return A QString containing the word near to the cursor when this
0056         context object was created.*/
0057     QString currentWord() const;
0058 
0059     /**
0060      * Returns the associated view.
0061      */
0062     KTextEditor::View* view() const;
0063 
0064 private:
0065     const QScopedPointer<class EditorContextPrivate> d_ptr;
0066     Q_DECLARE_PRIVATE(EditorContext)
0067 };
0068 }
0069 
0070 #endif