aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmldom/qqmldomoutwriter_p.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/qmldom/qqmldomoutwriter_p.h')
-rw-r--r--src/qmldom/qqmldomoutwriter_p.h42
1 files changed, 18 insertions, 24 deletions
diff --git a/src/qmldom/qqmldomoutwriter_p.h b/src/qmldom/qqmldomoutwriter_p.h
index 81251e60be..8b00223ea2 100644
--- a/src/qmldom/qqmldomoutwriter_p.h
+++ b/src/qmldom/qqmldomoutwriter_p.h
@@ -27,16 +27,10 @@ QT_BEGIN_NAMESPACE
namespace QQmlJS {
namespace Dom {
-#define QMLDOM_USTRING(s) u##s
-#define QMLDOM_REGION(name) constexpr const auto name = QMLDOM_USTRING(#name)
-// namespace, so it cam be reopened to add more entries
-namespace Regions {
-} // namespace Regions
-
class QMLDOM_EXPORT OutWriterState
{
public:
- OutWriterState(Path itPath, DomItem &it, FileLocations::Tree fLoc);
+ OutWriterState(const Path &itPath, const DomItem &it, const FileLocations::Tree &fLoc);
void closeState(OutWriter &);
@@ -44,8 +38,8 @@ public:
DomItem item;
PendingSourceLocationId fullRegionId;
FileLocations::Tree currentMap;
- QMap<QString, PendingSourceLocationId> pendingRegions;
- QMap<QString, CommentedElement> pendingComments;
+ QMap<FileLocationRegion, PendingSourceLocationId> pendingRegions;
+ QMap<FileLocationRegion, CommentedElement> pendingComments;
};
class QMLDOM_EXPORT OutWriter
@@ -92,21 +86,14 @@ public:
return indent;
}
- void itemStart(DomItem &it);
- void itemEnd(DomItem &it);
- void regionStart(QString rName);
- void regionStart(QStringView rName) { regionStart(rName.toString()); }
- void regionEnd(QString rName);
- void regionEnd(QStringView rName) { regionEnd(rName.toString()); }
+ void itemStart(const DomItem &it);
+ void itemEnd(const DomItem &it);
+ void regionStart(FileLocationRegion region);
+ void regionEnd(FileLocationRegion regino);
quint32 counter() const { return lineWriter.counter(); }
- OutWriter &writeRegion(QString rName, QStringView toWrite);
- OutWriter &writeRegion(QStringView rName, QStringView toWrite)
- {
- return writeRegion(rName.toString(), toWrite);
- }
- OutWriter &writeRegion(QString t) { return writeRegion(t, t); }
- OutWriter &writeRegion(QStringView t) { return writeRegion(t.toString(), t); }
+ OutWriter &writeRegion(FileLocationRegion region, QStringView toWrite);
+ OutWriter &writeRegion(FileLocationRegion region);
OutWriter &ensureNewline(int nNewlines = 1)
{
lineWriter.ensureNewline(nNewlines);
@@ -153,14 +140,21 @@ public:
return lineWriter.addTextAddCallback(callback);
}
bool removeTextAddCallback(int i) { return lineWriter.removeTextAddCallback(i); }
- void addReformattedScriptExpression(Path p, std::shared_ptr<ScriptExpression> exp)
+ void addReformattedScriptExpression(const Path &p, const std::shared_ptr<ScriptExpression> &exp)
{
if (auto updExp = UpdatedScriptExpression::ensure(reformattedScriptExpressions, p,
AttachedInfo::PathType::Canonical)) {
updExp->info().expr = exp;
}
}
- DomItem updatedFile(DomItem &qmlFile);
+ DomItem restoreWrittenFileItem(const DomItem &fileItem);
+
+private:
+ DomItem writtenQmlFileItem(const DomItem &fileItem, const Path &filePath);
+ DomItem writtenJsFileItem(const DomItem &fileItem, const Path &filePath);
+ static void logScriptExprUpdateSkipped(
+ const DomItem &exprItem, const Path &exprPath,
+ const std::shared_ptr<ScriptExpression> &formattedExpr);
};
} // end namespace Dom