aboutsummaryrefslogtreecommitdiffstats
path: root/tools/shared/scopetree.h
diff options
context:
space:
mode:
Diffstat (limited to 'tools/shared/scopetree.h')
-rw-r--r--tools/shared/scopetree.h31
1 files changed, 17 insertions, 14 deletions
diff --git a/tools/shared/scopetree.h b/tools/shared/scopetree.h
index 37eee26d16..b751815172 100644
--- a/tools/shared/scopetree.h
+++ b/tools/shared/scopetree.h
@@ -48,6 +48,8 @@
#include <QtCore/qstring.h>
#include <QtCore/qversionnumber.h>
+#include <optional>
+
enum class ScopeType
{
JSFunctionScope,
@@ -55,11 +57,17 @@ enum class ScopeType
QMLScope
};
-struct MethodUsage
+struct JavaScriptIdentifier
{
- MetaMethod method;
- QQmlJS::SourceLocation loc;
- bool hasMultilineHandlerBody;
+ enum Kind {
+ Parameter,
+ FunctionScoped,
+ LexicalScoped,
+ Injected
+ };
+
+ Kind kind = FunctionScoped;
+ QQmlJS::SourceLocation location;
};
class ScopeTree
@@ -115,9 +123,8 @@ public:
ScopeTree::Ptr parentScope() const { return m_parentScope.toStrongRef(); }
- void insertJSIdentifier(const QString &id, ScopeType scope);
- void insertSignalIdentifier(const QString &id, const MetaMethod &method,
- const QQmlJS::SourceLocation &loc, bool hasMultilineHandlerBody);
+ void insertJSIdentifier(const QString &name, const JavaScriptIdentifier &identifier);
+
// inserts property as qml identifier as well as the corresponding
void insertPropertyIdentifier(const MetaProperty &prop);
void addUnmatchedSignalHandler(const QString &handler,
@@ -196,23 +203,19 @@ public:
bool isIdInCurrentJSScopes(const QString &id) const;
bool isIdInjectedFromSignal(const QString &id) const;
+ std::optional<JavaScriptIdentifier> findJSIdentifier(const QString &id) const;
+
QVector<ScopeTree::Ptr> childScopes() const
{
return m_childScopes;
}
- QMultiHash<QString, MethodUsage> injectedSignalIdentifiers() const
- {
- return m_injectedSignalIdentifiers;
- }
-
void resolveTypes(const QHash<QString, ConstPtr> &contextualTypes);
private:
ScopeTree(ScopeType type, const ScopeTree::Ptr &parentScope = ScopeTree::Ptr());
- QSet<QString> m_jsIdentifiers;
- QMultiHash<QString, MethodUsage> m_injectedSignalIdentifiers;
+ QHash<QString, JavaScriptIdentifier> m_jsIdentifiers;
QMultiHash<QString, MetaMethod> m_methods;
QHash<QString, MetaProperty> m_properties;