Commit Graph

9 Commits

Author SHA1 Message Date
Maximilian Goldstein 324b625f9f Turn the QtQuick qmllint plugin into a proper shared library
Previously it was just a static library that we linked qmllint against
now it's properly installed in the qmllint plugins folder and can be
utilized in the language server as well.

Fixes: QTBUG-102278
Change-Id: I4aec42d1e2ba113237ee5ba148085e69b7251506
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-04-11 14:12:09 +02:00
Maximilian Goldstein 7c9276d38b qmllint: Integrate plugin infrastructure
Integrates the plugin and pass infrastructure into qmlcompiler and qmllint proper.
Plugins are searched for in the "qmllint" subfolder of the Qt installation's plugin
directory. In addition we also support loading statically linked plugins.

[ChangeLog][qmllint][New Feature] qmllint can now be extended via plugins. Use --plugins
to get a list of available plugins.

Original-patch-by: Fabian Kosmale <fabian.kosmale@qt.io>
Change-Id: I75a09dd978fc7724aca4931f055cc71c7ced971b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-04-05 14:06:56 +02:00
Ulf Hermann aea732d607 Avoid copying QQmlJSScope
The factory should populate the pre-existing scope rather than copy it
into place. This way we can detect inheritance cycles involving the
pre-existing scope.

However, now we may detect the inheritance cycles earlier, when
resolving the types inside the lazy loading. We have the right pointers
available there now, after all. Therefore, add a way to propagate base
type errors out of the factory. When clearing the base type, we can now
give a reason for that. When checking the inheritance cycles we
retrieve that reason and log it.

We also remove the special casing of the ScopeType property of
QQmlJSScope. There is no real reason to set it in the ctor. As we
delay the population of QQmlJSScope now, we have to set it later.

Pick-to: 6.2 6.3
Task-number: QTBUG-102153
Change-Id: I49cf6e20f59fbdb6ed98a82040b3b159676f5975
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-04-04 09:09:49 +02:00
Maximilian Goldstein 0092c27580 qmllint: Represent fix suggestion filename in JSON
Previously this information didn't get exposed in the JSON interface.
Now if a file other than the one the message belongs to has a fix
suggestion it will be properly represented in JSON.

Change-Id: I48f0f555dadd471ccfc58a5c9627c52f28b5e112
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-03-24 19:38:12 +01:00
Maximilian Goldstein a398e06c61 qmllint: Support automatically applying suggestions
We now support automatically applying fix suggestions that don't
need any additional user input. This allows us to automatically
solve issues such as unqualified access and multiline strings.

[ChangeLog][qmllint][New Feature] Added the ability to automatically
fix some warnings, use -f to automatically fix your files or add
--dry-run to see what changes would be made first.

Change-Id: I2dc7587137d74267f60c08bb94a035f1a85a62b1
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-03-14 09:43:15 +01:00
Maximilian Goldstein 195af3ce69 qmlcompiler: Allow for logging other files and add auto-fix infrastructure
This change makes sure the logger can write messages and show excerpts
from files other than the current one. This is necessary in order to
give users hints about problems that arise due to other components.

It also adds a field to FixSuggestion::Fix which specifies whether a
suggested fix can be applied automatically or is only a hint.

Change-Id: I94a929d3fc3fc966591cffb99e67309d264c38e7
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-03-03 11:19:51 +01:00
Maximilian Goldstein 2ea887cca0 qmldir: Allow for specifying default imports
Adds the option to specify default optional imports in qmldir for
tooling to load. Previously we would just load all entries.

This allows code that that relies on modules utilizing optional imports
(i.e. everything utilizing QtQuick.Controls) to still be supported in a
limited capacity.

This change also adds the necessary CMake API to add these entries to
qmldir files. It also disables loading optional imports by default
and only leaves them enabled for qmllint.

Change-Id: Iff6aaac9cb0ec72b7a2853b60840a4d28c84aa25
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-02-14 12:38:10 +01:00
Andrei Golubev 690b7cb6a2 Redesign QQmlJSLogger internals
High-level goal: be able to reuse existing infrastructure
"as is" to configure semantic analysis categories in tools
(qmllint, qmltc, qmlsc, etc.)

To achieve that, simplify the logging to always "log"
something, without explicitly specifying the severity. The
severity is now baked into the category (and we can extend
those to cover different cases)

One slight deviation is the cache generation which likes
to do its own thing at present. Provide a "forced logging"
option where we can specify which severify we want. The
hope is that this gets removed at some point

Particular list of (noteworthy) changes:
* No more "thresholding" by the level (this is rarely needed
  and is actually questionable). Instead, we can ignore a
  particular category explicitly
* Category levels are repurposed as category severities
  (at least from the high-level picture that always should've
  been this way)
* log{Warning,Info,Critical} removed. We use category severity
  instead
* "category error" makes zero sense so removed: if our severity
  is:
  - QtWarningMsg (qmllint), it is already an "error"
  - QtCriticalMsg (compilers), it is already an "error"
* Align m_output and m_{infos,warnings,errors} stored information
* Accept the fact that we don't support QtDebugMsg and QtFatalMsg
* Additional categories added to cover for places where the same
  category would be both an error and not an error

Task-number: QTBUG-100052
Change-Id: I3cd5d17d58be204f48428877bed053f756ac40a8
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-02-12 23:21:29 +01:00
Maximilian Goldstein 07917626f5 qmlcompiler: Remove qmllint library
Since all of the superfluous components of qmllint have been
removed now, we can just move what little custom linter logic
remains to qmlcompiler.

Change-Id: I91c752cb895e7d6c6f2dd4e2ccafb6cd05afa225
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-03 22:55:53 +01:00