aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitrii Akshintsev <dmitrii.akshintsev@qt.io>2024-01-24 14:05:13 +0100
committerDmitrii Akshintsev <dmitrii.akshintsev@qt.io>2024-01-25 21:40:34 +0100
commit8421be9bd554dd435147cfb2feeeaf65f10b49a4 (patch)
tree8f9bae4e83f7de8c01ed59136c46cc44b6162047
parent2da5ce3a46583b4949ef0fd2a9813489d1a255aa (diff)
DOM refactoring. Get rid of the envCallbackForFile usage
^^^ this allows us to keep the work with env within the environment and get rid of the lots of auxillary logic associated with callbacks. Task-number: QTBUG-119550 Change-Id: I863c143d34778630be348c891f49ba28e4c6e326 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
-rw-r--r--src/qmldom/qqmldomtop.cpp31
1 files changed, 10 insertions, 21 deletions
diff --git a/src/qmldom/qqmldomtop.cpp b/src/qmldom/qqmldomtop.cpp
index 1dd3f45371..855d8bb2dd 100644
--- a/src/qmldom/qqmldomtop.cpp
+++ b/src/qmldom/qqmldomtop.cpp
@@ -1197,7 +1197,6 @@ void DomEnvironment::loadFile(const FileToLoad &file, const Callback &loadCallba
shared_ptr<ExternalItemInfoBase> oldValue, newValue;
const DomType fType =
(bool(fileType) ? (*fileType) : fileTypeForPath(self, file.canonicalPath()));
- const auto callback = getCallbackFor(fType, self, loadCallback, endCallback);
switch (fType) {
case DomType::QmlDirectory: {
const auto &fetchResult = fetchFileFromEnvs<QmlDirectory>(file);
@@ -1205,10 +1204,8 @@ void DomEnvironment::loadFile(const FileToLoad &file, const Callback &loadCallba
newValue = fetchResult.second;
if (!newValue) {
const auto &loadRes = universe()->loadFile(file, fType, loadOptions);
- if (callback) {
- callback(Paths::qmlDirectoryInfoPath(file.canonicalPath()), loadRes.formerItem,
- loadRes.currentItem);
- }
+ addExternalItemInfo<QmlDirectory>(loadRes.currentItem,
+ getLoadCallbackFor(fType, loadCallback), endCallback);
return;
}
} break;
@@ -1218,10 +1215,8 @@ void DomEnvironment::loadFile(const FileToLoad &file, const Callback &loadCallba
newValue = fetchResult.second;
if (!newValue) {
const auto &loadRes = universe()->loadFile(file, fType, loadOptions);
- if (callback) {
- callback(Paths::qmlFileInfoPath(file.canonicalPath()), loadRes.formerItem,
- loadRes.currentItem);
- }
+ addExternalItemInfo<QmlFile>(loadRes.currentItem,
+ getLoadCallbackFor(fType, loadCallback), endCallback);
return;
}
} break;
@@ -1231,10 +1226,8 @@ void DomEnvironment::loadFile(const FileToLoad &file, const Callback &loadCallba
newValue = fetchResult.second;
if (!newValue) {
const auto &loadRes = universe()->loadFile(file, fType, loadOptions);
- if (callback) {
- callback(Paths::qmltypesFileInfoPath(file.canonicalPath()), loadRes.formerItem,
- loadRes.currentItem);
- }
+ addExternalItemInfo<QmltypesFile>(loadRes.currentItem,
+ getLoadCallbackFor(fType, loadCallback), endCallback);
return;
}
} break;
@@ -1244,19 +1237,15 @@ void DomEnvironment::loadFile(const FileToLoad &file, const Callback &loadCallba
newValue = fetchResult.second;
if (!newValue) {
const auto &loadRes = universe()->loadFile(file, fType, loadOptions);
- if (callback) {
- callback(Paths::qmldirFileInfoPath(file.canonicalPath()), loadRes.formerItem,
- loadRes.currentItem);
- }
+ addExternalItemInfo<QmldirFile>(loadRes.currentItem,
+ getLoadCallbackFor(fType, loadCallback), endCallback);
return;
}
} break;
case DomType::JsFile: {
const auto &loadRes = universe()->loadFile(file, fType, loadOptions);
- if (callback) {
- callback(Paths::jsFileInfoPath(file.canonicalPath()), loadRes.formerItem,
- loadRes.currentItem);
- }
+ addExternalItemInfo<JsFile>(loadRes.currentItem, getLoadCallbackFor(fType, loadCallback),
+ endCallback);
return;
} break;
default: {