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
QQmlJS::Dom::OutWriter Class Reference

#include <qqmldomoutwriter_p.h>

+ Collaboration diagram for QQmlJS::Dom::OutWriter:

Public Member Functions

 OutWriter (LineWriter &lw)
 
OutWriterStatestate (int i=0)
 
int increaseIndent (int level=1)
 
int decreaseIndent (int level=1, int expectedIndent=-1)
 
void itemStart (const DomItem &it)
 
void itemEnd (const DomItem &it)
 
void regionStart (FileLocationRegion region)
 
void regionEnd (FileLocationRegion regino)
 
quint32 counter () const
 
OutWriterwriteRegion (FileLocationRegion region, QStringView toWrite)
 
OutWriterwriteRegion (FileLocationRegion region)
 
OutWriterensureNewline (int nNewlines=1)
 
OutWriterensureSpace ()
 
OutWriterensureSpace (QStringView space)
 
OutWriternewline ()
 
OutWriterspace ()
 
OutWriterwrite (QStringView v, LineWriter::TextAddType t=LineWriter::TextAddType::Normal)
 
OutWriterwrite (QStringView v, SourceLocation *toUpdate)
 
void flush ()
 
void eof (bool ensureNewline=true)
 
int addNewlinesAutospacerCallback (int nLines)
 
int addTextAddCallback (std::function< bool(LineWriter &, LineWriter::TextAddType)> callback)
 
bool removeTextAddCallback (int i)
 
void addReformattedScriptExpression (const Path &p, const std::shared_ptr< ScriptExpression > &exp)
 
DomItem restoreWrittenFileItem (const DomItem &fileItem)
 

Public Attributes

int indent = 0
 
int indenterId = -1
 
bool indentNextlines = false
 
bool skipComments = false
 
LineWriterlineWriter
 
Path currentPath
 
FileLocations::Tree topLocation
 
QString writtenStr
 
UpdatedScriptExpression::Tree reformattedScriptExpressions
 
QList< OutWriterStatestates
 

Detailed Description

Definition at line 45 of file qqmldomoutwriter_p.h.

Constructor & Destructor Documentation

◆ OutWriter()

QQmlJS::Dom::OutWriter::OutWriter ( LineWriter & lw)
inlineexplicit

Definition at line 59 of file qqmldomoutwriter_p.h.

References QQmlJS::Dom::LineWriter::addInnerSink(), QQmlJS::Dom::LineWriter::addTextAddCallback(), QString::append(), QQmlJS::Dom::LineWriter::currentLine(), QStringView::isEmpty(), QQmlJS::Dom::LineWriter::setLineIndent(), and QStringView::trimmed().

+ Here is the call graph for this function:

Member Function Documentation

◆ addNewlinesAutospacerCallback()

int QQmlJS::Dom::OutWriter::addNewlinesAutospacerCallback ( int nLines)
inline

Definition at line 134 of file qqmldomoutwriter_p.h.

References QQmlJS::Dom::LineWriter::addNewlinesAutospacerCallback().

+ Here is the call graph for this function:

◆ addReformattedScriptExpression()

void QQmlJS::Dom::OutWriter::addReformattedScriptExpression ( const Path & p,
const std::shared_ptr< ScriptExpression > & exp )
inline

Definition at line 143 of file qqmldomoutwriter_p.h.

◆ addTextAddCallback()

int QQmlJS::Dom::OutWriter::addTextAddCallback ( std::function< bool(LineWriter &, LineWriter::TextAddType)> callback)
inline

Definition at line 138 of file qqmldomoutwriter_p.h.

References QQmlJS::Dom::LineWriter::addTextAddCallback().

+ Here is the call graph for this function:

◆ counter()

quint32 QQmlJS::Dom::OutWriter::counter ( ) const
inline

Definition at line 94 of file qqmldomoutwriter_p.h.

References QQmlJS::Dom::LineWriter::counter().

+ Here is the call graph for this function:

◆ decreaseIndent()

int QQmlJS::Dom::OutWriter::decreaseIndent ( int level = 1,
int expectedIndent = -1 )
inline

