diff options
Diffstat (limited to 'tools/qmlformat/qmlformat.cpp')
| -rw-r--r-- | tools/qmlformat/qmlformat.cpp | 19 |
1 files changed, 1 insertions, 18 deletions
diff --git a/tools/qmlformat/qmlformat.cpp b/tools/qmlformat/qmlformat.cpp index 13566fb503..f74ffab566 100644 --- a/tools/qmlformat/qmlformat.cpp +++ b/tools/qmlformat/qmlformat.cpp @@ -38,23 +38,6 @@ static void logParsingErrors(const DomItem &fileItem, const QString &filename) qWarning().noquote() << "Failed to parse" << filename; } -// TODO -// refactor this workaround. ExternalOWningItem is not recognized as an owning type -// in ownerAs. -static std::shared_ptr<ExternalOwningItem> getFileItemOwner(const DomItem &fileItem) -{ - std::shared_ptr<ExternalOwningItem> filePtr = nullptr; - switch (fileItem.internalKind()) { - case DomType::JsFile: - filePtr = fileItem.ownerAs<JsFile>(); - break; - default: - filePtr = fileItem.ownerAs<QmlFile>(); - break; - } - return filePtr; -} - // TODO refactor // Introduce better encapsulation and separation of concerns and move to DOM API // returns a DomItem corresponding to the loaded file and bool indicating the validity of the file @@ -107,7 +90,7 @@ static bool parseFile(const QString &filename, const QQmlFormatOptions &options) if (out.open(stdout, QIODevice::WriteOnly)) { auto lw = createLineWriter([&out](QStringView s) { out.write(s.toUtf8()); }, filename, lwOptions); - OutWriter ow(*lw); + OutWriter ow(getFileItemOwner(fileItem), *lw); res = fileItem.writeOutForFile(ow, checks); ow.flush(); } else { |
