forked from qt-creator/qt-creator
QmlJS: Add a UrlValue.
This will allow distinguishing mere strings from urls and allow different completion. Reviewed-by: Erik Verbruggen
This commit is contained in:
@@ -868,19 +868,20 @@ const Value *QmlObjectValue::propertyValue(const FakeMetaProperty &prop) const
|
||||
const Value *value = engine()->undefinedValue();
|
||||
if (typeName == QLatin1String("QByteArray")
|
||||
|| typeName == QLatin1String("string")
|
||||
|| typeName == QLatin1String("QString")
|
||||
|| typeName == QLatin1String("QUrl")) {
|
||||
|| typeName == QLatin1String("QString")) {
|
||||
value = engine()->stringValue();
|
||||
} else if (typeName == QLatin1String("QUrl")) {
|
||||
value = engine()->urlValue();
|
||||
} else if (typeName == QLatin1String("bool")) {
|
||||
value = engine()->booleanValue();
|
||||
} else if (typeName == QLatin1String("int")
|
||||
|| typeName == QLatin1String("long")) {
|
||||
value = engine()->intValue();
|
||||
value = engine()->intValue();
|
||||
} else if (typeName == QLatin1String("float")
|
||||
|| typeName == QLatin1String("double")
|
||||
|| typeName == QLatin1String("qreal")) {
|
||||
// ### Review: more types here?
|
||||
value = engine()->realValue();
|
||||
// ### Review: more types here?
|
||||
value = engine()->realValue();
|
||||
} else if (typeName == QLatin1String("QFont")) {
|
||||
value = engine()->qmlFontObject();
|
||||
} else if (typeName == QLatin1String("QPoint")
|
||||
@@ -1370,7 +1371,6 @@ const RealValue *Value::asRealValue() const
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
const BooleanValue *Value::asBooleanValue() const
|
||||
{
|
||||
return 0;
|
||||
@@ -1381,6 +1381,11 @@ const StringValue *Value::asStringValue() const
|
||||
return 0;
|
||||
}
|
||||
|
||||
const UrlValue *Value::asUrlValue() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
const ObjectValue *Value::asObjectValue() const
|
||||
{
|
||||
return 0;
|
||||
@@ -1437,7 +1442,6 @@ const NumberValue *NumberValue::asNumberValue() const
|
||||
const RealValue *RealValue::asRealValue() const
|
||||
{
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
const IntValue *IntValue::asIntValue() const
|
||||
@@ -1465,6 +1469,11 @@ const StringValue *StringValue::asStringValue() const
|
||||
return this;
|
||||
}
|
||||
|
||||
const UrlValue *UrlValue::asUrlValue() const
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
void StringValue::accept(ValueVisitor *visitor) const
|
||||
{
|
||||
visitor->visit(this);
|
||||
@@ -2597,6 +2606,7 @@ const RealValue *Engine::realValue() const
|
||||
{
|
||||
return &_realValue;
|
||||
}
|
||||
|
||||
const IntValue *Engine::intValue() const
|
||||
{
|
||||
return &_intValue;
|
||||
@@ -2612,6 +2622,11 @@ const StringValue *Engine::stringValue() const
|
||||
return &_stringValue;
|
||||
}
|
||||
|
||||
const UrlValue *Engine::urlValue() const
|
||||
{
|
||||
return &_urlValue;
|
||||
}
|
||||
|
||||
const ColorValue *Engine::colorValue() const
|
||||
{
|
||||
return &_colorValue;
|
||||
@@ -3147,12 +3162,16 @@ const ObjectValue *Engine::qmlVector3DObject()
|
||||
|
||||
const Value *Engine::defaultValueForBuiltinType(const QString &typeName) const
|
||||
{
|
||||
if (typeName == QLatin1String("string") || typeName == QLatin1String("url"))
|
||||
if (typeName == QLatin1String("string"))
|
||||
return stringValue();
|
||||
else if (typeName == QLatin1String("url"))
|
||||
return urlValue();
|
||||
else if (typeName == QLatin1String("bool"))
|
||||
return booleanValue();
|
||||
else if (typeName == QLatin1String("int") || typeName == QLatin1String("real"))
|
||||
return numberValue();
|
||||
else if (typeName == QLatin1String("int"))
|
||||
return intValue();
|
||||
else if (typeName == QLatin1String("real"))
|
||||
return realValue();
|
||||
else if (typeName == QLatin1String("color"))
|
||||
return colorValue();
|
||||
// ### more types...
|
||||
|
||||
@@ -61,6 +61,7 @@ class IntValue;
|
||||
class RealValue;
|
||||
class BooleanValue;
|
||||
class StringValue;
|
||||
class UrlValue;
|
||||
class ObjectValue;
|
||||
class FunctionValue;
|
||||
class Reference;
|
||||
@@ -115,6 +116,7 @@ public:
|
||||
virtual const RealValue *asRealValue() const;
|
||||
virtual const BooleanValue *asBooleanValue() const;
|
||||
virtual const StringValue *asStringValue() const;
|
||||
virtual const UrlValue *asUrlValue() const;
|
||||
virtual const ObjectValue *asObjectValue() const;
|
||||
virtual const FunctionValue *asFunctionValue() const;
|
||||
virtual const Reference *asReference() const;
|
||||
@@ -170,6 +172,12 @@ template <> Q_INLINE_TEMPLATE const StringValue *value_cast(const Value *v)
|
||||
else return 0;
|
||||
}
|
||||
|
||||
template <> Q_INLINE_TEMPLATE const UrlValue *value_cast(const Value *v)
|
||||
{
|
||||
if (v) return v->asUrlValue();
|
||||
else return 0;
|
||||
}
|
||||
|
||||
template <> Q_INLINE_TEMPLATE const ObjectValue *value_cast(const Value *v)
|
||||
{
|
||||
if (v) return v->asObjectValue();
|
||||
@@ -236,7 +244,6 @@ public:
|
||||
virtual const IntValue *asIntValue() const;
|
||||
};
|
||||
|
||||
|
||||
class QMLJS_EXPORT BooleanValue: public Value
|
||||
{
|
||||
public:
|
||||
@@ -251,6 +258,12 @@ public:
|
||||
virtual void accept(ValueVisitor *visitor) const;
|
||||
};
|
||||
|
||||
class QMLJS_EXPORT UrlValue: public StringValue
|
||||
{
|
||||
public:
|
||||
virtual const UrlValue *asUrlValue() const;
|
||||
};
|
||||
|
||||
class QMLJS_EXPORT MemberProcessor
|
||||
{
|
||||
MemberProcessor(const MemberProcessor &other);
|
||||
@@ -687,6 +700,7 @@ public:
|
||||
const IntValue *intValue() const;
|
||||
const BooleanValue *booleanValue() const;
|
||||
const StringValue *stringValue() const;
|
||||
const UrlValue *urlValue() const;
|
||||
const ColorValue *colorValue() const;
|
||||
const AnchorLineValue *anchorLineValue() const;
|
||||
|
||||
@@ -787,6 +801,7 @@ private:
|
||||
IntValue _intValue;
|
||||
BooleanValue _booleanValue;
|
||||
StringValue _stringValue;
|
||||
UrlValue _urlValue;
|
||||
ColorValue _colorValue;
|
||||
AnchorLineValue _anchorLineValue;
|
||||
QList<Value *> _registeredValues;
|
||||
|
||||
Reference in New Issue
Block a user