Commit 6fb3328d authored by hjk's avatar hjk

CppEditor: remove operator() overloads from OverView

Feels less obfuscated.

Change-Id: Ide0ec1f38762038ddbb1eddb4f70f7d6acdf1ff7
Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@digia.com>
parent 2b305823
......@@ -304,25 +304,25 @@ private:
virtual void visit(const DestructorNameId *name)
{
Overview oo;
qWarning() << "ignored name:" << oo(name);
qWarning() << "ignored name:" << oo.prettyName(name);
}
virtual void visit(const OperatorNameId *name)
{
Overview oo;
qWarning() << "ignored name:" << oo(name);
qWarning() << "ignored name:" << oo.prettyName(name);
}
virtual void visit(const ConversionNameId *name)
{
Overview oo;
qWarning() << "ignored name:" << oo(name);
qWarning() << "ignored name:" << oo.prettyName(name);
}
virtual void visit(const SelectorNameId *name)
{
Overview oo;
qWarning() << "ignored name:" << oo(name);
qWarning() << "ignored name:" << oo.prettyName(name);
}
private:
......
......@@ -55,13 +55,13 @@ static QString indent(QString s, int level = 2)
QString CPlusPlus::toString(const Name *name, QString id)
{
Overview oo;
return QString("%0: %1").arg(id, name ? oo(name) : QLatin1String("(null)"));
return QString("%0: %1").arg(id, name ? oo.prettyName(name) : QLatin1String("(null)"));
}
QString CPlusPlus::toString(FullySpecifiedType ty, QString id)
{
Overview oo;
return QString("%0: %1 (a %2)").arg(id, oo(ty), ty.type() ? typeid(*ty.type()).name() : "(null)");
return QString("%0: %1 (a %2)").arg(id, oo.prettyType(ty), ty.type() ? typeid(*ty.type()).name() : "(null)");
}
QString CPlusPlus::toString(const Symbol *s, QString id)
......
......@@ -1106,7 +1106,7 @@ bool CreateBindings::visit(Declaration *decl)
_currentClassOrNamespace->addNestedType(decl->name(), e);
} else if (false) {
Overview oo;
qDebug() << "found entity not found for" << oo(namedTy->name());
qDebug() << "found entity not found for" << oo.prettyName(namedTy->name());
}
} else if (Class *klass = ty->asClassType()) {
if (const Identifier *nameId = decl->name()->asNameId()) {
......@@ -1131,7 +1131,7 @@ bool CreateBindings::visit(BaseClass *b)
_currentClassOrNamespace->addUsing(base);
} else if (false) {
Overview oo;
qDebug() << "no entity for:" << oo(b->name());
qDebug() << "no entity for:" << oo.prettyName(b->name());
}
return false;
}
......@@ -1157,7 +1157,7 @@ bool CreateBindings::visit(UsingNamespaceDirective *u)
_currentClassOrNamespace->addUsing(e);
} else if (false) {
Overview oo;
qDebug() << "no entity for namespace:" << oo(u->name());
qDebug() << "no entity for namespace:" << oo.prettyName(u->name());
}
return false;
}
......@@ -1173,7 +1173,7 @@ bool CreateBindings::visit(NamespaceAlias *a)
} else if (false) {
Overview oo;
qDebug() << "no entity for namespace:" << oo(a->namespaceName());
qDebug() << "no entity for namespace:" << oo.prettyName(a->namespaceName());
}
return false;
......@@ -1201,7 +1201,7 @@ bool CreateBindings::visit(ObjCBaseClass *b)
_currentClassOrNamespace->addUsing(base);
} else if (false) {
Overview oo;
qDebug() << "no entity for:" << oo(b->name());
qDebug() << "no entity for:" << oo.prettyName(b->name());
}
return false;
}
......@@ -1233,7 +1233,7 @@ bool CreateBindings::visit(ObjCBaseProtocol *b)
_currentClassOrNamespace->addUsing(base);
} else if (false) {
Overview oo;
qDebug() << "no entity for:" << oo(b->name());
qDebug() << "no entity for:" << oo.prettyName(b->name());
}
return false;
}
......
......@@ -345,7 +345,7 @@ void TypePrettyPrinter::visit(Function *type)
if (_overview->showArgumentNames)
name = arg->name();
_text += argumentText(arg->type(), name);
_text += argumentText.prettyType(arg->type(), name);
if (_overview->showDefaultArguments) {
if (const StringLiteral *initializer = arg->initializer()) {
......
......@@ -79,7 +79,7 @@ public:
scope);
if (!candidates .isEmpty() && candidates.first().declaration()) {
Symbol *decl = candidates.first().declaration();
values << prettyPrint(LookupContext::fullyQualifiedName(decl));
values << prettyPrint.prettyName(LookupContext::fullyQualifiedName(decl));
}
}
return true;
......@@ -194,7 +194,7 @@ QList<CppQuickFixOperation::Ptr> CompleteSwitchCaseStatement::match(
Overview prettyPrint;
for (unsigned i = 0; i < e->memberCount(); ++i) {
if (Declaration *decl = e->memberAt(i)->asDeclaration()) {
values << prettyPrint(LookupContext::fullyQualifiedName(decl));
values << prettyPrint.prettyName(LookupContext::fullyQualifiedName(decl));
}
}
// Get the used values
......
......@@ -604,7 +604,7 @@ Utils::ChangeSet FunctionDeclDefLink::changes(const Snapshot &snapshot, int targ
// abort if the name of the newly parsed function is not the expected one
DeclaratorIdAST *newDeclId = getDeclaratorId(newDef->declarator);
if (!newDeclId || !newDeclId->name || !newDeclId->name->name
|| overview(newDeclId->name->name) != nameInitial) {
|| overview.prettyName(newDeclId->name->name) != nameInitial) {
return changes;
}
......@@ -650,7 +650,7 @@ Utils::ChangeSet FunctionDeclDefLink::changes(const Snapshot &snapshot, int targ
if (!newFunction->returnType().isEqualTo(sourceFunction->returnType())
&& !newFunction->returnType().isEqualTo(targetFunction->returnType())) {
FullySpecifiedType type = rewriteType(newFunction->returnType(), &env, control);
const QString replacement = overview(type, targetFunction->name());
const QString replacement = overview.prettyType(type, targetFunction->name());
changes.replace(returnTypeStart,
targetFile->startOf(targetFunctionDeclarator->lparen_token),
replacement);
......@@ -706,19 +706,19 @@ Utils::ChangeSet FunctionDeclDefLink::changes(const Snapshot &snapshot, int targ
QMultiHash<QString, int> sourceParamNameToIndex;
for (int i = 0; i < existingParamCount; ++i) {
Symbol *sourceParam = sourceFunction->argumentAt(i);
sourceParamNameToIndex.insert(overview(sourceParam->name()), i);
sourceParamNameToIndex.insert(overview.prettyName(sourceParam->name()), i);
}
QMultiHash<QString, int> newParamNameToIndex;
for (int i = 0; i < newParamCount; ++i) {
Symbol *newParam = newFunction->argumentAt(i);
newParamNameToIndex.insert(overview(newParam->name()), i);
newParamNameToIndex.insert(overview.prettyName(newParam->name()), i);
}
// name-based binds (possibly disambiguated by type)
for (int sourceParamIndex = 0; sourceParamIndex < existingParamCount; ++sourceParamIndex) {
Symbol *sourceParam = sourceFunction->argumentAt(sourceParamIndex);
const QString &name = overview(sourceParam->name());
const QString &name = overview.prettyName(sourceParam->name());
QList<int> newParams = newParamNameToIndex.values(name);
QList<int> sourceParams = sourceParamNameToIndex.values(name);
......@@ -783,7 +783,7 @@ Utils::ChangeSet FunctionDeclDefLink::changes(const Snapshot &snapshot, int targ
// if it's genuinely new, add it
if (existingParamIndex == -1) {
FullySpecifiedType type = rewriteType(newParam->type(), &env, control);
newTargetParam = overview(type, newParam->name());
newTargetParam = overview.prettyType(type, newParam->name());
hadChanges = true;
}
// otherwise preserve as much as possible from the existing parameter
......@@ -821,7 +821,7 @@ Utils::ChangeSet FunctionDeclDefLink::changes(const Snapshot &snapshot, int targ
// track renames
if (replacementName != targetParam->name() && replacementName)
renamedTargetParameters[targetParam] = overview(replacementName);
renamedTargetParameters[targetParam] = overview.prettyName(replacementName);
// need to change the type (and name)?
if (!newParam->type().isEqualTo(sourceParam->type())
......@@ -837,14 +837,14 @@ Utils::ChangeSet FunctionDeclDefLink::changes(const Snapshot &snapshot, int targ
FullySpecifiedType replacementType = rewriteType(newParam->type(), &env, control);
newTargetParam = targetFile->textOf(parameterStart, parameterTypeStart);
newTargetParam += overview(replacementType, replacementName);
newTargetParam += overview.prettyType(replacementType, replacementName);
newTargetParam += targetFile->textOf(parameterTypeEnd, parameterEnd);
hadChanges = true;
}
// change the name only?
else if (!namesEqual(targetParam->name(), replacementName)) {
DeclaratorIdAST *id = getDeclaratorId(targetParamAst->declarator);
const QString &replacementNameStr = overview(replacementName);
const QString &replacementNameStr = overview.prettyName(replacementName);
if (id) {
newTargetParam += targetFile->textOf(parameterStart, targetFile->startOf(id));
QString rest = targetFile->textOf(targetFile->endOf(id), parameterEnd);
......
......@@ -212,7 +212,7 @@ QString InsertDeclOperation::generateDeclaration(Function *function)
oo.showArgumentNames = true;
QString decl;
decl += oo(function->type(), function->unqualifiedName());
decl += oo.prettyType(function->type(), function->unqualifiedName());
decl += QLatin1String(";\n");
return decl;
......@@ -271,7 +271,7 @@ public:
FullySpecifiedType tn = rewriteType(m_decl->type(), &env, control);
// rewrite the function name
QString name = oo(LookupContext::minimalName(m_decl, targetCoN, control));
QString name = oo.prettyName(LookupContext::minimalName(m_decl, targetCoN, control));
QString defText = oo.prettyType(tn, name) + QLatin1String("\n{\n}");
......
......@@ -102,7 +102,7 @@ QList<CppQuickFixOperation::Ptr> InsertQtPropertyMembers::match(
Symbol *member = c->memberAt(i);
FullySpecifiedType type = member->type();
if (member->asFunction() || (type.isValid() && type->asFunctionType())) {
const QString name = overview(member->name());
const QString name = overview.prettyName(member->name());
if (name == getterName) {
generateFlags &= ~GenerateGetter;
} else if (name == setterName) {
......@@ -111,7 +111,7 @@ QList<CppQuickFixOperation::Ptr> InsertQtPropertyMembers::match(
generateFlags &= ~GenerateSignal;
}
} else if (member->asDeclaration()) {
const QString name = overview(member->name());
const QString name = overview.prettyName(member->name());
if (name == storageName)
generateFlags &= ~GenerateStorage;
}
......
......@@ -1702,7 +1702,7 @@ private:
FullySpecifiedType tn = rewriteType(result.first().type(), &env, control);
Overview oo;
QString ty = oo(tn);
QString ty = oo.prettyType(tn);
if (! ty.isEmpty()) {
const QChar ch = ty.at(ty.size() - 1);
......@@ -1848,7 +1848,7 @@ public:
if (!existingResults.isEmpty())
return noResult();
const QString &className = Overview()(innermostName->name);
const QString &className = Overview().prettyName(innermostName->name);
if (className.isEmpty())
return noResult();
......
......@@ -1134,9 +1134,9 @@ void CppCompletionAssistProcessor::completeObjCMsgSend(CPlusPlus::ClassOrNamespa
text += QLatin1Char(':');
text += TextEditor::Snippet::kVariableDelimiter;
text += QLatin1Char('(');
text += oo(arg->type());
text += oo.prettyType(arg->type());
text += QLatin1Char(')');
text += oo(arg->name());
text += oo.prettyName(arg->name());
text += TextEditor::Snippet::kVariableDelimiter;
}
} else {
......@@ -1907,7 +1907,7 @@ bool CppCompletionAssistProcessor::completeConstructorOrFunction(const QList<CPl
const FullySpecifiedType localTy = rewriteType(f->type(), &env, control);
// gets: "parameter list) cv-spec",
QString completion = overview(localTy).mid(1);
QString completion = overview.prettyType(localTy).mid(1);
addCompletionItem(completion, QIcon(), 0,
QVariant::fromValue(CompleteFunctionDeclaration(f)));
......
......@@ -250,7 +250,7 @@ void CppFindReferences::findUsages(CPlusPlus::Symbol *symbol,
Overview overview;
Find::SearchResult *search = Find::SearchResultWindow::instance()->startNewSearch(tr("C++ Usages:"),
QString(),
overview(context.fullyQualifiedName(symbol)),
overview.prettyName(context.fullyQualifiedName(symbol)),
replace ? Find::SearchResultWindow::SearchAndReplace
: Find::SearchResultWindow::SearchOnly,
QLatin1String("CppEditor"));
......
......@@ -516,7 +516,7 @@ static FullySpecifiedType stripPointerAndReference(const FullySpecifiedType &typ
static QString toQmlType(const FullySpecifiedType &type)
{
Overview overview;
QString result = overview(stripPointerAndReference(type));
QString result = overview.prettyType(stripPointerAndReference(type));
if (result == QLatin1String("QString"))
result = QLatin1String("string");
return result;
......@@ -553,7 +553,7 @@ static LanguageUtils::FakeMetaObject::Ptr buildFakeMetaObject(
Overview namePrinter;
fmo->setClassName(namePrinter(klass->name()));
fmo->setClassName(namePrinter.prettyName(klass->name()));
// add the no-package export, so the cpp name can be used in properties
fmo->addExport(fmo->className(), QmlJS::CppQmlTypes::cppPackage, ComponentVersion());
......@@ -564,7 +564,7 @@ static LanguageUtils::FakeMetaObject::Ptr buildFakeMetaObject(
if (Function *func = member->type()->asFunctionType()) {
if (!func->isSlot() && !func->isInvokable() && !func->isSignal())
continue;
FakeMetaMethod method(namePrinter(func->name()), toQmlType(func->returnType()));
FakeMetaMethod method(namePrinter.prettyName(func->name()), toQmlType(func->returnType()));
if (func->isSignal())
method.setMethodType(FakeMetaMethod::Signal);
else
......@@ -573,7 +573,7 @@ static LanguageUtils::FakeMetaObject::Ptr buildFakeMetaObject(
Symbol *arg = func->argumentAt(a);
QString name;
if (arg->name())
name = namePrinter(arg->name());
name = namePrinter.prettyName(arg->name());
method.addParameter(name, toQmlType(arg->type()));
}
fmo->addMethod(method);
......@@ -585,7 +585,7 @@ static LanguageUtils::FakeMetaObject::Ptr buildFakeMetaObject(
const bool isPointer = type.type() && type.type()->isPointerType();
const int revision = 0; // ### fixme
FakeMetaProperty property(
namePrinter(propDecl->name()),
namePrinter.prettyName(propDecl->name()),
toQmlType(type),
isList, isWritable, isPointer,
revision);
......@@ -594,7 +594,7 @@ static LanguageUtils::FakeMetaObject::Ptr buildFakeMetaObject(
if (QtEnum *qtEnum = member->asQtEnum()) {
// find the matching enum
Enum *e = 0;
QList<LookupItem> result = typeOf(namePrinter(qtEnum->name()).toUtf8(), klass);
QList<LookupItem> result = typeOf(namePrinter.prettyName(qtEnum->name()).toUtf8(), klass);
foreach (const LookupItem &item, result) {
if (item.declaration()) {
e = item.declaration()->asEnum();
......@@ -605,12 +605,12 @@ static LanguageUtils::FakeMetaObject::Ptr buildFakeMetaObject(
if (!e)
continue;
FakeMetaEnum metaEnum(namePrinter(e->name()));
FakeMetaEnum metaEnum(namePrinter.prettyName(e->name()));
for (unsigned j = 0; j < e->memberCount(); ++j) {
Symbol *enumMember = e->memberAt(j);
if (!enumMember->name())
continue;
metaEnum.addKey(namePrinter(enumMember->name()), 0);
metaEnum.addKey(namePrinter.prettyName(enumMember->name()), 0);
}
fmo->addEnum(metaEnum);
}
......@@ -622,7 +622,7 @@ static LanguageUtils::FakeMetaObject::Ptr buildFakeMetaObject(
if (!base->name())
return fmo;
const QString baseClassName = namePrinter(base->name());
const QString baseClassName = namePrinter.prettyName(base->name());
fmo->setSuperclassName(baseClassName);
Class *baseClass = lookupClass(baseClassName, klass, typeOf);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment