File indexing completed on 2024-05-05 05:51:38
0001 #pragma once 0002 /* Description : Kate CTags plugin 0003 * 0004 * SPDX-FileCopyrightText: 2008-2011 Kare Sars <kare.sars@iki.fi> 0005 * 0006 * This program is free software; you can redistribute it and/or 0007 * modify it under the terms of the GNU General Public 0008 * License as published by the Free Software Foundation; either 0009 * version 2.1 of the License, or (at your option) version 3, or any 0010 * later version accepted by the membership of KDE e.V. (or its 0011 * successor approved by the membership of KDE e.V.), which shall 0012 * act as a proxy defined in Section 6 of version 3 of the license. 0013 * 0014 * This program is distributed in the hope that it will be useful, 0015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0017 * General Public License for more details. 0018 * 0019 * You should have received a copy of the GNU General Public 0020 * License along with this program. If not, see <http://www.gnu.org/licenses/>. 0021 */ 0022 0023 #include <KTextEditor/View> 0024 0025 #include <KTextEditor/MainWindow> 0026 #include <ktexteditor/sessionconfiginterface.h> 0027 0028 #include <KXMLGUIClient> 0029 #include <QProcess> 0030 0031 #include <KActionMenu> 0032 #include <QPointer> 0033 #include <QStack> 0034 #include <QTimer> 0035 0036 #include "tags.h" 0037 0038 #include "ui_kate_ctags.h" 0039 0040 #include "gotosymbolwidget.h" 0041 0042 const static QString DEFAULT_CTAGS_CMD = QStringLiteral("ctags -R --c++-types=+px --extra=+q --excmd=pattern --exclude=Makefile --exclude=."); 0043 0044 typedef struct { 0045 QUrl url; 0046 KTextEditor::Cursor cursor; 0047 } TagJump; 0048 0049 /******************************************************************/ 0050 class KateCTagsView : public QObject, public KXMLGUIClient, public KTextEditor::SessionConfigInterface 0051 { 0052 Q_OBJECT 0053 Q_INTERFACES(KTextEditor::SessionConfigInterface) 0054 0055 public: 0056 KateCTagsView(KTextEditor::Plugin *plugin, KTextEditor::MainWindow *mainWin); 0057 ~KateCTagsView() override; 0058 0059 // reimplemented: read and write session config 0060 void readSessionConfig(const KConfigGroup &config) override; 0061 void writeSessionConfig(KConfigGroup &config) override; 0062 0063 void jumpToTag(const QString &file, const QString &pattern, const QString &word); 0064 0065 public Q_SLOTS: 0066 void gotoDefinition(); 0067 void gotoDeclaration(); 0068 void lookupTag(); 0069 void stepBack(); 0070 void editLookUp(); 0071 void aboutToShow(); 0072 void tagHitClicked(QTreeWidgetItem *); 0073 void startEditTmr(); 0074 0075 void addTagTarget(); 0076 void delTagTarget(); 0077 0078 void updateSessionDB(); 0079 void updateDone(int exitCode, QProcess::ExitStatus status); 0080 0081 protected: 0082 bool eventFilter(QObject *obj, QEvent *ev) override; 0083 0084 private Q_SLOTS: 0085 void resetCMD(); 0086 void handleEsc(QEvent *e); 0087 void showSymbols(); 0088 void showGlobalSymbols(); 0089 0090 private: 0091 bool listContains(const QString &target); 0092 0093 QString currentWord(); 0094 0095 void setNewLookupText(const QString &newText); 0096 void displayHits(const Tags::TagList &list); 0097 0098 void gotoResults(const QString &word, const Tags::TagList &list); 0099 0100 QPointer<KTextEditor::MainWindow> m_mWin; 0101 QPointer<QWidget> m_toolView; 0102 Ui::kateCtags m_ctagsUi{}; 0103 std::unique_ptr<GotoSymbolWidget> m_gotoSymbWidget; 0104 0105 QPointer<KActionMenu> m_menu; 0106 QAction *m_gotoDef; 0107 QAction *m_gotoDec; 0108 QAction *m_lookup; 0109 0110 QProcess m_proc; 0111 QString m_commonDB; 0112 0113 QTimer m_editTimer; 0114 QStack<TagJump> m_jumpStack; 0115 };