diff options
author | Sami Shalayel <sami.shalayel@qt.io> | 2024-04-10 14:30:32 +0200 |
---|---|---|
committer | Sami Shalayel <sami.shalayel@qt.io> | 2024-04-18 11:39:16 +0200 |
commit | 1bef3c4d0db67bd9dcfc7289b6322649af980c22 (patch) | |
tree | 6a1231078a137020cabf0add5e1767fe0451ee23 /src/qmlls/qqmlcodemodel_p.h | |
parent | 547de2d4e5d5619e5d37b91ad534f9260492e339 (diff) |
qmlls: add -I and -E option
Add a -I option that specifies additional import paths used to find QML
modules.
Add a -E option that searches QML modules in the import paths specified
by the environment variables QML_IMPORT_PATH.
Add an import path field to QQmlCodeModel with setters and getters
that may now consist of more than just
`QLibraryInfo::path(QLibraryInfo::QmlImportsPath)`.
Extract some common code used to read, check and inform about directories
used from environment variables or command line options into static
methods. This would allow other tooling, like qmllint, to print the same
warnings when using environment variables, for example.
Add a new test tst_qmlls_cli that allows to test qmlls behavior
when fed with different combinations of -I, -E and -b (for build
directories) options. The test also enables checking that warnings are
correctly emitted and that import paths are correctly used during
linting via qmlls.
Note that the warnings emitted by qmlls when using -b were
enhanced, partially due to the refactoring of the static helpers to read
directory names from environment and command line options. Also note
that qmlls was informing twice about possibly using .qmlls.ini files
before this commit, so also remove the redundant warning.
Task-number: QTBUG-114969
Change-Id: I102ca8b50299f277746c5bba6832551a76898fc0
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qmlls/qqmlcodemodel_p.h')
-rw-r--r-- | src/qmlls/qqmlcodemodel_p.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/qmlls/qqmlcodemodel_p.h b/src/qmlls/qqmlcodemodel_p.h index 1be4ca13d2..8e2be96ef6 100644 --- a/src/qmlls/qqmlcodemodel_p.h +++ b/src/qmlls/qqmlcodemodel_p.h @@ -101,6 +101,8 @@ public: QStringList buildPathsForRootUrl(const QByteArray &url); QStringList buildPathsForFileUrl(const QByteArray &url); void setBuildPathsForRootUrl(QByteArray url, const QStringList &paths); + QStringList importPaths() const { return m_importPaths; }; + void setImportPaths(const QStringList &paths) { m_importPaths = paths; }; void removeRootUrls(const QList<QByteArray> &urls); QQmlToolingSettings *settings(); QStringList findFilePathsFromFileNames(const QStringList &fileNames) const; @@ -136,6 +138,7 @@ private: int m_indexInProgressCost = 0; int m_indexDoneCost = 0; int m_nUpdateInProgress = 0; + QStringList m_importPaths; QQmlJS::Dom::DomItem m_currentEnv; QQmlJS::Dom::DomItem m_validEnv; QByteArray m_lastOpenDocumentUpdated; |