12#include <QtCore/QLoggingCategory>
19 : itemCanonicalPath(itCanonicalPath),
item(
it), currentMap(fLoc)
21 DomItem cRegions =
it.field(Fields::comments);
33 qCWarning(writeOutLog) <<
"PendingRegions non empty when closing item"
38 w.lineWriter.endSourceLocation(
it.value());
43 qCWarning(writeOutLog) <<
"PendingComments when closing item "
59 Path itP =
it.canonicalPath();
62 &&
states.last().itemCanonicalPath
63 == itP.
mid(0,
states.last().itemCanonicalPath.length())) {
64 int oldL =
states.last().itemCanonicalPath.length();
85 state().closeState(*
this);
96 (updateLocs ? &(fMap->info().preCommentLocations[rName]) :
nullptr);
97 state().pendingComments[rName].writePre(*
this, cLocs);
108 state().pendingRegions.remove(rName);
109 if (
state().pendingComments.contains(rName)) {
114 (updateLocs ? &(fMap->info().postCommentLocations[rName]) :
nullptr);
115 state().pendingComments[rName].writePost(*
this, cLocs);
117 state().pendingComments.remove(rName);
132 if (std::shared_ptr<QmlFile> qmlFilePtr = qmlFile.
ownerAs<
QmlFile>()) {
133 std::shared_ptr<QmlFile> copyPtr = qmlFilePtr->makeCopy(qmlFile);
137 auto newEnvPtr = std::make_shared<DomEnvironment>(
138 envPtr, envPtr->loadPaths(), envPtr->options());
139 newEnvPtr->addQmlFile(copyPtr);
143 if (newLoc->path() != qmlFilePath) {
144 if (newLoc->path()) {
145 if (newLoc->path().length() > qmlFilePath.
length()
146 && newLoc->path().mid(0, qmlFilePath.
length()) == qmlFilePath) {
154 <<
"failed to base fileLocations in OutWriter (" << newLoc->path()
155 <<
") to current file (" << qmlFilePath <<
")";
159 Q_ASSERT(newLoc->subItems().isEmpty() && newLoc->info().regions.isEmpty());
162 copyPtr->setFileLocationsTree(newLoc);
166 if (std::shared_ptr<ScriptExpression> exprPtr =
t->info().expr) {
167 Q_ASSERT(p.mid(0, qmlFilePath.length()) == qmlFilePath);
168 MutableDomItem targetExpr = copy.path(p.mid(qmlFilePath.length()));
170 qCWarning(writeOutLog) <<
"failed to get" << p.mid(qmlFilePath.length())
171 <<
"from" << copy.canonicalPath();
172 else if (exprPtr->ast()
173 || (!targetExpr.as<ScriptExpression>()
174 || !targetExpr.as<ScriptExpression>()->ast()))
175 targetExpr.setScript(exprPtr);
177 qCWarning(writeOutLog).noquote()
178 <<
"Skipped update of reformatted ScriptExpression with "
179 "code:\n---------------\n"
180 << exprPtr->code() <<
"\n---------------\n preCode:" <<
181 [exprPtr](Sink s) { sinkEscaped(s, exprPtr->preCode()); }
182 <<
"\n postCode: " <<
183 [exprPtr](Sink s) { sinkEscaped(s, exprPtr->postCode()); }
184 <<
"\n as it failed standalone reparse with errors:" <<
185 [&targetExpr, exprPtr](Sink s) {
187 .copy(exprPtr, targetExpr.canonicalPath())
189 [s](DomItem, ErrorMessage msg) {
Represents a consistent set of types organized in modules, it is the top level of the DOM.
std::shared_ptr< T > ownerAs()
InternalKind internalKind() const
static Tree createTree(Path basePath)
static void addRegion(Tree fLoc, QString locName, SourceLocation loc)
static void updateFullLocation(Tree fLoc, SourceLocation loc)
static Tree ensure(Tree base, Path basePath, AttachedInfo::PathType pType=AttachedInfo::PathType::Relative)
std::shared_ptr< AttachedInfoT< FileLocations > > Tree
LineWriter & write(QStringView v, TextAddType tType=TextAddType::Normal)
void endSourceLocation(PendingSourceLocationId)
PendingSourceLocationId startSourceLocation(SourceLocation *)
const LineWriterOptions & options() const
void closeState(OutWriter &)
QMap< QString, PendingSourceLocationId > pendingRegions
PendingSourceLocationId fullRegionId
OutWriterState(Path itPath, DomItem &it, FileLocations::Tree fLoc)
QMap< QString, CommentedElement > pendingComments
OutWriter & writeRegion(QString rName, QStringView toWrite)
void regionEnd(QString rName)
DomItem updatedFile(DomItem &qmlFile)
UpdatedScriptExpression::Tree reformattedScriptExpressions
FileLocations::Tree topLocation
void itemStart(DomItem &it)
void itemEnd(DomItem &it)
void regionStart(QString rName)
OutWriterState & state(int i=0)
Path mid(int offset, int length) const
std::shared_ptr< AttachedInfoT< UpdatedScriptExpression > > Tree
static bool visitTree(Tree base, function_ref< bool(Path, Tree)> visitor, Path basePath=Path())
\macro QT_RESTRICTED_CAST_FROM_ASCII
QSet< QString >::iterator it
Combined button and popup list for selecting options.
static jboolean copy(JNIEnv *, jobject)
#define qCWarning(category,...)
GLfloat GLfloat GLfloat w
[0]