File indexing completed on 2024-04-28 04:34:35
0001 /* 0002 SPDX-FileCopyrightText: 2009 Milian Wolff <mail@milianw.de> 0003 Based on Cpp ImplementationHelperItem 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #ifndef KEYWORDITEM_H 0009 #define KEYWORDITEM_H 0010 0011 #include "item.h" 0012 0013 using namespace KDevelop; 0014 0015 namespace Php 0016 { 0017 0018 class KeywordItem : public NormalDeclarationCompletionItem 0019 { 0020 public: 0021 /// Use @p customReplacement for additional power on how the keyword gets replaced. 0022 /// Newlines will be indented to the indentation level of the line we execute the item on. 0023 /// To increase an indentation level, use %INDENT%. To place the cursor, use %CURSOR%. 0024 /// Alternatively you can select a word with %SELECT%word%SELECT% 0025 /// 0026 /// NOTE: By default (i.e. when this function never gets called) @p keyword will be used as replacement. 0027 explicit KeywordItem(const QString &keyword, 0028 QExplicitlySharedDataPointer<Php::CodeCompletionContext> context = {}, 0029 const QString &customReplacement = QString()) 0030 : NormalDeclarationCompletionItem(KDevelop::DeclarationPointer(), context, 0), 0031 m_keyword(keyword), m_replacement(customReplacement) {} 0032 0033 void execute(KTextEditor::View* view, 0034 const KTextEditor::Range& word) override; 0035 0036 QVariant data(const QModelIndex& index, 0037 int role, 0038 const KDevelop::CodeCompletionModel* model) const override; 0039 0040 private: 0041 const QString m_keyword; 0042 QString m_replacement; 0043 }; 0044 0045 } 0046 0047 #endif // KEYWORDITEM_H