Definition at line 82 of file qqmldomoutwriter_p.h.

References QQmlJS::Dom::LineWriterOptions::formatOptions, QQmlJS::Dom::FormatOptions::indentSize, QQmlJS::Dom::LineWriter::options(), and Q_ASSERT.

Referenced by QQmlJS::Dom::ScriptFormatter::lnAcceptIndented(), QQmlJS::Dom::ScriptFormatter::visit(), QQmlJS::Dom::ScriptFormatter::visit(), QQmlJS::Dom::ScriptFormatter::visit(), QQmlJS::Dom::ScriptFormatter::visit(), QQmlJS::Dom::ScriptFormatter::visit(), and QQmlJS::Dom::ScriptFormatter::visit().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ensureNewline()

OutWriter & QQmlJS::Dom::OutWriter::ensureNewline ( int nNewlines = 1)
inline

Definition at line 97 of file qqmldomoutwriter_p.h.

References QQmlJS::Dom::LineWriter::ensureNewline().

Referenced by QQmlJS::Dom::ScriptFormatter::lnAcceptIndented(), QQmlJS::Dom::ScriptFormatter::newLine(), QQmlJS::Dom::Comment::write(), and QQmlJS::Dom::QmlComponent::writeOut().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ensureSpace() [1/2]

OutWriter & QQmlJS::Dom::OutWriter::ensureSpace ( )
inline

Definition at line 102 of file qqmldomoutwriter_p.h.

References QQmlJS::Dom::LineWriter::ensureSpace().

Referenced by QQmlJS::Dom::Comment::write().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ensureSpace() [2/2]

OutWriter & QQmlJS::Dom::OutWriter::ensureSpace ( QStringView space)
inline

Definition at line 107 of file qqmldomoutwriter_p.h.

References QQmlJS::Dom::LineWriter::ensureSpace().

+ Here is the call graph for this function:

◆ eof()

void QQmlJS::Dom::OutWriter::eof ( bool ensureNewline = true)
inline

Definition at line 133 of file qqmldomoutwriter_p.h.

References QQmlJS::Dom::LineWriter::eof().

+ Here is the call graph for this function:

◆ flush()

void QQmlJS::Dom::OutWriter::flush ( )
inline

Definition at line 132 of file qqmldomoutwriter_p.h.

References QQmlJS::Dom::LineWriter::flush().

+ Here is the call graph for this function:

◆ increaseIndent()

int QQmlJS::Dom::OutWriter::increaseIndent ( int level = 1)
inline

Definition at line 76 of file qqmldomoutwriter_p.h.

References QQmlJS::Dom::LineWriterOptions::formatOptions, QQmlJS::Dom::FormatOptions::indentSize, and QQmlJS::Dom::LineWriter::options().

Referenced by QQmlJS::Dom::ScriptFormatter::lnAcceptIndented(), QQmlJS::Dom::ScriptFormatter::visit(), QQmlJS::Dom::ScriptFormatter::visit(), QQmlJS::Dom::ScriptFormatter::visit(), QQmlJS::Dom::ScriptFormatter::visit(), QQmlJS::Dom::ScriptFormatter::visit(), and QQmlJS::Dom::ScriptFormatter::visit().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ itemEnd()

void QQmlJS::Dom::OutWriter::itemEnd ( const DomItem & it)

Definition at line 79 of file qqmldomoutwriter.cpp.

References it, item, QQmlJS::Dom::MainRegion, Q_ASSERT, regionEnd(), and state.

+ Here is the call graph for this function:

◆ itemStart()

◆ newline()

OutWriter & QQmlJS::Dom::OutWriter::newline ( )
inline

Definition at line 112 of file qqmldomoutwriter_p.h.

References QQmlJS::Dom::LineWriter::newline().

Referenced by QQmlJS::Dom::ScriptFormatter::visit(), and QQmlJS::Dom::ScriptFormatter::visit().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ regionEnd()

void QQmlJS::Dom::OutWriter::regionEnd ( FileLocationRegion regino)

Definition at line 102 of file qqmldomoutwriter.cpp.

