From 467bbc0b525615d998de845b33b4d2378364dd8c Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Sat, 30 Jul 2011 21:52:14 -0700 Subject: [PATCH] Cosmetics. --- .../AbstractClassInstantiationChecker.java | 32 +++++++++---------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/AbstractClassInstantiationChecker.java b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/AbstractClassInstantiationChecker.java index 6554b9ed9d4..33028a04ed6 100644 --- a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/AbstractClassInstantiationChecker.java +++ b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/AbstractClassInstantiationChecker.java @@ -79,7 +79,7 @@ public class AbstractClassInstantiationChecker extends AbstractIndexAstChecker { // Looking for the variables declarations. if (declaration instanceof IASTSimpleDeclaration) { // If there is at least one non-pointer and non-reference type... - IASTSimpleDeclaration simpleDecl = (IASTSimpleDeclaration)declaration; + IASTSimpleDeclaration simpleDecl = (IASTSimpleDeclaration) declaration; IASTDeclSpecifier declSpec = simpleDecl.getDeclSpecifier(); if (declSpec.getStorageClass() != IASTDeclSpecifier.sc_typedef) { for (IASTDeclarator declarator : simpleDecl.getDeclarators()) { @@ -111,34 +111,33 @@ public class AbstractClassInstantiationChecker extends AbstractIndexAstChecker { private void checkClass(IASTDeclSpecifier declSpec) { if (declSpec instanceof ICPPASTNamedTypeSpecifier) { - IASTName className = ((ICPPASTNamedTypeSpecifier)declSpec).getName(); + IASTName className = ((ICPPASTNamedTypeSpecifier) declSpec).getName(); IBinding binding = className.resolveBinding(); if (binding instanceof IType) { - // Resolve class and check whether it is abstract - reportProblemsIfAbstract((IType)binding, className); + // Resolve class and check whether it is abstract. + reportProblemsIfAbstract((IType) binding, className); } } } public int visit(IASTExpression expression) { - // Looking for the new expression if (expression instanceof ICPPASTNewExpression) { - ICPPASTNewExpression newExpression = (ICPPASTNewExpression)expression; + // New expression. + ICPPASTNewExpression newExpression = (ICPPASTNewExpression) expression; if (!hasPointerOrReference(newExpression.getTypeId().getAbstractDeclarator())) { // Try to resolve its implicit constructor IASTDeclSpecifier declSpecifier = newExpression.getTypeId().getDeclSpecifier(); if (declSpecifier instanceof ICPPASTNamedTypeSpecifier) { - IASTName constructorName = ((ICPPASTNamedTypeSpecifier)declSpecifier).getName(); + IASTName constructorName = ((ICPPASTNamedTypeSpecifier) declSpecifier).getName(); checkClassConstructor(constructorName); } } - } - // Looking for direct class constructor call and check it. - else if (expression instanceof ICPPASTFunctionCallExpression) { - ICPPASTFunctionCallExpression functionCall = (ICPPASTFunctionCallExpression)expression; + } else if (expression instanceof ICPPASTFunctionCallExpression) { + // Direct constructor call. + ICPPASTFunctionCallExpression functionCall = (ICPPASTFunctionCallExpression) expression; IASTExpression functionName = functionCall.getFunctionNameExpression(); if (functionName instanceof IASTIdExpression) { - IASTName constructorName = ((IASTIdExpression)functionName).getName(); + IASTName constructorName = ((IASTIdExpression) functionName).getName(); checkClassConstructor(constructorName); } } @@ -153,10 +152,9 @@ public class AbstractClassInstantiationChecker extends AbstractIndexAstChecker { IBinding binding = constructorName.resolveBinding(); if (binding instanceof ICPPConstructor) { // Resolve class and check whether it is abstract. - reportProblemsIfAbstract(((ICPPConstructor)binding).getClassOwner(), constructorName); - } - else if (binding instanceof IType) { - reportProblemsIfAbstract((IType)binding, constructorName); + reportProblemsIfAbstract(((ICPPConstructor) binding).getClassOwner(), constructorName); + } else if (binding instanceof IType) { + reportProblemsIfAbstract((IType) binding, constructorName); } } @@ -187,7 +185,7 @@ public class AbstractClassInstantiationChecker extends AbstractIndexAstChecker { private void reportProblemsIfAbstract(IType typeToCheck, IASTNode problemNode ) { IType unwindedType = CxxAstUtils.getInstance().unwindTypedef(typeToCheck); if (unwindedType instanceof ICPPClassType) { - ICPPClassType classType = (ICPPClassType)unwindedType; + ICPPClassType classType = (ICPPClassType) unwindedType; ICPPMethod[] pureVirtualMethods; if (pureVirtualMethodsCache.containsKey(classType)) { pureVirtualMethods = pureVirtualMethodsCache.get(classType);