Changeset View
Changeset View
Standalone View
Standalone View
autotests/src/codecompletiontestmodels.h
Show All 20 Lines | |||||
21 | #define KATE_COMPLETIONTESTMODELS_H | 21 | #define KATE_COMPLETIONTESTMODELS_H | ||
22 | 22 | | |||
23 | #include "codecompletiontestmodel.h" | 23 | #include "codecompletiontestmodel.h" | ||
24 | #include <ktexteditor/codecompletionmodelcontrollerinterface.h> | 24 | #include <ktexteditor/codecompletionmodelcontrollerinterface.h> | ||
25 | 25 | | |||
26 | #include <ktexteditor/document.h> | 26 | #include <ktexteditor/document.h> | ||
27 | #include <ktexteditor/view.h> | 27 | #include <ktexteditor/view.h> | ||
28 | 28 | | |||
29 | #include <QRegularExpression> | ||||
30 | | ||||
29 | using namespace KTextEditor; | 31 | using namespace KTextEditor; | ||
30 | 32 | | |||
31 | class CustomRangeModel : public CodeCompletionTestModel, public CodeCompletionModelControllerInterface | 33 | class CustomRangeModel : public CodeCompletionTestModel, public CodeCompletionModelControllerInterface | ||
32 | { | 34 | { | ||
33 | Q_OBJECT | 35 | Q_OBJECT | ||
34 | Q_INTERFACES(KTextEditor::CodeCompletionModelControllerInterface) | 36 | Q_INTERFACES(KTextEditor::CodeCompletionModelControllerInterface) | ||
35 | public: | 37 | public: | ||
36 | explicit CustomRangeModel(KTextEditor::View *parent = nullptr, const QString &startText = QString()) | 38 | explicit CustomRangeModel(KTextEditor::View *parent = nullptr, const QString &startText = QString()) | ||
Show All 13 Lines | 42 | { | |||
50 | } | 52 | } | ||
51 | return range; | 53 | return range; | ||
52 | } | 54 | } | ||
53 | 55 | | |||
54 | bool shouldAbortCompletion(View *view, const Range &range, const QString ¤tCompletion) override | 56 | bool shouldAbortCompletion(View *view, const Range &range, const QString ¤tCompletion) override | ||
55 | { | 57 | { | ||
56 | Q_UNUSED(view); | 58 | Q_UNUSED(view); | ||
57 | Q_UNUSED(range); | 59 | Q_UNUSED(range); | ||
58 | static const QRegExp allowedText("^\\$?(\\w*)"); | 60 | static const QRegularExpression allowedText("^\\$?(\\w*)$"); | ||
59 | return !allowedText.exactMatch(currentCompletion); | 61 | return !allowedText.match(currentCompletion).hasMatch(); | ||
60 | } | 62 | } | ||
61 | }; | 63 | }; | ||
62 | 64 | | |||
63 | class CustomAbortModel : public CodeCompletionTestModel, public CodeCompletionModelControllerInterface | 65 | class CustomAbortModel : public CodeCompletionTestModel, public CodeCompletionModelControllerInterface | ||
64 | { | 66 | { | ||
65 | Q_OBJECT | 67 | Q_OBJECT | ||
66 | Q_INTERFACES(KTextEditor::CodeCompletionModelControllerInterface) | 68 | Q_INTERFACES(KTextEditor::CodeCompletionModelControllerInterface) | ||
67 | public: | 69 | public: | ||
68 | explicit CustomAbortModel(KTextEditor::View *parent = nullptr, const QString &startText = QString()) | 70 | explicit CustomAbortModel(KTextEditor::View *parent = nullptr, const QString &startText = QString()) | ||
69 | : CodeCompletionTestModel(parent, startText) | 71 | : CodeCompletionTestModel(parent, startText) | ||
70 | {} | 72 | {} | ||
71 | 73 | | |||
72 | bool shouldAbortCompletion(View *view, const Range &range, const QString ¤tCompletion) override | 74 | bool shouldAbortCompletion(View *view, const Range &range, const QString ¤tCompletion) override | ||
73 | { | 75 | { | ||
74 | Q_UNUSED(view); | 76 | Q_UNUSED(view); | ||
75 | Q_UNUSED(range); | 77 | Q_UNUSED(range); | ||
76 | static const QRegExp allowedText("^([\\w-]*)"); | 78 | static const QRegularExpression allowedText("^([\\w-]*)"); | ||
77 | return !allowedText.exactMatch(currentCompletion); | 79 | return !allowedText.match(currentCompletion).hasMatch(); | ||
78 | } | 80 | } | ||
79 | }; | 81 | }; | ||
80 | 82 | | |||
81 | class EmptyFilterStringModel : public CodeCompletionTestModel, public CodeCompletionModelControllerInterface | 83 | class EmptyFilterStringModel : public CodeCompletionTestModel, public CodeCompletionModelControllerInterface | ||
82 | { | 84 | { | ||
83 | Q_OBJECT | 85 | Q_OBJECT | ||
84 | Q_INTERFACES(KTextEditor::CodeCompletionModelControllerInterface) | 86 | Q_INTERFACES(KTextEditor::CodeCompletionModelControllerInterface) | ||
85 | public: | 87 | public: | ||
▲ Show 20 Lines • Show All 81 Lines • Show Last 20 Lines |