References QQmlJS::Dom::LineWriter::endSourceLocation(), lineWriter, QQmlJS::Dom::LineWriterOptions::Locations, QQmlJS::Dom::LineWriter::options(), Q_ASSERT, skipComments, state, and QQmlJS::Dom::LineWriterOptions::updateOptions.

Referenced by itemEnd(), and writeRegion().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ regionStart()

void QQmlJS::Dom::OutWriter::regionStart ( FileLocationRegion region)

Definition at line 88 of file qqmldomoutwriter.cpp.

References QQmlJS::Dom::FileLocations::addRegion(), lineWriter, QQmlJS::Dom::LineWriterOptions::Locations, QQmlJS::Dom::LineWriter::options(), Q_ASSERT, skipComments, QQmlJS::Dom::LineWriter::startSourceLocation(), state, and QQmlJS::Dom::LineWriterOptions::updateOptions.

Referenced by itemStart(), and writeRegion().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeTextAddCallback()

bool QQmlJS::Dom::OutWriter::removeTextAddCallback ( int i)
inline

Definition at line 142 of file qqmldomoutwriter_p.h.

References i, and QQmlJS::Dom::LineWriter::removeTextAddCallback().

+ Here is the call graph for this function:

◆ restoreWrittenFileItem()

DomItem QQmlJS::Dom::OutWriter::restoreWrittenFileItem ( const DomItem & fileItem)

Restores written out FileItem using intermediate information saved during DOM traversal. It enables verifying DOM consistency of the written item later.

At the moment of writing, intermediate information consisting only of UpdatedScriptExpression, however this is subject for change. The process of restoration is the following:

  1. Creating copy of the initial fileItem
  2. Updating relevant data/subitems modified during the WriteOut
  3. Returning an item containing updates.

Definition at line 282 of file qqmldomoutwriter.cpp.

References QQmlJS::Dom::JsFile, qCWarning, and QQmlJS::Dom::QmlFile.

◆ space()

OutWriter & QQmlJS::Dom::OutWriter::space ( )
inline

◆ state()

OutWriterState & QQmlJS::Dom::OutWriter::state ( int i = 0)

Definition at line 47 of file qqmldomoutwriter.cpp.

References i.

◆ write() [1/2]

OutWriter & QQmlJS::Dom::OutWriter::write ( QStringView v,
LineWriter::TextAddType t = LineWriter::TextAddType::Normal )
inline

Definition at line 122 of file qqmldomoutwriter_p.h.

References QQmlJS::Dom::LineWriter::write().

Referenced by QQmlJS::Dom::ScriptFormatter::out(), QQmlJS::Dom::ScriptFormatter::out(), and QQmlJS::Dom::Comment::write().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ write() [2/2]

OutWriter & QQmlJS::Dom::OutWriter::write ( QStringView v,
SourceLocation * toUpdate )
inline

Definition at line 127 of file qqmldomoutwriter_p.h.

References QQmlJS::Dom::LineWriter::write().

+ Here is the call graph for this function:

◆ writeRegion() [1/2]

OutWriter & QQmlJS::Dom::OutWriter::writeRegion ( FileLocationRegion region)

Helper method for writeRegion(FileLocationRegion region) that allows to use {writeRegion(ColonTokenRegion);} instead of having to write out the more error-prone {writeRegion(ColonTokenRegion, ":");} for tokens and keywords.

Definition at line 126 of file qqmldomoutwriter.cpp.

