Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qqmlcompletioncontextstrings.cpp
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// Qt-Security score:significant reason:default
4
6
7CompletionContextStrings::CompletionContextStrings(QString code, qsizetype pos)
8 : m_code(code), m_pos(pos)
9{
10 // computes the context just before pos in code.
11 // After this code all the values of all the attributes should be correct (see above)
12 // handle also letter or numbers represented a surrogate pairs?
13 m_filterStart = m_pos;
14 while (m_filterStart != 0) {
15 QChar c = code.at(m_filterStart - 1);
16 if (!c.isLetterOrNumber() && c != u'_')
17 break;
18 else
19 --m_filterStart;
20 }
21 // handle spaces?
22 m_baseStart = m_filterStart;
23 while (m_baseStart != 0) {
24 QChar c = code.at(m_baseStart - 1);
25 if (c != u'.' || m_baseStart == 1)
26 break;
27 c = code.at(m_baseStart - 2);
28 if (!c.isLetterOrNumber() && c != u'_')
29 break;
30 qsizetype baseEnd = --m_baseStart;
31 while (m_baseStart != 0) {
32 QChar c = code.at(m_baseStart - 1);
33 if (!c.isLetterOrNumber() && c != u'_')
34 break;
35 else
36 --m_baseStart;
37 }
38 if (m_baseStart == baseEnd)
39 break;
40 }
41 m_atLineStart = true;
42 m_lineStart = m_baseStart;
43 while (m_lineStart != 0) {
44 QChar c = code.at(m_lineStart - 1);
45 if (c == u'\n' || c == u'\r')
46 break;
47 if (!c.isSpace())
48 m_atLineStart = false;
49 --m_lineStart;
50 }
51}