tooling: add automatic QMLLS support for new imports and singletons

This commit is contained in:
outfoxxed 2025-07-16 14:35:46 -07:00
parent 4d8055f1cd
commit 986749cdb9
No known key found for this signature in database
GPG key ID: 4C88A185FB89301E
7 changed files with 283 additions and 3 deletions

View file

@ -4,6 +4,7 @@
#include <qdir.h>
#include <qfileinfo.h>
#include <qfilesystemwatcher.h>
#include <qlogging.h>
#include <qobject.h>
#include <qqmlcomponent.h>
@ -18,15 +19,26 @@
#include "instanceinfo.hpp"
#include "qmlglobal.hpp"
#include "scan.hpp"
#include "toolsupport.hpp"
RootWrapper::RootWrapper(QString rootPath, QString shellId)
: QObject(nullptr)
, rootPath(std::move(rootPath))
, shellId(std::move(shellId))
, originalWorkingDirectory(QDir::current().absolutePath()) {
// clang-format off
QObject::connect(QuickshellSettings::instance(), &QuickshellSettings::watchFilesChanged, this, &RootWrapper::onWatchFilesChanged);
// clang-format on
QObject::connect(
QuickshellSettings::instance(),
&QuickshellSettings::watchFilesChanged,
this,
&RootWrapper::onWatchFilesChanged
);
QObject::connect(
&this->configDirWatcher,
&QFileSystemWatcher::directoryChanged,
this,
&RootWrapper::updateTooling
);
this->reloadGraph(true);
@ -48,6 +60,9 @@ void RootWrapper::reloadGraph(bool hard) {
auto scanner = QmlScanner(rootPath);
scanner.scanQmlFile(this->rootPath);
qs::core::QmlToolingSupport::updateTooling(rootPath, scanner);
this->configDirWatcher.addPath(rootPath.path());
auto* generation = new EngineGeneration(rootPath, std::move(scanner));
generation->wrapper = this;
@ -168,3 +183,9 @@ void RootWrapper::onWatchFilesChanged() {
}
void RootWrapper::onWatchedFilesChanged() { this->reloadGraph(false); }
void RootWrapper::updateTooling() {
if (!this->generation) return;
auto configDir = QFileInfo(this->rootPath).dir();
qs::core::QmlToolingSupport::updateTooling(configDir, this->generation->scanner);
}