forked from qt-creator/qt-creator
QmlDesigner: Remove using namespace QmlJS::AST from RemovePropertyVisitor
Change-Id: Ife1542a61abbd1b323ce1fa46854d95de253f2aa Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com>
This commit is contained in:
committed by
Thomas Hartmann
parent
11ee8adfdc
commit
059c2aafd5
@@ -33,8 +33,6 @@
|
|||||||
#include <qmljs/parser/qmljsast_p.h>
|
#include <qmljs/parser/qmljsast_p.h>
|
||||||
|
|
||||||
using namespace QmlDesigner::Internal;
|
using namespace QmlDesigner::Internal;
|
||||||
using namespace QmlJS;
|
|
||||||
using namespace QmlJS::AST;
|
|
||||||
|
|
||||||
RemovePropertyVisitor::RemovePropertyVisitor(QmlDesigner::TextModifier &modifier,
|
RemovePropertyVisitor::RemovePropertyVisitor(QmlDesigner::TextModifier &modifier,
|
||||||
quint32 parentLocation,
|
quint32 parentLocation,
|
||||||
@@ -45,7 +43,7 @@ RemovePropertyVisitor::RemovePropertyVisitor(QmlDesigner::TextModifier &modifier
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RemovePropertyVisitor::visit(UiObjectBinding *ast)
|
bool RemovePropertyVisitor::visit(QmlJS::AST::UiObjectBinding *ast)
|
||||||
{
|
{
|
||||||
if (ast->firstSourceLocation().offset == parentLocation) {
|
if (ast->firstSourceLocation().offset == parentLocation) {
|
||||||
//this condition is wrong for the UiObjectBinding case, but we keep it
|
//this condition is wrong for the UiObjectBinding case, but we keep it
|
||||||
@@ -62,7 +60,7 @@ bool RemovePropertyVisitor::visit(UiObjectBinding *ast)
|
|||||||
return !didRewriting();
|
return !didRewriting();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RemovePropertyVisitor::visit(UiObjectDefinition *ast)
|
bool RemovePropertyVisitor::visit(QmlJS::AST::UiObjectDefinition *ast)
|
||||||
{
|
{
|
||||||
if (ast->firstSourceLocation().offset == parentLocation) {
|
if (ast->firstSourceLocation().offset == parentLocation) {
|
||||||
// FIXME: change this to use the QmlJS::Rewriter class
|
// FIXME: change this to use the QmlJS::Rewriter class
|
||||||
@@ -73,22 +71,22 @@ bool RemovePropertyVisitor::visit(UiObjectDefinition *ast)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: duplicate code in the QmlJS::Rewriter class, remove this
|
// FIXME: duplicate code in the QmlJS::Rewriter class, remove this
|
||||||
void RemovePropertyVisitor::removeFrom(UiObjectInitializer *ast)
|
void RemovePropertyVisitor::removeFrom(QmlJS::AST::UiObjectInitializer *ast)
|
||||||
{
|
{
|
||||||
QString prefix;
|
QString prefix;
|
||||||
int dotIdx = propertyName.indexOf(QLatin1Char('.'));
|
int dotIdx = propertyName.indexOf(QLatin1Char('.'));
|
||||||
if (dotIdx != -1)
|
if (dotIdx != -1)
|
||||||
prefix = propertyName.left(dotIdx);
|
prefix = propertyName.left(dotIdx);
|
||||||
|
|
||||||
for (UiObjectMemberList *it = ast->members; it; it = it->next) {
|
for (QmlJS::AST::UiObjectMemberList *it = ast->members; it; it = it->next) {
|
||||||
UiObjectMember *member = it->member;
|
QmlJS::AST::UiObjectMember *member = it->member;
|
||||||
|
|
||||||
// run full name match (for ungrouped properties):
|
// run full name match (for ungrouped properties):
|
||||||
if (memberNameMatchesPropertyName(propertyName, member)) {
|
if (memberNameMatchesPropertyName(propertyName, member)) {
|
||||||
removeMember(member);
|
removeMember(member);
|
||||||
// check for grouped properties:
|
// check for grouped properties:
|
||||||
} else if (!prefix.isEmpty()) {
|
} else if (!prefix.isEmpty()) {
|
||||||
if (UiObjectDefinition *def = cast<UiObjectDefinition *>(member)) {
|
if (QmlJS::AST::UiObjectDefinition *def = QmlJS::AST::cast<QmlJS::AST::UiObjectDefinition *>(member)) {
|
||||||
if (toString(def->qualifiedTypeNameId) == prefix)
|
if (toString(def->qualifiedTypeNameId) == prefix)
|
||||||
removeGroupedProperty(def);
|
removeGroupedProperty(def);
|
||||||
}
|
}
|
||||||
@@ -97,7 +95,7 @@ void RemovePropertyVisitor::removeFrom(UiObjectInitializer *ast)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: duplicate code in the QmlJS::Rewriter class, remove this
|
// FIXME: duplicate code in the QmlJS::Rewriter class, remove this
|
||||||
void RemovePropertyVisitor::removeGroupedProperty(UiObjectDefinition *ast)
|
void RemovePropertyVisitor::removeGroupedProperty(QmlJS::AST::UiObjectDefinition *ast)
|
||||||
{
|
{
|
||||||
int dotIdx = propertyName.indexOf(QLatin1Char('.'));
|
int dotIdx = propertyName.indexOf(QLatin1Char('.'));
|
||||||
if (dotIdx == -1)
|
if (dotIdx == -1)
|
||||||
@@ -105,11 +103,11 @@ void RemovePropertyVisitor::removeGroupedProperty(UiObjectDefinition *ast)
|
|||||||
|
|
||||||
const QString propName = propertyName.mid(dotIdx + 1);
|
const QString propName = propertyName.mid(dotIdx + 1);
|
||||||
|
|
||||||
UiObjectMember *wanted = 0;
|
QmlJS::AST::UiObjectMember *wanted = 0;
|
||||||
unsigned memberCount = 0;
|
unsigned memberCount = 0;
|
||||||
for (UiObjectMemberList *it = ast->initializer->members; it; it = it->next) {
|
for (QmlJS::AST::UiObjectMemberList *it = ast->initializer->members; it; it = it->next) {
|
||||||
++memberCount;
|
++memberCount;
|
||||||
UiObjectMember *member = it->member;
|
QmlJS::AST::UiObjectMember *member = it->member;
|
||||||
|
|
||||||
if (!wanted && memberNameMatchesPropertyName(propName, member))
|
if (!wanted && memberNameMatchesPropertyName(propName, member))
|
||||||
wanted = member;
|
wanted = member;
|
||||||
@@ -124,7 +122,7 @@ void RemovePropertyVisitor::removeGroupedProperty(UiObjectDefinition *ast)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: duplicate code in the QmlJS::Rewriter class, remove this
|
// FIXME: duplicate code in the QmlJS::Rewriter class, remove this
|
||||||
void RemovePropertyVisitor::removeMember(UiObjectMember *member)
|
void RemovePropertyVisitor::removeMember(QmlJS::AST::UiObjectMember *member)
|
||||||
{
|
{
|
||||||
int start = member->firstSourceLocation().offset;
|
int start = member->firstSourceLocation().offset;
|
||||||
int end = member->lastSourceLocation().end();
|
int end = member->lastSourceLocation().end();
|
||||||
@@ -136,15 +134,15 @@ void RemovePropertyVisitor::removeMember(UiObjectMember *member)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: duplicate code in the QmlJS::Rewriter class, remove this
|
// FIXME: duplicate code in the QmlJS::Rewriter class, remove this
|
||||||
bool RemovePropertyVisitor::memberNameMatchesPropertyName(const QString &propertyName, UiObjectMember *ast)
|
bool RemovePropertyVisitor::memberNameMatchesPropertyName(const QString &propertyName, QmlJS::AST::UiObjectMember *ast)
|
||||||
{
|
{
|
||||||
if (UiPublicMember *publicMember = cast<UiPublicMember*>(ast))
|
if (QmlJS::AST::UiPublicMember *publicMember = QmlJS::AST::cast<QmlJS::AST::UiPublicMember*>(ast))
|
||||||
return publicMember->name == propertyName;
|
return publicMember->name == propertyName;
|
||||||
else if (UiObjectBinding *objectBinding = cast<UiObjectBinding*>(ast))
|
else if (QmlJS::AST::UiObjectBinding *objectBinding = QmlJS::AST::cast<QmlJS::AST::UiObjectBinding*>(ast))
|
||||||
return toString(objectBinding->qualifiedId) == propertyName;
|
return toString(objectBinding->qualifiedId) == propertyName;
|
||||||
else if (UiScriptBinding *scriptBinding = cast<UiScriptBinding*>(ast))
|
else if (QmlJS::AST::UiScriptBinding *scriptBinding = QmlJS::AST::cast<QmlJS::AST::UiScriptBinding*>(ast))
|
||||||
return toString(scriptBinding->qualifiedId) == propertyName;
|
return toString(scriptBinding->qualifiedId) == propertyName;
|
||||||
else if (UiArrayBinding *arrayBinding = cast<UiArrayBinding*>(ast))
|
else if (QmlJS::AST::UiArrayBinding *arrayBinding = QmlJS::AST::cast<QmlJS::AST::UiArrayBinding*>(ast))
|
||||||
return toString(arrayBinding->qualifiedId) == propertyName;
|
return toString(arrayBinding->qualifiedId) == propertyName;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
Reference in New Issue
Block a user