forked from qt-creator/qt-creator
Qml&Js: properties/methods/enums inspection
.. of builtIn qml and cpp code over "Inspect API For Element Under Cursor" action. Change-Id: I70d5bec2933b682295c5242248a2b0f95dba4e76 Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
This commit is contained in:
@@ -137,40 +137,37 @@ public:
|
||||
} // end of anonymous namespace
|
||||
|
||||
namespace QmlJS {
|
||||
namespace Internal {
|
||||
class MetaFunction: public FunctionValue
|
||||
|
||||
MetaFunction::MetaFunction(const FakeMetaMethod &method, ValueOwner *valueOwner)
|
||||
: FunctionValue(valueOwner), m_method(method)
|
||||
{
|
||||
FakeMetaMethod m_method;
|
||||
}
|
||||
|
||||
public:
|
||||
MetaFunction(const FakeMetaMethod &method, ValueOwner *valueOwner)
|
||||
: FunctionValue(valueOwner), m_method(method)
|
||||
{
|
||||
}
|
||||
int MetaFunction::namedArgumentCount() const
|
||||
{
|
||||
return m_method.parameterNames().size();
|
||||
}
|
||||
|
||||
virtual int namedArgumentCount() const
|
||||
{
|
||||
return m_method.parameterNames().size();
|
||||
}
|
||||
QString MetaFunction::argumentName(int index) const
|
||||
{
|
||||
if (index < m_method.parameterNames().size())
|
||||
return m_method.parameterNames().at(index);
|
||||
|
||||
virtual QString argumentName(int index) const
|
||||
{
|
||||
if (index < m_method.parameterNames().size())
|
||||
return m_method.parameterNames().at(index);
|
||||
return FunctionValue::argumentName(index);
|
||||
}
|
||||
|
||||
return FunctionValue::argumentName(index);
|
||||
}
|
||||
|
||||
virtual bool isVariadic() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
const MetaFunction *asMetaFunction() const
|
||||
{
|
||||
return this;
|
||||
}
|
||||
};
|
||||
} // namespace Internal
|
||||
bool MetaFunction::isVariadic() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
const MetaFunction *MetaFunction::asMetaFunction() const
|
||||
{
|
||||
return this;
|
||||
}
|
||||
const FakeMetaMethod &MetaFunction::fakeMetaMethod() const
|
||||
{
|
||||
return m_method;
|
||||
}
|
||||
|
||||
FakeMetaObjectWithOrigin::FakeMetaObjectWithOrigin(FakeMetaObject::ConstPtr fakeMetaObject, const QString &originId)
|
||||
: fakeMetaObject(fakeMetaObject)
|
||||
@@ -293,7 +290,7 @@ void CppComponentValue::processMembers(MemberProcessor *processor) const
|
||||
signatures = new QList<const Value *>;
|
||||
signatures->reserve(m_metaObject->methodCount());
|
||||
for (int index = 0; index < m_metaObject->methodCount(); ++index)
|
||||
signatures->append(new Internal::MetaFunction(m_metaObject->method(index), valueOwner()));
|
||||
signatures->append(new MetaFunction(m_metaObject->method(index), valueOwner()));
|
||||
if (!m_metaSignatures.testAndSetOrdered(0, signatures)) {
|
||||
delete signatures;
|
||||
signatures = m_metaSignatures.load();
|
||||
@@ -830,7 +827,7 @@ const Function *Value::asFunction() const
|
||||
return 0;
|
||||
}
|
||||
|
||||
const Internal::MetaFunction *Value::asMetaFunction() const
|
||||
const MetaFunction *Value::asMetaFunction() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -83,10 +83,10 @@ class UnknownValue;
|
||||
class UrlValue;
|
||||
class Value;
|
||||
class ValueOwner;
|
||||
class MetaFunction;
|
||||
typedef QSharedPointer<const Context> ContextPtr;
|
||||
|
||||
namespace Internal {
|
||||
class MetaFunction;
|
||||
class QtObjectPrototypeReference;
|
||||
} // namespace Internal
|
||||
|
||||
@@ -150,7 +150,7 @@ public:
|
||||
virtual const ASTSignal *asAstSignal() const;
|
||||
virtual const ASTFunctionValue *asAstFunctionValue() const;
|
||||
virtual const Function *asFunction() const;
|
||||
virtual const Internal::MetaFunction *asMetaFunction() const;
|
||||
virtual const MetaFunction *asMetaFunction() const;
|
||||
virtual const JSImportScope *asJSImportScope() const;
|
||||
virtual const TypeScope *asTypeScope() const;
|
||||
|
||||
@@ -304,7 +304,7 @@ template <> Q_INLINE_TEMPLATE const Function *value_cast(const Value *v)
|
||||
else return 0;
|
||||
}
|
||||
|
||||
template <> Q_INLINE_TEMPLATE const Internal::MetaFunction*value_cast(const Value *v)
|
||||
template <> Q_INLINE_TEMPLATE const MetaFunction *value_cast(const Value *v)
|
||||
{
|
||||
if (v) return v->asMetaFunction();
|
||||
else return 0;
|
||||
@@ -1110,6 +1110,20 @@ private:
|
||||
bool m_importFailed;
|
||||
};
|
||||
|
||||
class QMLJS_EXPORT MetaFunction: public FunctionValue
|
||||
{
|
||||
LanguageUtils::FakeMetaMethod m_method;
|
||||
|
||||
public:
|
||||
MetaFunction(const LanguageUtils::FakeMetaMethod &method, ValueOwner *valueOwner);
|
||||
|
||||
int namedArgumentCount() const override;
|
||||
QString argumentName(int index) const override;
|
||||
bool isVariadic() const override;
|
||||
const MetaFunction *asMetaFunction() const override;
|
||||
const LanguageUtils::FakeMetaMethod &fakeMetaMethod() const;
|
||||
};
|
||||
|
||||
} // namespace QmlJS
|
||||
|
||||
#endif // QMLJS_INTERPRETER_H
|
||||
|
||||
Reference in New Issue
Block a user