forked from qt-creator/qt-creator
QmlJS: Extending QmlJSSimpleReader
With this patch bindings are parsed as strings. Change-Id: I92014052947c595b220640d827dd77ee2db8f655 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -127,6 +127,8 @@ bool SimpleAbstractStreamReader::readFromSource(const QString &source)
|
||||
m_errors.clear();
|
||||
m_currentSourceLocation = AST::SourceLocation();
|
||||
|
||||
m_source = source;
|
||||
|
||||
Engine engine;
|
||||
Lexer lexer(&engine);
|
||||
Parser parser(&engine);
|
||||
@@ -176,6 +178,8 @@ bool SimpleAbstractStreamReader::readDocument(AST::UiProgram *ast)
|
||||
}
|
||||
readChild(uiObjectDefinition);
|
||||
|
||||
m_source.clear();
|
||||
|
||||
return errors().isEmpty();
|
||||
}
|
||||
|
||||
@@ -271,8 +275,7 @@ QVariant SimpleAbstractStreamReader::parsePropertyExpression(AST::ExpressionNode
|
||||
if (numericLiteral)
|
||||
return numericLiteral->value;
|
||||
|
||||
addError(tr("Expected expression statement to be a literal."), expressionNode->firstSourceLocation());
|
||||
return QVariant();
|
||||
return textAt(expressionNode->firstSourceLocation(), expressionNode->lastSourceLocation());
|
||||
}
|
||||
|
||||
void SimpleAbstractStreamReader::setSourceLocation(const AST::SourceLocation &sourceLocation)
|
||||
@@ -280,6 +283,12 @@ void SimpleAbstractStreamReader::setSourceLocation(const AST::SourceLocation &so
|
||||
m_currentSourceLocation = sourceLocation;
|
||||
}
|
||||
|
||||
QString SimpleAbstractStreamReader::textAt(const AST::SourceLocation &from,
|
||||
const AST::SourceLocation &to)
|
||||
{
|
||||
return m_source.mid(from.offset, to.end() - from.begin());
|
||||
}
|
||||
|
||||
SimpleReader::SimpleReader()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -101,9 +101,11 @@ private:
|
||||
QVariant parsePropertyScriptBinding(AST::UiScriptBinding *ExpressionNode);
|
||||
QVariant parsePropertyExpression(AST::ExpressionNode *expressionNode);
|
||||
void setSourceLocation(const AST::SourceLocation &sourceLocation);
|
||||
QString textAt(const AST::SourceLocation &from, const AST::SourceLocation &to);
|
||||
|
||||
QStringList m_errors;
|
||||
AST::SourceLocation m_currentSourceLocation;
|
||||
QString m_source;
|
||||
};
|
||||
|
||||
class QMLJS_EXPORT SimpleReader: public SimpleAbstractStreamReader
|
||||
|
||||
Reference in New Issue
Block a user