aboutsummaryrefslogtreecommitdiffstats
path: root/tools/qmlformat
diff options
context:
space:
mode:
authorSami Shalayel <[email protected]>2023-03-10 12:07:27 +0100
committerSami Shalayel <[email protected]>2023-03-29 19:07:25 +0200
commit6913084b0d649b78dc10b80cd9b8d77d51a50c8b (patch)
tree9eb887e161ed877e61b26ad9f15d83753712fc5f /tools/qmlformat
parent7ad7eb606a0831568dc55c782d1a7cdc8fb395b3 (diff)
Remove DomItem::loadFile code-duplication and use correct environments
The loadFile overload (in DomItem, DomEnvironment and DomUnivers) for different files (in-memory files and files that needs to be loaded from disk) are either copypasted or just calling the other overload. Encapsulate the file-related arguments of all loadFile overloads into a new struct called FileToLoad, such that the copypasted overloads can be removed. Use the static factory function FileToLoad::fromMemory and FileToLoad::fromFileSystem to create the FileToLoad struct. In addition, FileToLoad allows to specify the environment in which a file should be loaded. Prior this commit, myEnv.loadFile() was creating a new environment for each loaded file. Change-Id: I3b6acb681cb77faefdaa447d985bdfbe4f6a9ce2 Reviewed-by: Fabian Kosmale <[email protected]>
Diffstat (limited to 'tools/qmlformat')
-rw-r--r--tools/qmlformat/qmlformat.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/qmlformat/qmlformat.cpp b/tools/qmlformat/qmlformat.cpp
index 06d1c2b4d0..68dd7c5379 100644
--- a/tools/qmlformat/qmlformat.cpp
+++ b/tools/qmlformat/qmlformat.cpp
@@ -54,7 +54,7 @@ bool parseFile(const QString &filename, const Options &options)
| QQmlJS::Dom::DomEnvironment::Option::NoDependencies);
DomItem tFile; // place where to store the loaded file
env.loadFile(
- filename, QString(),
+ FileToLoad::fromFileSystem(env.ownerAs<DomEnvironment>(), filename),
[&tFile](Path, const DomItem &, const DomItem &newIt) {
tFile = newIt; // callback called when everything is loaded that receives the loaded
// external file pair (path, oldValue, newValue)