5#include <QtCore/QCoreApplication>
6#include <QtCore/QRegularExpression>
26 if (change < 0 && offset - change >=
utf16Start()) {
35 value.offset += change;
36 value.startColumn += colChange;
37 value.startLine += lineChange;
39 if (change < 0 && offset - change >
utf16End())
41 value.length += change;
54 int lineNr,
int columnNr,
int utf16Offset,
QString currentLine)
55 : m_innerSinks({ innerSink }),
59 m_currentColumnNr(columnNr),
60 m_utf16Offset(utf16Offset),
61 m_currentLine(currentLine),
68 int nToAdd = nNewline;
77 for (
int i = 0;
i < nToAdd; ++
i)
105 int trailingSpaceStartColumn =
107 IndentInfo indExisting(trailingSpace, tabSize, trailingSpaceStartColumn);
108 if (trailingSpaceStartColumn != 0)
140template<
typename String,
typename ...Args>
155 auto i =
m.capturedStart(1);
156 auto iEnd =
m.capturedEnd(1);
160 if (iEnd <
v.size()) {
163 while (
m.hasMatch()) {
164 write(
v.mid(iEnd,
m.capturedEnd(1) - iEnd));
165 iEnd =
m.capturedEnd(1);
169 write(
v.mid(iEnd,
v.size() - iEnd));
181 if (!
v.trimmed().isEmpty())
204 if (shouldEnsureNewline)
219 res.toUpdate = toUpdate;
229 res.updater = updater;
239 qWarning() <<
"Trying to close already closed PendingSourceLocation" << int(slId);
244 qWarning() <<
"Trying to close non existing PendingSourceLocation" << int(slId);
264 if (spaceOnly && !self.m_currentLine.
isEmpty())
265 spacesToPreserve = self.m_currentLine;
267 if (self.counter() !=
c && !spacesToPreserve.
isEmpty())
278 int startNonSpace = 0;
281 int oldColumn =
column(startNonSpace);
282 if (indentAmount >= 0) {
291 quint32 colChange = indentAmount - oldColumn;
293 qint32 oChange = indent.
size() - startNonSpace;
304 switch (trailingSpace) {
343 i.value().changeAtOffset(
offset, change, colChange, lineChange);
368 if (!
it.value()(*
this,
t))
378 bool isEmptyNewline = !eol.
isEmpty() && isSpaceOnly;
390 int oldCol =
column(untilChar);
433 else if (!isSpaceOnly)
439 auto &pLoc =
i.value();
440 if (!pLoc.open && pLoc.utf16End() <= endCommit) {
455#include "moc_qqmldomlinewriter_p.cpp"
constexpr bool isSpace() const noexcept
Returns true if the character is a separator character (Separator_* categories or certain code points...
QStringView trailingString
FormatOptions formatOptions
TrailingSpace codeTrailingSpace
void commitLine(QString eol, TextAddType t=TextAddType::Normal, int untilChar=-1)
virtual void lineChanged()
LineWriter & write(QStringView v, TextAddType tType=TextAddType::Normal)
QAtomicInt m_lastCallbackId
void endSourceLocation(PendingSourceLocationId)
void handleTrailingSpace(LineWriterOptions::TrailingSpace s)
int column(int localIndex)
LineWriter & ensureNewline(int nNewlines=1, TextAddType t=TextAddType::Extra)
PendingSourceLocationId startSourceLocation(SourceLocation *)
QMap< PendingSourceLocationId, PendingSourceLocation > m_pendingSourceLocations
QMap< int, std::function< bool(LineWriter &, TextAddType)> > m_textAddCallbacks
PendingSourceLocationId m_lastSourceLocationId
LineWriter(SinkF innerSink, QString fileName, const LineWriterOptions &options=LineWriterOptions(), int lineNr=0, int columnNr=0, int utf16Offset=0, QString currentLine=QString())
LineWriterOptions m_options
virtual void reindentAndSplit(QString eol, bool eof=false)
LineWriter & ensureSpace(TextAddType t=TextAddType::Extra)
QString eolToWrite() const
void eof(bool ensureNewline=true)
QList< SinkF > m_innerSinks
std::function< void(QStringView)> sink()
int addNewlinesAutospacerCallback(int nLines)
void changeAtOffset(quint32 offset, qint32 change, qint32 colChange, qint32 lineChange)
quint32 m_committedEmptyLines
SourceLocation currentSourceLocation() const
virtual void willCommit()
SourceLocation committedLocation() const
void setLineIndent(int indentAmount)
int addTextAddCallback(std::function< bool(LineWriter &, TextAddType)> callback)
void textAddCallback(TextAddType t)
quint32 utf16Start() const
std::function< void(SourceLocation)> updater
void changeAtOffset(quint32 offset, qint32 change, qint32 colChange, qint32 lineChange)
SourceLocation * toUpdate
\inmodule QtCore \reentrant
\inmodule QtCore \reentrant
QRegularExpressionMatch matchView(QStringView subjectView, qsizetype offset=0, MatchType matchType=NormalMatch, MatchOptions matchOptions=NoMatchOption) const
constexpr bool isEmpty() const noexcept
Returns whether this string view is empty - that is, whether {size() == 0}.
constexpr qsizetype size() const noexcept
Returns the size of this string view, in UTF-16 code units (that is, surrogate pairs count as two for...
QString toString() const
Returns a deep copy of this string view's data as a QString.
constexpr QStringView mid(qsizetype pos, qsizetype n=-1) const noexcept
Returns the substring of length length starting at position start in this object.
QStringView trimmed() const noexcept
Strips leading and trailing whitespace and returns the result.
\macro QT_RESTRICTED_CAST_FROM_ASCII
QString & replace(qsizetype i, qsizetype len, QChar after)
void clear()
Clears the contents of the string and makes it null.
qsizetype size() const
Returns the number of characters in this string.
QString mid(qsizetype position, qsizetype n=-1) const
Returns a string that contains n characters of this string, starting at the specified position index.
const QChar at(qsizetype i) const
Returns the character at the given index position in the string.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QString & append(QChar c)
QString trimmed() const &
QSet< QString >::iterator it
std::function< void(QStringView)> SinkF
static QRegularExpressionMatch matchHelper(QRegularExpression &re, String &&s, Args &&...args)
Combined button and popup list for selecting options.
SharedPointerFileDialogOptions m_options
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLsizei const GLfloat * v
[13]
GLenum GLuint GLintptr offset
GLenum GLenum GLsizei void GLsizei void * column
GLsizei GLenum GLboolean sink
QLatin1StringView QLatin1String
#define QStringLiteral(str)