Expose defining scope finders in QQmlLSUtils

These functions are used to find the base scope for a given identifier
name and the current scope. They are useful for documentation hints to get
the correct documentation for a given name.

Pick-to: 6.8
Task-number: QTBUG-120016
Change-Id: I575604d09eab067b2af2209dedb4cb13f477c42d
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
This commit is contained in:
Semih Yavuz 2024-06-04 15:08:40 +02:00
parent c72c79ffa3
commit 229803961d
2 changed files with 22 additions and 10 deletions

View File

@ -734,8 +734,8 @@ QQmlJSScope::ConstPtr findDefiningScopeIf(
Starts looking for the name starting from the given scope and traverse through base and
extension types.
*/
static QQmlJSScope::ConstPtr findDefiningScopeForProperty(
const QQmlJSScope::ConstPtr &referrerScope, const QString &nameToCheck)
QQmlJSScope::ConstPtr findDefiningScopeForProperty(QQmlJSScope::ConstPtr referrerScope,
const QString &nameToCheck)
{
return findDefiningScopeIf(referrerScope, [&nameToCheck](const QQmlJSScope::ConstPtr &scope) {
return scope->hasOwnProperty(nameToCheck);
@ -748,8 +748,8 @@ See also findDefiningScopeForProperty().
Special case: you can also bind to a signal handler.
*/
static QQmlJSScope::ConstPtr findDefiningScopeForBinding(
const QQmlJSScope::ConstPtr &referrerScope, const QString &nameToCheck)
QQmlJSScope::ConstPtr findDefiningScopeForBinding(QQmlJSScope::ConstPtr referrerScope,
const QString &nameToCheck)
{
return findDefiningScopeIf(referrerScope, [&nameToCheck](const QQmlJSScope::ConstPtr &scope) {
return scope->hasOwnProperty(nameToCheck) || scope->hasOwnMethod(nameToCheck);
@ -760,8 +760,8 @@ static QQmlJSScope::ConstPtr findDefiningScopeForBinding(
\internal
See also findDefiningScopeForProperty().
*/
static QQmlJSScope::ConstPtr findDefiningScopeForMethod(
const QQmlJSScope::ConstPtr &referrerScope, const QString &nameToCheck)
QQmlJSScope::ConstPtr findDefiningScopeForMethod(QQmlJSScope::ConstPtr referrerScope,
const QString &nameToCheck)
{
return findDefiningScopeIf(referrerScope, [&nameToCheck](const QQmlJSScope::ConstPtr &scope) {
return scope->hasOwnMethod(nameToCheck);
@ -772,8 +772,8 @@ static QQmlJSScope::ConstPtr findDefiningScopeForMethod(
\internal
See also findDefiningScopeForProperty().
*/
static QQmlJSScope::ConstPtr findDefiningScopeForEnumeration(
const QQmlJSScope::ConstPtr &referrerScope, const QString &nameToCheck)
QQmlJSScope::ConstPtr findDefiningScopeForEnumeration(QQmlJSScope::ConstPtr referrerScope,
const QString &nameToCheck)
{
return findDefiningScopeIf(referrerScope, [&nameToCheck](const QQmlJSScope::ConstPtr &scope) {
return scope->hasOwnEnumeration(nameToCheck);
@ -784,8 +784,8 @@ static QQmlJSScope::ConstPtr findDefiningScopeForEnumeration(
\internal
See also findDefiningScopeForProperty().
*/
static QQmlJSScope::ConstPtr findDefiningScopeForEnumerationKey(
const QQmlJSScope::ConstPtr &referrerScope, const QString &nameToCheck)
QQmlJSScope::ConstPtr findDefiningScopeForEnumerationKey(QQmlJSScope::ConstPtr referrerScope,
const QString &nameToCheck)
{
return findDefiningScopeIf(referrerScope, [&nameToCheck](const QQmlJSScope::ConstPtr &scope) {
return scope->hasOwnEnumerationKey(nameToCheck);

View File

@ -259,7 +259,19 @@ bool isFieldMemberAccess(const DomItem &item);
QStringList fieldMemberExpressionBits(const DomItem &item, const DomItem &stopAtChild = {});
QString qualifiersFrom(const DomItem &el);
QQmlJSScope::ConstPtr findDefiningScopeForProperty(QQmlJSScope::ConstPtr referrerScope,
const QString &nameToCheck);
QQmlJSScope::ConstPtr findDefiningScopeForBinding(QQmlJSScope::ConstPtr referrerScope,
const QString &nameToCheck);
QQmlJSScope::ConstPtr findDefiningScopeForMethod(QQmlJSScope::ConstPtr referrerScope,
const QString &nameToCheck);
QQmlJSScope::ConstPtr findDefiningScopeForEnumeration(QQmlJSScope::ConstPtr referrerScope,
const QString &nameToCheck);
QQmlJSScope::ConstPtr findDefiningScopeForEnumerationKey(QQmlJSScope::ConstPtr referrerScope,
const QString &nameToCheck);
} // namespace QQmlLSUtils
QT_END_NAMESPACE
#endif // QLANGUAGESERVERUTILS_P_H