Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qqmlcompletioncontextstrings_p.h
Go to the documentation of this file.
1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QQMLLSCOMPLETIONCONTEXTSTRINGS_H
5#define QQMLLSCOMPLETIONCONTEXTSTRINGS_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/qtconfigmacros.h>
19#include <QtCore/qstring.h>
20#include <QtCore/qstringview.h>
21
23
24// finds the filter string, the base (for fully qualified accesses) and the whole string
25// just before pos in code
27{
29
30public:
31 // line up until pos
33 {
34 return QStringView(m_code).mid(m_lineStart, m_pos - m_lineStart);
35 }
36 // the part used to filter the completion (normally actual filtering is left to the client)
38 {
39 return QStringView(m_code).mid(m_filterStart, m_pos - m_filterStart);
40 }
41 // the base part (qualified access)
43 {
44 return QStringView(m_code).mid(m_baseStart, m_filterStart - m_baseStart);
45 }
46 // if we are at line start
47 bool atLineStart() const { return m_atLineStart; }
48
49 qsizetype offset() const { return m_pos; }
50
51private:
52 QString m_code; // the current code
53 qsizetype m_pos = {}; // current position of the cursor
54 qsizetype m_filterStart = {}; // start of the characters that are used to filter the suggestions
55 qsizetype m_lineStart = {}; // start of the current line
56 qsizetype m_baseStart = {}; // start of the dotted expression that ends at the cursor position
57 bool m_atLineStart = {}; // if there are only spaces before base
58};
59
61
62#endif // QQMLLSCOMPLETIONCONTEXTSTRINGS_H
\inmodule QtCore
Definition qstringview.h:78
constexpr QStringView mid(qsizetype pos, qsizetype n=-1) const noexcept
Returns the substring of length length starting at position start in this object.
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
Combined button and popup list for selecting options.
ptrdiff_t qsizetype
Definition qtypes.h:165
CompletionContextStrings(QString code, qsizetype pos)