Revert now unnecessary checks for null-types

This reverts commits:

c721304a47
885d908ea3
a0909989f7
fb4ad59ddb
0a9a67cf54
0d1624d4d1
d018cfd5cb
0504fdd00b
a2fd10fe19

Conflicts:

	src/plugins/cpptools/cppcodecompletion.cpp

Reviewed-by: Roberto Raggi
This commit is contained in:
Thorbjørn Lindeijer
2009-02-10 17:37:18 +01:00
parent 146a534932
commit a33ae02927
5 changed files with 8 additions and 23 deletions

View File

@@ -171,7 +171,7 @@ QVariant OverviewModel::data(const QModelIndex &index, int role) const
if (! symbol->isScopedSymbol() || symbol->isFunction()) { if (! symbol->isScopedSymbol() || symbol->isFunction()) {
QString type = _overview.prettyType(symbol->type()); QString type = _overview.prettyType(symbol->type());
if (! type.isEmpty()) { if (! type.isEmpty()) {
if (symbol->type() && ! symbol->type()->isFunctionType()) if (! symbol->type()->isFunctionType())
name += QLatin1String(": "); name += QLatin1String(": ");
name += type; name += type;
} }

View File

@@ -593,8 +593,6 @@ Symbol *CPPEditor::findDefinition(Symbol *symbol)
{ {
if (symbol->isFunction()) if (symbol->isFunction())
return 0; // symbol is a function definition. return 0; // symbol is a function definition.
else if (! symbol->type())
return 0;
Function *funTy = symbol->type()->asFunctionType(); Function *funTy = symbol->type()->asFunctionType();
if (! funTy) if (! funTy)

View File

@@ -256,7 +256,7 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in
const QList<TypeOfExpression::Result> types = const QList<TypeOfExpression::Result> types =
typeOfExpression(expression, doc, lastSymbol); typeOfExpression(expression, doc, lastSymbol);
if (!types.isEmpty() && types.first().first) { if (!types.isEmpty()) {
FullySpecifiedType firstType = types.first().first; FullySpecifiedType firstType = types.first().first;
Symbol *symbol = types.first().second; Symbol *symbol = types.first().second;
FullySpecifiedType docType = firstType; FullySpecifiedType docType = firstType;

View File

@@ -578,8 +578,6 @@ bool CppCodeCompletion::completeFunction(FullySpecifiedType exprTy,
QSet<QString> signatures; QSet<QString> signatures;
foreach (TypeOfExpression::Result p, resolvedTypes) { foreach (TypeOfExpression::Result p, resolvedTypes) {
FullySpecifiedType ty = p.first; FullySpecifiedType ty = p.first;
if (! ty)
continue;
if (Function *fun = ty->asFunctionType()) { if (Function *fun = ty->asFunctionType()) {
if (TextEditor::CompletionItem item = toCompletionItem(fun)) { if (TextEditor::CompletionItem item = toCompletionItem(fun)) {
QString signature; QString signature;
@@ -602,7 +600,7 @@ bool CppCodeCompletion::completeFunction(FullySpecifiedType exprTy,
bool CppCodeCompletion::completeMember(const QList<TypeOfExpression::Result> &results, bool CppCodeCompletion::completeMember(const QList<TypeOfExpression::Result> &results,
const LookupContext &context) const LookupContext &context)
{ {
if (results.isEmpty() || ! results.first().first) if (results.isEmpty())
return false; return false;
TypeOfExpression::Result result = results.first(); TypeOfExpression::Result result = results.first();
@@ -898,10 +896,7 @@ bool CppCodeCompletion::completeConstructors(Class *klass)
for (unsigned i = 0; i < klass->memberCount(); ++i) { for (unsigned i = 0; i < klass->memberCount(); ++i) {
Symbol *member = klass->memberAt(i); Symbol *member = klass->memberAt(i);
FullySpecifiedType memberTy = member->type(); if (! member->type()->isFunctionType())
if (! memberTy)
continue;
else if (! memberTy->isFunctionType())
continue; continue;
else if (! member->identity()) else if (! member->identity())
continue; continue;
@@ -935,12 +930,8 @@ bool CppCodeCompletion::completeQtMethod(CPlusPlus::FullySpecifiedType,
QSet<QString> signatures; QSet<QString> signatures;
foreach (TypeOfExpression::Result p, results) { foreach (TypeOfExpression::Result p, results) {
FullySpecifiedType ty = p.first; FullySpecifiedType ty = p.first;
if (! ty)
continue;
if (ReferenceType *refTy = ty->asReferenceType()) if (ReferenceType *refTy = ty->asReferenceType())
ty = refTy->elementType(); ty = refTy->elementType();
if (PointerType *ptrTy = ty->asPointerType()) if (PointerType *ptrTy = ty->asPointerType())
ty = ptrTy->elementType(); ty = ptrTy->elementType();
else else
@@ -968,8 +959,6 @@ bool CppCodeCompletion::completeQtMethod(CPlusPlus::FullySpecifiedType,
for (unsigned i = 0; i < scope->symbolCount(); ++i) { for (unsigned i = 0; i < scope->symbolCount(); ++i) {
Symbol *member = scope->symbolAt(i); Symbol *member = scope->symbolAt(i);
if (! member->type())
continue;
Function *fun = member->type()->asFunctionType(); Function *fun = member->type()->asFunctionType();
if (! fun) if (! fun)
continue; continue;
@@ -1127,15 +1116,13 @@ void CppCodeCompletion::complete(const TextEditor::CompletionItem &item)
extraChars += QLatin1Char('('); extraChars += QLatin1Char('(');
// If the function takes no arguments, automatically place the closing parenthesis // If the function takes no arguments, automatically place the closing parenthesis
if (function->argumentCount() == 0 || (function->argumentCount() == 1 && if (function->argumentCount() == 0 || (function->argumentCount() == 1 &&
function->argumentAt(0)->type() &&
function->argumentAt(0)->type()->isVoidType())) { function->argumentAt(0)->type()->isVoidType())) {
extraChars += QLatin1Char(')'); extraChars += QLatin1Char(')');
// If the function doesn't return anything, automatically place the semicolon, // If the function doesn't return anything, automatically place the semicolon,
// unless we're doing a scope completion (then it might be function definition). // unless we're doing a scope completion (then it might be function definition).
FullySpecifiedType retTy = function->returnType(); if (function->returnType()->isVoidType() && m_completionOperator != T_COLON_COLON) {
if (retTy && retTy->isVoidType() && m_completionOperator != T_COLON_COLON) {
extraChars += QLatin1Char(';'); extraChars += QLatin1Char(';');
} }
} }

View File

@@ -320,8 +320,8 @@ bool CheckExpression::visit(QtMethodAST *ast)
Scope dummy; Scope dummy;
FullySpecifiedType methTy = semantic()->check(ast->declarator, FullySpecifiedType(), FullySpecifiedType methTy = semantic()->check(ast->declarator, FullySpecifiedType(),
&dummy, &name); &dummy, &name);
Function *fty = 0; Function *fty = methTy->asFunctionType();
if (! methTy || 0 == (fty = methTy->asFunctionType())) if (! fty)
translationUnit()->warning(ast->firstToken(), "expected a function declarator"); translationUnit()->warning(ast->firstToken(), "expected a function declarator");
else { else {
for (unsigned i = 0; i < fty->argumentCount(); ++i) { for (unsigned i = 0; i < fty->argumentCount(); ++i) {