aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlcompiler/qqmljsscope.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qmlcompiler/qqmljsscope.cpp')
-rw-r--r--src/qmlcompiler/qqmljsscope.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/qmlcompiler/qqmljsscope.cpp b/src/qmlcompiler/qqmljsscope.cpp
index 5b23b247b3..ded18e8163 100644
--- a/src/qmlcompiler/qqmljsscope.cpp
+++ b/src/qmlcompiler/qqmljsscope.cpp
@@ -40,6 +40,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
/*! \internal
Utility method that returns proper value according to the type To. This
@@ -246,6 +248,27 @@ QHash<QString, QQmlJSMetaEnum> QQmlJSScope::enumerations() const
return results;
}
+QString QQmlJSScope::prettyName(QAnyStringView name)
+{
+ const auto internal = "$internal$."_L1;
+ const QString anonymous = "$anonymous$."_L1;
+
+ QString pretty = name.toString();
+
+ if (pretty.startsWith(internal))
+ pretty = pretty.mid(internal.size());
+ else if (pretty.startsWith(anonymous))
+ pretty = pretty.mid(anonymous.size());
+
+ if (pretty == u"std::nullptr_t")
+ return u"null"_s;
+
+ if (pretty == u"void")
+ return u"undefined"_s;
+
+ return pretty;
+}
+
/*!
Returns if assigning \a assignedType to \a property would require an
implicit component wrapping.