summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorChristian Kamm <christian.d.kamm@nokia.com>2011-09-13 09:57:24 +0200
committerChristian Kamm <christian.d.kamm@nokia.com>2011-09-14 11:48:22 +0200
commit4b2f42cf8742d281bd107637044dd0e74bfa4224 (patch)
tree8ea8056c37aee5aa500aa79c702e0d9e4306f027 /src/plugins
parentb5312090028a338ac3f945f8692cadde7eb2172b (diff)
downloadqt-creator-4b2f42cf8742d281bd107637044dd0e74bfa4224.tar.gz
QmlJS: Adjust existing code for updated QML parser.
Change-Id: I153723eeb9973be025daf47e317f7b9d076a3c72 Reviewed-on: http://codereview.qt-project.org/4733 Reviewed-by: Thomas Hartmann <Thomas.Hartmann@nokia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/qmldesigner/designercore/filemanager/changeimportsvisitor.cpp2
-rw-r--r--src/plugins/qmldesigner/designercore/filemanager/changepropertyvisitor.cpp2
-rw-r--r--src/plugins/qmldesigner/designercore/filemanager/qmlrewriter.cpp2
-rw-r--r--src/plugins/qmldesigner/designercore/filemanager/removepropertyvisitor.cpp2
-rw-r--r--src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp4
-rw-r--r--src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp44
-rw-r--r--src/plugins/qmljseditor/qmljscompletionassist.cpp4
-rw-r--r--src/plugins/qmljseditor/qmljscomponentfromobjectdef.cpp10
-rw-r--r--src/plugins/qmljseditor/qmljseditor.cpp42
-rw-r--r--src/plugins/qmljseditor/qmljsfindreferences.cpp49
-rw-r--r--src/plugins/qmljseditor/qmljshoverhandler.cpp20
-rw-r--r--src/plugins/qmljseditor/qmljssemantichighlighter.cpp18
-rw-r--r--src/plugins/qmljseditor/qmloutlinemodel.cpp15
-rw-r--r--src/plugins/qmljseditor/quicktoolbar.cpp10
-rw-r--r--src/plugins/qmljsinspector/qmljslivetextpreview.cpp4
-rw-r--r--src/plugins/qmljstools/qmljslocatordata.cpp16
-rwxr-xr-xsrc/plugins/qttest/testcode.cpp4
17 files changed, 123 insertions, 125 deletions
diff --git a/src/plugins/qmldesigner/designercore/filemanager/changeimportsvisitor.cpp b/src/plugins/qmldesigner/designercore/filemanager/changeimportsvisitor.cpp
index 288fef94f1..b3bf51829f 100644
--- a/src/plugins/qmldesigner/designercore/filemanager/changeimportsvisitor.cpp
+++ b/src/plugins/qmldesigner/designercore/filemanager/changeimportsvisitor.cpp
@@ -99,7 +99,7 @@ bool ChangeImportsVisitor::equals(QmlJS::AST::UiImport *ast, const Import &impor
if (import.isLibraryImport()) {
return flatten(ast->importUri) == import.url();
} else if (import.isFileImport()) {
- return ast->fileName->asString() == import.file();
+ return ast->fileName == import.file();
} else {
return false;
}
diff --git a/src/plugins/qmldesigner/designercore/filemanager/changepropertyvisitor.cpp b/src/plugins/qmldesigner/designercore/filemanager/changepropertyvisitor.cpp
index 460e49d553..85bfb739bd 100644
--- a/src/plugins/qmldesigner/designercore/filemanager/changepropertyvisitor.cpp
+++ b/src/plugins/qmldesigner/designercore/filemanager/changepropertyvisitor.cpp
@@ -182,7 +182,7 @@ bool ChangePropertyVisitor::isMatchingPropertyMember(const QString &propName,
} else if (UiArrayBinding *arrayBinding = AST::cast<UiArrayBinding *>(member)) {
return propName == flatten(arrayBinding->qualifiedId);
} else if (UiPublicMember *publicMember = AST::cast<UiPublicMember *>(member)) {
- return propName == publicMember->name->asString();
+ return propName == publicMember->name;
} else {
return false;
}
diff --git a/src/plugins/qmldesigner/designercore/filemanager/qmlrewriter.cpp b/src/plugins/qmldesigner/designercore/filemanager/qmlrewriter.cpp
index 5862e1be2c..ca169c67dd 100644
--- a/src/plugins/qmldesigner/designercore/filemanager/qmlrewriter.cpp
+++ b/src/plugins/qmldesigner/designercore/filemanager/qmlrewriter.cpp
@@ -207,7 +207,7 @@ QString QMLRewriter::flatten(UiQualifiedId *first)
if (current != first)
flatId += '.';
- flatId += current->name->asString();
+ flatId += current->name;
}
return flatId;
diff --git a/src/plugins/qmldesigner/designercore/filemanager/removepropertyvisitor.cpp b/src/plugins/qmldesigner/designercore/filemanager/removepropertyvisitor.cpp
index f009f05c4a..e21664a566 100644
--- a/src/plugins/qmldesigner/designercore/filemanager/removepropertyvisitor.cpp
+++ b/src/plugins/qmldesigner/designercore/filemanager/removepropertyvisitor.cpp
@@ -145,7 +145,7 @@ void RemovePropertyVisitor::removeMember(UiObjectMember *member)
bool RemovePropertyVisitor::memberNameMatchesPropertyName(const QString &propertyName, UiObjectMember *ast)
{
if (UiPublicMember *publicMember = cast<UiPublicMember*>(ast))
- return publicMember->name->asString() == propertyName;
+ return publicMember->name == propertyName;
else if (UiObjectBinding *objectBinding = cast<UiObjectBinding*>(ast))
return flatten(objectBinding->qualifiedId) == propertyName;
else if (UiScriptBinding *scriptBinding = cast<UiScriptBinding*>(ast))
diff --git a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp
index eabd0bb5c4..5afb1a343e 100644
--- a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp
+++ b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp
@@ -99,8 +99,8 @@ public:
const ASTPropertyReference *ref = dynamic_cast<const ASTPropertyReference*>(value);
if (ref) {
QString type = "unknown";
- if (ref->ast()->memberType)
- type = ref->ast()->memberType->asString();
+ if (!ref->ast()->memberType.isEmpty())
+ type = ref->ast()->memberType.toString();
m_properties.append(qMakePair(name, type));
} else {
if (const QmlObjectValue * ov = dynamic_cast<const QmlObjectValue *>(value)) {
diff --git a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp
index fa77d1f855..b636fd83ce 100644
--- a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp
+++ b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp
@@ -176,13 +176,13 @@ static QString flatten(UiQualifiedId *qualifiedId)
QString result;
for (UiQualifiedId *iter = qualifiedId; iter; iter = iter->next) {
- if (!iter->name)
+ if (iter->name.isEmpty())
continue;
if (!result.isEmpty())
result.append(QLatin1Char('.'));
- result.append(iter->name->asString());
+ result.append(iter->name);
}
return result;
@@ -369,13 +369,13 @@ public:
minorVersion = fixUpMinorVersionForQt(qmlValue->packageName(), qmlValue->version().minorVersion());
} else {
for (UiQualifiedId *iter = astTypeNode; iter; iter = iter->next)
- if (!iter->next && iter->name)
- typeName = iter->name->asString();
+ if (!iter->next && !iter->name.isEmpty())
+ typeName = iter->name.toString();
QString fullTypeName;
for (UiQualifiedId *iter = astTypeNode; iter; iter = iter->next)
- if (iter->name)
- fullTypeName += iter->name->asString() + ".";
+ if (!iter->name.isEmpty())
+ fullTypeName += iter->name.toString() + ".";
if (fullTypeName.endsWith("."))
fullTypeName.chop(1);
@@ -413,12 +413,12 @@ public:
if (! id)
return false; // ### error?
- if (! id->name) // possible after error recovery
+ if (id->name.isEmpty()) // possible after error recovery
return false;
QString propertyName;
if (prefix.isEmpty())
- propertyName = id->name->asString();
+ propertyName = id->name.toString();
else
propertyName = prefix;
@@ -478,13 +478,13 @@ public:
if (parentObject)
*parentObject = objectValue;
- if (! idPart->name) {
+ if (idPart->name.isEmpty()) {
// somebody typed "id." and error recovery still gave us a valid tree,
// so just bail out here.
return false;
}
- propertyName = idPart->name->asString();
+ propertyName = idPart->name.toString();
if (name)
*name = propertyName;
@@ -595,15 +595,15 @@ public:
if (IdentifierExpression *idExp = cast<IdentifierExpression *>(eStmt->expression)) {
if (!m_scopeChain.qmlScopeObjects().isEmpty())
rhsValueObject = m_scopeChain.qmlScopeObjects().last();
- if (idExp->name)
- rhsValueName = idExp->name->asString();
+ if (!idExp->name.isEmpty())
+ rhsValueName = idExp->name.toString();
} else if (FieldMemberExpression *memberExp = cast<FieldMemberExpression *>(eStmt->expression)) {
Evaluate evaluate(&m_scopeChain);
const Value *result = evaluate(memberExp->base);
rhsValueObject = result->asObjectValue();
- if (memberExp->name)
- rhsValueName = memberExp->name->asString();
+ if (!memberExp->name.isEmpty())
+ rhsValueName = memberExp->name.toString();
}
if (rhsValueObject)
@@ -708,12 +708,10 @@ void TextToModelMerger::setupImports(const Document::Ptr &doc,
QString version;
if (import->versionToken.isValid())
version = textAt(doc, import->versionToken);
- QString as;
- if (import->importId)
- as = import->importId->asString();
+ const QString &as = import->importId.toString();
- if (import->fileName) {
- const QString strippedFileName = stripQuotes(import->fileName->asString());
+ if (!import->fileName.isEmpty()) {
+ const QString strippedFileName = stripQuotes(import->fileName.toString());
const Import newImport = Import::createFileImport(strippedFileName,
version, as, m_rewriterView->textModifier()->importPaths());
@@ -910,7 +908,7 @@ void TextToModelMerger::syncNode(ModelNode &modelNode,
<< "for node type" << modelNode.type();
}
} else if (UiObjectDefinition *def = cast<UiObjectDefinition *>(member)) {
- const QString name = def->qualifiedTypeNameId->name->asString();
+ const QString &name = def->qualifiedTypeNameId->name.toString();
if (name.isEmpty() || !name.at(0).isUpper()) {
QStringList props = syncGroupedProperties(modelNode,
name,
@@ -949,16 +947,16 @@ void TextToModelMerger::syncNode(ModelNode &modelNode,
if (property->type == UiPublicMember::Signal)
continue; // QML designer doesn't support this yet.
- if (!property->name || !property->memberType)
+ if (property->name.isEmpty() || property->memberType.isEmpty())
continue; // better safe than sorry.
- const QString astName = property->name->asString();
+ const QString &astName = property->name.toString();
QString astValue;
if (property->statement)
astValue = textAt(context->doc(),
property->statement->firstSourceLocation(),
property->statement->lastSourceLocation());
- const QString astType = property->memberType->asString();
+ const QString &astType = property->memberType.toString();
AbstractProperty modelProperty = modelNode.property(astName);
if (!property->statement || isLiteralValue(property->statement)) {
const QVariant variantValue = convertDynamicPropertyValueToVariant(astValue, astType);
diff --git a/src/plugins/qmljseditor/qmljscompletionassist.cpp b/src/plugins/qmljseditor/qmljscompletionassist.cpp
index 8a775699ff..e14e0ce30f 100644
--- a/src/plugins/qmljseditor/qmljscompletionassist.cpp
+++ b/src/plugins/qmljseditor/qmljscompletionassist.cpp
@@ -452,11 +452,11 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const IAssistInterface
break;
const ObjectValue *newScopeType = qmlScopeType;
for (AST::UiQualifiedId *it = objDef->qualifiedTypeNameId; it; it = it->next) {
- if (!newScopeType || !it->name) {
+ if (!newScopeType || it->name.isEmpty()) {
newScopeType = 0;
break;
}
- const Value *v = newScopeType->lookupMember(it->name->asString(), context);
+ const Value *v = newScopeType->lookupMember(it->name.toString(), context);
v = context->lookupReference(v);
newScopeType = value_cast<const ObjectValue *>(v);
}
diff --git a/src/plugins/qmljseditor/qmljscomponentfromobjectdef.cpp b/src/plugins/qmljseditor/qmljscomponentfromobjectdef.cpp
index f8baece7e8..73b0263f77 100644
--- a/src/plugins/qmljseditor/qmljscomponentfromobjectdef.cpp
+++ b/src/plugins/qmljseditor/qmljscomponentfromobjectdef.cpp
@@ -57,9 +57,9 @@ static QString toString(Statement *statement)
if (!expStmt)
return QString();
if (IdentifierExpression *idExp = cast<IdentifierExpression *>(expStmt->expression)) {
- return idExp->name->asString();
+ return idExp->name.toString();
} else if (StringLiteral *strExp = cast<StringLiteral *>(expStmt->expression)) {
- return strExp->value->asString();
+ return strExp->value.toString();
}
return QString();
}
@@ -75,10 +75,10 @@ static QString getIdProperty(UiObjectDefinition *def)
continue;
if (script->qualifiedId->next)
continue;
- if (script->qualifiedId->name) {
- if (script->qualifiedId->name->asString() == QLatin1String("id"))
+ if (!script->qualifiedId->name.isEmpty()) {
+ if (script->qualifiedId->name == QLatin1String("id"))
return toString(script->statement);
- if (script->qualifiedId->name->asString() == QLatin1String("objectName"))
+ if (script->qualifiedId->name == QLatin1String("objectName"))
objectName = toString(script->statement);
}
}
diff --git a/src/plugins/qmljseditor/qmljseditor.cpp b/src/plugins/qmljseditor/qmljseditor.cpp
index 5ec720ff10..69b83809c5 100644
--- a/src/plugins/qmljseditor/qmljseditor.cpp
+++ b/src/plugins/qmljseditor/qmljseditor.cpp
@@ -126,8 +126,8 @@ protected:
{
QString text;
for (; id; id = id->next) {
- if (id->name)
- text += id->name->asString();
+ if (!id->name.isEmpty())
+ text += id->name;
else
text += QLatin1Char('?');
@@ -149,8 +149,8 @@ protected:
if (asString(node->qualifiedId) == QLatin1String("id")) {
if (AST::ExpressionStatement *stmt = AST::cast<AST::ExpressionStatement*>(node->statement)) {
if (AST::IdentifierExpression *idExpr = AST::cast<AST::IdentifierExpression *>(stmt->expression)) {
- if (idExpr->name) {
- const QString id = idExpr->name->asString();
+ if (!idExpr->name.isEmpty()) {
+ const QString &id = idExpr->name.toString();
QList<AST::SourceLocation> *locs = &_ids[id];
locs->append(idExpr->firstSourceLocation());
locs->append(_maybeIds.value(id));
@@ -168,8 +168,8 @@ protected:
virtual bool visit(AST::IdentifierExpression *node)
{
- if (node->name) {
- const QString name = node->name->asString();
+ if (!node->name.isEmpty()) {
+ const QString &name = node->name.toString();
if (_ids.contains(name))
_ids[name].append(node->identifierToken);
@@ -206,8 +206,8 @@ protected:
{
QString text;
for (; id; id = id->next) {
- if (id->name)
- text += id->name->asString();
+ if (!id->name.isEmpty())
+ text += id->name;
else
text += QLatin1Char('?');
@@ -320,19 +320,19 @@ protected:
virtual bool visit(AST::FunctionDeclaration *ast)
{
- if (! ast->name)
+ if (ast->name.isEmpty())
return false;
Declaration decl;
init(&decl, ast);
decl.text.fill(QLatin1Char(' '), _depth);
- decl.text += ast->name->asString();
+ decl.text += ast->name;
decl.text += QLatin1Char('(');
for (FormalParameterList *it = ast->formals; it; it = it->next) {
- if (it->name)
- decl.text += it->name->asString();
+ if (!it->name.isEmpty())
+ decl.text += it->name;
if (it->next)
decl.text += QLatin1String(", ");
@@ -347,12 +347,12 @@ protected:
virtual bool visit(AST::VariableDeclaration *ast)
{
- if (! ast->name)
+ if (ast->name.isEmpty())
return false;
Declaration decl;
decl.text.fill(QLatin1Char(' '), _depth);
- decl.text += ast->name->asString();
+ decl.text += ast->name;
const SourceLocation first = ast->identifierToken;
decl.startLine = first.startLine;
@@ -568,8 +568,8 @@ QmlJS::AST::Node *SemanticInfo::declaringMemberNoProperties(int cursorPosition)
AST::Node *node = rangeAt(cursorPosition);
if (UiObjectDefinition *objectDefinition = cast<UiObjectDefinition*>(node)) {
- QString name = objectDefinition->qualifiedTypeNameId->name->asString();
- if (!name.isNull() && name.at(0).isLower()) {
+ const QString &name = objectDefinition->qualifiedTypeNameId->name.toString();
+ if (!name.isEmpty() && name.at(0).isLower()) {
QList<AST::Node *> path = rangePath(cursorPosition);
if (path.size() > 1)
return path.at(path.size() - 2);
@@ -579,7 +579,7 @@ QmlJS::AST::Node *SemanticInfo::declaringMemberNoProperties(int cursorPosition)
return path.at(path.size() - 3);
}
} else if (UiObjectBinding *objectBinding = cast<UiObjectBinding*>(node)) {
- QString name = objectBinding->qualifiedTypeNameId->name->asString();
+ const QString &name = objectBinding->qualifiedTypeNameId->name.toString();
if (name.contains("Gradient")) {
QList<AST::Node *> path = rangePath(cursorPosition);
if (path.size() > 1)
@@ -1085,7 +1085,7 @@ protected:
id = binding->qualifiedTypeNameId;
if (id) {
- QString name = id->name->asString();
+ const QStringRef &name = id->name;
if (!name.isEmpty() && name.at(0).isUpper()) {
return true;
}
@@ -1108,12 +1108,12 @@ protected:
if (UiScriptBinding *script = cast<UiScriptBinding *>(member)) {
if (! script->qualifiedId)
return false;
- else if (! script->qualifiedId->name)
+ else if (script->qualifiedId->name.isEmpty())
return false;
else if (script->qualifiedId->next)
return false;
- const QString propertyName = script->qualifiedId->name->asString();
+ const QStringRef &propertyName = script->qualifiedId->name;
if (propertyName == QLatin1String("id"))
return true;
@@ -1313,7 +1313,7 @@ TextEditor::BaseTextEditorWidget::Link QmlJSTextEditorWidget::findLinkAt(const Q
// string literals that could refer to a file link to them
if (StringLiteral *literal = cast<StringLiteral *>(node)) {
- const QString text = literal->value->asString();
+ const QString &text = literal->value.toString();
BaseTextEditorWidget::Link link;
link.begin = literal->literalToken.begin();
link.end = literal->literalToken.end();
diff --git a/src/plugins/qmljseditor/qmljsfindreferences.cpp b/src/plugins/qmljseditor/qmljsfindreferences.cpp
index 716e448bc4..b5d7965e25 100644
--- a/src/plugins/qmljseditor/qmljsfindreferences.cpp
+++ b/src/plugins/qmljseditor/qmljsfindreferences.cpp
@@ -104,8 +104,7 @@ protected:
virtual bool visit(AST::UiPublicMember *node)
{
- if (node->name
- && node->name->asString() == _name
+ if (node->name == _name
&& _scopeChain.qmlScopeObjects().contains(_scope)) {
_usages.append(node->identifierToken);
}
@@ -130,7 +129,7 @@ protected:
{
if (node->qualifiedId
&& !node->qualifiedId->next
- && node->qualifiedId->name->asString() == _name
+ && node->qualifiedId->name == _name
&& checkQmlScope()) {
_usages.append(node->qualifiedId->identifierToken);
}
@@ -145,7 +144,7 @@ protected:
{
if (node->qualifiedId
&& !node->qualifiedId->next
- && node->qualifiedId->name->asString() == _name
+ && node->qualifiedId->name == _name
&& checkQmlScope()) {
_usages.append(node->qualifiedId->identifierToken);
}
@@ -163,7 +162,7 @@ protected:
{
if (node->qualifiedId
&& !node->qualifiedId->next
- && node->qualifiedId->name->asString() == _name
+ && node->qualifiedId->name == _name
&& checkQmlScope()) {
_usages.append(node->qualifiedId->identifierToken);
}
@@ -172,7 +171,7 @@ protected:
virtual bool visit(AST::IdentifierExpression *node)
{
- if (!node->name || node->name->asString() != _name)
+ if (node->name.isEmpty() || node->name != _name)
return false;
const ObjectValue *scope;
@@ -203,7 +202,7 @@ protected:
virtual bool visit(AST::FieldMemberExpression *node)
{
- if (!node->name || node->name->asString() != _name)
+ if (node->name != _name)
return true;
Evaluate evaluate(&_scopeChain);
@@ -224,7 +223,7 @@ protected:
virtual bool visit(AST::FunctionExpression *node)
{
- if (node->name && node->name->asString() == _name) {
+ if (node->name == _name) {
if (checkLookup())
_usages.append(node->identifierToken);
}
@@ -237,7 +236,7 @@ protected:
virtual bool visit(AST::VariableDeclaration *node)
{
- if (node->name && node->name->asString() == _name) {
+ if (node->name == _name) {
if (checkLookup())
_usages.append(node->identifierToken);
}
@@ -330,7 +329,7 @@ protected:
virtual bool visit(AST::UiPublicMember *node)
{
- if (node->memberType && node->memberType->asString() == _name){
+ if (node->memberType == _name){
const ObjectValue * tVal = _context->lookupType(_doc.data(), QStringList(_name));
if (tVal == _typeValue)
_usages.append(node->typeToken);
@@ -376,7 +375,7 @@ protected:
virtual bool visit(AST::IdentifierExpression *node)
{
- if (!node->name || node->name->asString() != _name)
+ if (node->name != _name)
return false;
const ObjectValue *scope;
@@ -388,7 +387,7 @@ protected:
virtual bool visit(AST::FieldMemberExpression *node)
{
- if (!node->name || node->name->asString() != _name)
+ if (node->name != _name)
return true;
Evaluate evaluate(&_scopeChain);
const Value *lhsValue = evaluate(node->base);
@@ -422,7 +421,7 @@ protected:
virtual bool visit(UiImport *ast)
{
- if (ast && ast->importId && ast->importId->asString() == _name) {
+ if (ast && ast->importId == _name) {
const Imports *imp = _context->imports(_doc.data());
if (!imp)
return false;
@@ -437,7 +436,7 @@ private:
bool checkTypeName(UiQualifiedId *id)
{
for (UiQualifiedId *att = id; att; att = att->next){
- if (att->name && att->name->asString() == _name) {
+ if (att->name == _name) {
const ObjectValue *objectValue = _context->lookupType(_doc.data(), id, att->next);
if (_typeValue == objectValue){
_usages.append(att->identifierToken);
@@ -522,7 +521,7 @@ protected:
virtual bool visit(IdentifierExpression *node)
{
if (containsOffset(node->identifierToken)) {
- _name = node->name->asString();
+ _name = node->name.toString();
if ((!_name.isEmpty()) && _name.at(0).isUpper()) {
// a possible type
_targetValue = _scopeChain->lookup(_name, &_scope);
@@ -537,7 +536,7 @@ protected:
{
if (containsOffset(node->identifierToken)) {
setScope(node->base);
- _name = node->name->asString();
+ _name = node->name.toString();
if ((!_name.isEmpty()) && _name.at(0).isUpper()) {
// a possible type
Evaluate evaluate(_scopeChain);
@@ -592,8 +591,8 @@ protected:
virtual bool visit(UiPublicMember *node)
{
if (containsOffset(node->typeToken)){
- if (node->memberType){
- _name = node->memberType->asString();
+ if (!node->memberType.isEmpty()) {
+ _name = node->memberType.toString();
_targetValue = _scopeChain->context()->lookupType(_doc.data(), QStringList(_name));
_scope = 0;
_typeKind = TypeKind;
@@ -601,7 +600,7 @@ protected:
return false;
} else if (containsOffset(node->identifierToken)) {
_scope = _doc->bind()->findQmlObject(_objectNode);
- _name = node->name->asString();
+ _name = node->name.toString();
return false;
}
return true;
@@ -615,7 +614,7 @@ protected:
virtual bool visit(FunctionExpression *node)
{
if (containsOffset(node->identifierToken)) {
- _name = node->name->asString();
+ _name = node->name.toString();
return false;
}
return true;
@@ -624,7 +623,7 @@ protected:
virtual bool visit(VariableDeclaration *node)
{
if (containsOffset(node->identifierToken)) {
- _name = node->name->asString();
+ _name = node->name.toString();
return false;
}
return true;
@@ -643,9 +642,9 @@ private:
bool checkBindingName(UiQualifiedId *id)
{
- if (id && id->name && !id->next && containsOffset(id->identifierToken)) {
+ if (id && !id->name.isEmpty() && !id->next && containsOffset(id->identifierToken)) {
_scope = _doc->bind()->findQmlObject(_objectNode);
- _name = id->name->asString();
+ _name = id->name.toString();
return true;
}
return false;
@@ -654,10 +653,10 @@ private:
bool checkTypeName(UiQualifiedId *id)
{
for (UiQualifiedId *att = id; att; att = att->next) {
- if (att->name && containsOffset(att->identifierToken)) {
+ if (!att->name.isEmpty() && containsOffset(att->identifierToken)) {
_targetValue = _scopeChain->context()->lookupType(_doc.data(), id, att->next);
_scope = 0;
- _name = att->name->asString();
+ _name = att->name.toString();
_typeKind = TypeKind;
return true;
}
diff --git a/src/plugins/qmljseditor/qmljshoverhandler.cpp b/src/plugins/qmljseditor/qmljshoverhandler.cpp
index b3c39f953e..93f3fd87d3 100644
--- a/src/plugins/qmljseditor/qmljshoverhandler.cpp
+++ b/src/plugins/qmljseditor/qmljshoverhandler.cpp
@@ -197,8 +197,8 @@ bool HoverHandler::matchColorItem(const ScopeChain &scopeChain,
}
} else if (const AST::UiPublicMember *publicMember =
AST::cast<const AST::UiPublicMember *>(member)) {
- if (publicMember->name && posIsInSource(pos, publicMember->statement)) {
- value = scopeChain.lookup(publicMember->name->asString());
+ if (!publicMember->name.isEmpty() && posIsInSource(pos, publicMember->statement)) {
+ value = scopeChain.lookup(publicMember->name.toString());
if (const Reference *ref = value->asReference())
value = scopeChain.context()->lookupReference(ref);
if (value && value->asColorValue()) {
@@ -317,14 +317,14 @@ static const ObjectValue *isMember(const ScopeChain &scopeChain,
{
const ObjectValue *owningObject = 0;
if (AST::IdentifierExpression *identExp = AST::cast<AST::IdentifierExpression *>(node)) {
- if (!identExp->name)
+ if (identExp->name.isEmpty())
return 0;
- *name = identExp->name->asString();
+ *name = identExp->name.toString();
scopeChain.lookup(*name, &owningObject);
} else if (AST::FieldMemberExpression *fme = AST::cast<AST::FieldMemberExpression *>(node)) {
- if (!fme->base || !fme->name)
+ if (!fme->base || fme->name.isEmpty())
return 0;
- *name = fme->name->asString();
+ *name = fme->name.toString();
const Value *base = scopeChain.evaluate(fme->base);
if (!base)
return 0;
@@ -332,17 +332,17 @@ static const ObjectValue *isMember(const ScopeChain &scopeChain,
if (owningObject)
owningObject->lookupMember(*name, scopeChain.context(), &owningObject);
} else if (AST::UiQualifiedId *qid = AST::cast<AST::UiQualifiedId *>(node)) {
- if (!qid->name)
+ if (qid->name.isEmpty())
return 0;
- *name = qid->name->asString();
+ *name = qid->name.toString();
const Value *value = scopeChain.lookup(*name, &owningObject);
for (AST::UiQualifiedId *it = qid->next; it; it = it->next) {
if (!value)
return 0;
const ObjectValue *next = value->asObjectValue();
- if (!next || !it->name)
+ if (!next || it->name.isEmpty())
return 0;
- *name = it->name->asString();
+ *name = it->name.toString();
value = next->lookupMember(*name, scopeChain.context(), &owningObject);
}
}
diff --git a/src/plugins/qmljseditor/qmljssemantichighlighter.cpp b/src/plugins/qmljseditor/qmljssemantichighlighter.cpp
index f3928ee9c4..cc81c57cc7 100644
--- a/src/plugins/qmljseditor/qmljssemantichighlighter.cpp
+++ b/src/plugins/qmljseditor/qmljssemantichighlighter.cpp
@@ -168,19 +168,19 @@ protected:
{
if (!m_inStateType)
return false;
- if (!ast->qualifiedId || ! ast->qualifiedId->name || ast->qualifiedId->next)
+ if (!ast->qualifiedId || ast->qualifiedId->name.isEmpty() || ast->qualifiedId->next)
return false;
- if (ast->qualifiedId->name->asString() != QLatin1String("name"))
+ if (ast->qualifiedId->name != QLatin1String("name"))
return false;
ExpressionStatement *expStmt = cast<ExpressionStatement *>(ast->statement);
if (!expStmt)
return false;
StringLiteral *strLit = cast<StringLiteral *>(expStmt->expression);
- if (!strLit || !strLit->value)
+ if (!strLit || strLit->value.isEmpty())
return false;
- m_stateNames += strLit->value->asString();
+ m_stateNames += strLit->value.toString();
return false;
}
@@ -211,12 +211,12 @@ protected:
m_scopeBuilder.pop();
}
- void processName(NameId *name, SourceLocation location)
+ void processName(const QStringRef &name, SourceLocation location)
{
- if (!name)
+ if (name.isEmpty())
return;
- const QString nameStr = name->asString();
+ const QString &nameStr = name.toString();
const ObjectValue *scope = 0;
const Value *value = m_scopeChain.lookup(nameStr, &scope);
if (!value || !scope)
@@ -299,10 +299,10 @@ protected:
bool visit(StringLiteral *ast)
{
- if (!ast->value)
+ if (ast->value.isEmpty())
return false;
- const QString value = ast->value->asString();
+ const QString &value = ast->value.toString();
if (m_stateNames.contains(value)) {
addUse(ast->literalToken, SemanticHighlighter::LocalStateNameType);
}
diff --git a/src/plugins/qmljseditor/qmloutlinemodel.cpp b/src/plugins/qmljseditor/qmloutlinemodel.cpp
index cd19095c7a..9a9b5f9060 100644
--- a/src/plugins/qmljseditor/qmloutlinemodel.cpp
+++ b/src/plugins/qmljseditor/qmloutlinemodel.cpp
@@ -271,7 +271,7 @@ private:
AST::IdentifierExpression *lhsIdent = AST::cast<AST::IdentifierExpression *>(binExp->left);
AST::ObjectLiteral *rhsObjLit = AST::cast<AST::ObjectLiteral *>(binExp->right);
- if (lhsIdent && rhsObjLit && (lhsIdent->name->asString() == "testcase")
+ if (lhsIdent && rhsObjLit && (lhsIdent->name == "testcase")
&& (binExp->op == QSOperator::Assign)) {
QModelIndex index = m_model->enterTestCase(rhsObjLit);
m_nodeToIndex.insert(rhsObjLit, index);
@@ -553,8 +553,8 @@ QModelIndex QmlOutlineModel::enterPublicMember(AST::UiPublicMember *publicMember
{
QMap<int, QVariant> objectData;
- if (publicMember->name)
- objectData.insert(Qt::DisplayRole, publicMember->name->asString());
+ if (!publicMember->name.isEmpty())
+ objectData.insert(Qt::DisplayRole, publicMember->name.toString());
objectData.insert(AnnotationRole, getAnnotation(publicMember->statement));
objectData.insert(ItemTypeRole, NonElementBindingType);
@@ -572,7 +572,8 @@ QModelIndex QmlOutlineModel::enterFunctionDeclaration(AST::FunctionDeclaration *
{
QMap<int, QVariant> objectData;
- objectData.insert(Qt::DisplayRole, functionDeclaration->name->asString());
+ if (!functionDeclaration->name.isEmpty())
+ objectData.insert(Qt::DisplayRole, functionDeclaration->name.toString());
objectData.insert(ItemTypeRole, ElementBindingType);
QmlOutlineItem *item = enterNode(objectData, functionDeclaration, 0, m_icons->functionDeclarationIcon());
@@ -606,7 +607,7 @@ QModelIndex QmlOutlineModel::enterTestCaseProperties(AST::PropertyNameAndValueLi
{
QMap<int, QVariant> objectData;
if (AST::IdentifierPropertyName *propertyName = AST::cast<AST::IdentifierPropertyName *>(propertyNameAndValueList->name)) {
- objectData.insert(Qt::DisplayRole, propertyName->id->asString());
+ objectData.insert(Qt::DisplayRole, propertyName->id.toString());
objectData.insert(ItemTypeRole, ElementBindingType);
QmlOutlineItem *item;
if (propertyNameAndValueList->value->kind == AST::Node::Kind_FunctionExpression) {
@@ -895,8 +896,8 @@ QString QmlOutlineModel::asString(AST::UiQualifiedId *id)
{
QString text;
for (; id; id = id->next) {
- if (id->name)
- text += id->name->asString();
+ if (!id->name.isEmpty())
+ text += id->name;
else
text += QLatin1Char('?');
diff --git a/src/plugins/qmljseditor/quicktoolbar.cpp b/src/plugins/qmljseditor/quicktoolbar.cpp
index b9daf07ce1..87b19b013e 100644
--- a/src/plugins/qmljseditor/quicktoolbar.cpp
+++ b/src/plugins/qmljseditor/quicktoolbar.cpp
@@ -75,7 +75,7 @@ static inline const ObjectValue * getPropertyChangesTarget(Node *node, const Sco
for (UiObjectMemberList *members = initializer->members; members; members = members->next) {
if (UiScriptBinding *scriptBinding = cast<UiScriptBinding *>(members->member)) {
if (scriptBinding->qualifiedId
- && scriptBinding->qualifiedId->name->asString() == QLatin1String("target")
+ && scriptBinding->qualifiedId->name == QLatin1String("target")
&& ! scriptBinding->qualifiedId->next) {
Evaluate evaluator(&scopeChain);
const Value *targetValue = evaluator(scriptBinding->statement);
@@ -184,12 +184,12 @@ void QuickToolBar::apply(TextEditor::BaseTextEditor *editor, Document::Ptr docum
quint32 end = 0;
UiObjectInitializer *initializer = 0;
if (objectDefinition) {
- name = objectDefinition->qualifiedTypeNameId->name->asString();
+ name = objectDefinition->qualifiedTypeNameId->name.toString();
initializer = objectDefinition->initializer;
offset = objectDefinition->firstSourceLocation().offset;
end = objectDefinition->lastSourceLocation().end();
} else if (objectBinding) {
- name = objectBinding->qualifiedTypeNameId->name->asString();
+ name = objectBinding->qualifiedTypeNameId->name.toString();
initializer = objectBinding->initializer;
offset = objectBinding->firstSourceLocation().offset;
end = objectBinding->lastSourceLocation().end();
@@ -274,10 +274,10 @@ bool QuickToolBar::isAvailable(TextEditor::BaseTextEditor *, Document::Ptr docum
UiObjectDefinition *objectDefinition = cast<UiObjectDefinition*>(node);
UiObjectBinding *objectBinding = cast<UiObjectBinding*>(node);
if (objectDefinition) {
- name = objectDefinition->qualifiedTypeNameId->name->asString();
+ name = objectDefinition->qualifiedTypeNameId->name.toString();
} else if (objectBinding) {
- name = objectBinding->qualifiedTypeNameId->name->asString();
+ name = objectBinding->qualifiedTypeNameId->name.toString();
}
QStringList prototypes;
diff --git a/src/plugins/qmljsinspector/qmljslivetextpreview.cpp b/src/plugins/qmljsinspector/qmljslivetextpreview.cpp
index 77e24381ec..01e2c31738 100644
--- a/src/plugins/qmljsinspector/qmljslivetextpreview.cpp
+++ b/src/plugins/qmljsinspector/qmljslivetextpreview.cpp
@@ -498,9 +498,9 @@ protected:
if (unsyncronizableChanges == QmlJSLiveTextPreview::NoUnsyncronizableChanges) {
UiObjectDefinition *parentDefinition = cast<UiObjectDefinition *>(parent);
if (parentDefinition && parentDefinition->qualifiedTypeNameId
- && parentDefinition->qualifiedTypeNameId->name)
+ && !parentDefinition->qualifiedTypeNameId->name.isEmpty())
{
- unsyncronizableElementName = parentDefinition->qualifiedTypeNameId->name->asString();
+ unsyncronizableElementName = parentDefinition->qualifiedTypeNameId->name.toString();
unsyncronizableChanges = QmlJSLiveTextPreview::ElementChangeWarning;
unsyncronizableChangeLine = parentDefinition->firstSourceLocation().startLine;
unsyncronizableChangeColumn = parentDefinition->firstSourceLocation().startColumn;
diff --git a/src/plugins/qmljstools/qmljslocatordata.cpp b/src/plugins/qmljstools/qmljslocatordata.cpp
index a7f84c9319..1c741b59a2 100644
--- a/src/plugins/qmljstools/qmljslocatordata.cpp
+++ b/src/plugins/qmljstools/qmljslocatordata.cpp
@@ -62,14 +62,14 @@ static QString findId(UiObjectInitializer *initializer)
return QString();
for (UiObjectMemberList *member = initializer->members; member; member = member->next) {
if (UiScriptBinding *script = cast<UiScriptBinding *>(member->member)) {
- if (!script->qualifiedId || !script->qualifiedId->name || script->qualifiedId->next)
+ if (!script->qualifiedId || script->qualifiedId->name.isEmpty() || script->qualifiedId->next)
continue;
- if (script->qualifiedId->name->asString() != QLatin1String("id"))
+ if (script->qualifiedId->name != QLatin1String("id"))
continue;
if (ExpressionStatement *expStmt = cast<ExpressionStatement *>(script->statement)) {
if (IdentifierExpression *identExp = cast<IdentifierExpression *>(expStmt->expression)) {
- if (identExp->name)
- return identExp->name->asString();
+ if (!identExp->name.isEmpty())
+ return identExp->name.toString();
}
}
}
@@ -132,19 +132,19 @@ protected:
bool visit(FunctionExpression *ast)
{
- if (!ast->name)
+ if (ast->name.isEmpty())
return true;
LocatorData::Entry entry = basicEntry(ast->identifierToken);
entry.type = LocatorData::Function;
- entry.displayName = ast->name->asString();
+ entry.displayName = ast->name.toString();
entry.displayName += QLatin1Char('(');
for (FormalParameterList *it = ast->formals; it; it = it->next) {
if (it != ast->formals)
entry.displayName += QLatin1String(", ");
- if (it->name)
- entry.displayName += it->name->asString();
+ if (!it->name.isEmpty())
+ entry.displayName += it->name.toString();
}
entry.displayName += QLatin1Char(')');
entry.symbolName = entry.displayName;
diff --git a/src/plugins/qttest/testcode.cpp b/src/plugins/qttest/testcode.cpp
index 1cff491bcc..f57cfe7b53 100755
--- a/src/plugins/qttest/testcode.cpp
+++ b/src/plugins/qttest/testcode.cpp
@@ -91,7 +91,7 @@ public:
private:
bool visit(QmlJS::AST::IdentifierExpression *identifier)
{
- QString name = identifier->name->asString();
+ const QStringRef &name = identifier->name;
m_foundTestCase = (name == QLatin1String("testcase"));
if (!m_foundTestCase && (name == QLatin1String("prompt") || name == QLatin1String("manualTest")))
m_testCode->setManualTest(identifier->identifierToken.offset);
@@ -120,7 +120,7 @@ private:
if (properties->name->kind == QmlJS::AST::Node::Kind_IdentifierPropertyName) {
QmlJS::AST::IdentifierPropertyName *name =
static_cast<QmlJS::AST::IdentifierPropertyName*>(properties->name);
- QString nameString = name->id->asString();
+ const QString &nameString = name->id.toString();
if (properties->value->kind == QmlJS::AST::Node::Kind_FunctionExpression) {
int startLine = name->propertyNameToken.startLine;
int start = name->propertyNameToken.offset;