References QQmlJS::Dom::AsTokenRegion, QQmlJS::Dom::BreakKeywordRegion, QQmlJS::Dom::CaseKeywordRegion, QQmlJS::Dom::CatchKeywordRegion, QQmlJS::Dom::ColonTokenRegion, QQmlJS::Dom::CommaTokenRegion, QQmlJS::Dom::ComponentKeywordRegion, QQmlJS::Dom::ContinueKeywordRegion, QQmlJS::Dom::DefaultKeywordRegion, QQmlJS::Dom::DoKeywordRegion, QQmlJS::Dom::EllipsisTokenRegion, QQmlJS::Dom::ElseKeywordRegion, QQmlJS::Dom::EnumKeywordRegion, QQmlJS::Dom::EnumValueRegion, QQmlJS::Dom::EqualTokenRegion, QQmlJS::Dom::FinallyKeywordRegion, QQmlJS::Dom::FirstSemicolonTokenRegion, QQmlJS::Dom::ForKeywordRegion, QQmlJS::Dom::FunctionKeywordRegion, QQmlJS::Dom::IdColonTokenRegion, QQmlJS::Dom::IdentifierRegion, QQmlJS::Dom::IdNameRegion, QQmlJS::Dom::IdTokenRegion, QQmlJS::Dom::ImportTokenRegion, QQmlJS::Dom::ImportUriRegion, QQmlJS::Dom::InOfTokenRegion, QQmlJS::Dom::LeftBraceRegion, QQmlJS::Dom::LeftBracketRegion, QQmlJS::Dom::LeftParenthesisRegion, QQmlJS::Dom::MainRegion, QQmlJS::Dom::OnTargetRegion, QQmlJS::Dom::OnTokenRegion, QQmlJS::Dom::OperatorTokenRegion, QQmlJS::Dom::PragmaKeywordRegion, QQmlJS::Dom::PragmaValuesRegion, QQmlJS::Dom::PropertyKeywordRegion, Q_ASSERT_X, QQmlJS::Dom::QuestionMarkTokenRegion, QQmlJS::Dom::ReadonlyKeywordRegion, QQmlJS::Dom::RequiredKeywordRegion, QQmlJS::Dom::ReturnKeywordRegion, QQmlJS::Dom::RightBraceRegion, QQmlJS::Dom::RightBracketRegion, QQmlJS::Dom::RightParenthesisRegion, QQmlJS::Dom::SecondSemicolonRegion, QQmlJS::Dom::SemicolonTokenRegion, QQmlJS::Dom::SignalKeywordRegion, QQmlJS::Dom::ThrowKeywordRegion, QQmlJS::Dom::TryKeywordRegion, QQmlJS::Dom::TypeIdentifierRegion, QQmlJS::Dom::VersionRegion, QQmlJS::Dom::WhileKeywordRegion, and writeRegion().

+ Here is the call graph for this function:

◆ writeRegion() [2/2]

OutWriter & QQmlJS::Dom::OutWriter::writeRegion ( FileLocationRegion region,
QStringView toWrite )

Definition at line 264 of file qqmldomoutwriter.cpp.

References lineWriter, regionEnd(), regionStart(), and QQmlJS::Dom::LineWriter::write().

Referenced by QQmlJS::Dom::QmlComponent::writeOut(), and writeRegion().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ currentPath

Path QQmlJS::Dom::OutWriter::currentPath

Definition at line 53 of file qqmldomoutwriter_p.h.

◆ indent

int QQmlJS::Dom::OutWriter::indent = 0

Definition at line 48 of file qqmldomoutwriter_p.h.

◆ indenterId

int QQmlJS::Dom::OutWriter::indenterId = -1

Definition at line 49 of file qqmldomoutwriter_p.h.

◆ indentNextlines

bool QQmlJS::Dom::OutWriter::indentNextlines = false

◆ lineWriter

LineWriter& QQmlJS::Dom::OutWriter::lineWriter

◆ reformattedScriptExpressions

UpdatedScriptExpression::Tree QQmlJS::Dom::OutWriter::reformattedScriptExpressions

Definition at line 56 of file qqmldomoutwriter_p.h.

◆ skipComments

bool QQmlJS::Dom::OutWriter::skipComments = false

Definition at line 51 of file qqmldomoutwriter_p.h.

Referenced by regionEnd(), and regionStart().

◆ states

QList<OutWriterState> QQmlJS::Dom::OutWriter::states

Definition at line 57 of file qqmldomoutwriter_p.h.

◆ topLocation

FileLocations::Tree QQmlJS::Dom::OutWriter::topLocation

Definition at line 54 of file qqmldomoutwriter_p.h.

Referenced by itemStart().

◆ writtenStr

QString QQmlJS::Dom::OutWriter::writtenStr

Definition at line 55 of file qqmldomoutwriter_p.h.


The documentation for this class was generated from the following files: