From 72b60757333e37599ae117c9472ac821c4ebbca7 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Sun, 17 Jul 2011 19:38:57 -0700 Subject: [PATCH] Cosmetics. --- .../core/dom/parser/cpp/CPPMethod.java | 54 ++++++++++--------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethod.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethod.java index b4d0bd3301f..7067ca1b3e6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethod.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethod.java @@ -40,7 +40,7 @@ public class CPPMethod extends CPPFunction implements ICPPMethod { public CPPMethod(IASTDeclarator declarator) { super(declarator); } - + public IASTDeclaration getPrimaryDeclaration() { //first check if we already know it if (declarations != null) { @@ -60,7 +60,7 @@ public class CPPMethod extends CPPFunction implements ICPPMethod { if (decl.getParent() instanceof ICPPASTCompositeTypeSpecifier) return decl; } - + final char[] myName = getASTName().getLookupKey(); ICPPClassScope scope = (ICPPClassScope) getScope(); ICPPASTCompositeTypeSpecifier compSpec = (ICPPASTCompositeTypeSpecifier) ASTInternal.getPhysicalNodeOfScope(scope); @@ -91,33 +91,34 @@ public class CPPMethod extends CPPFunction implements ICPPMethod { */ public int getVisibility() { IASTDeclaration decl = getPrimaryDeclaration(); - if( decl == null ){ + if (decl == null) { IScope scope = getScope(); - if( scope instanceof ICPPClassScope ){ + if (scope instanceof ICPPClassScope) { ICPPClassType cls = ((ICPPClassScope)scope).getClassType(); - if( cls != null ) - return ( cls.getKey() == ICPPClassType.k_class ) ? ICPPASTVisibilityLabel.v_private : ICPPASTVisibilityLabel.v_public; + if (cls != null) + return (cls.getKey() == ICPPClassType.k_class) ? ICPPASTVisibilityLabel.v_private : ICPPASTVisibilityLabel.v_public; } return ICPPASTVisibilityLabel.v_private; } - + IASTCompositeTypeSpecifier cls = (IASTCompositeTypeSpecifier) decl.getParent(); IASTDeclaration [] members = cls.getMembers(); ICPPASTVisibilityLabel vis = null; for (IASTDeclaration member : members) { - if( member instanceof ICPPASTVisibilityLabel ) + if (member instanceof ICPPASTVisibilityLabel) { vis = (ICPPASTVisibilityLabel) member; - else if( member == decl ) + } else if (member == decl) { break; + } } - if( vis != null ){ + if (vis != null) { return vis.getVisibility(); - } else if( cls.getKey() == ICPPASTCompositeTypeSpecifier.k_class ){ + } else if (cls.getKey() == ICPPASTCompositeTypeSpecifier.k_class) { return ICPPASTVisibilityLabel.v_private; - } + } return ICPPASTVisibilityLabel.v_public; } - + public ICPPClassType getClassOwner() { ICPPClassScope scope = (ICPPClassScope)getScope(); return scope.getClassType(); @@ -139,15 +140,15 @@ public class CPPMethod extends CPPFunction implements ICPPMethod { public IScope getScope() { return CPPVisitor.getContainingScope(getASTName()); } - + /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod#isVirtual() */ public boolean isVirtual() { IASTDeclaration decl = getPrimaryDeclaration(); - if( decl != null ){ + if (decl != null) { ICPPASTDeclSpecifier declSpec = getDeclSpec(decl); - if( declSpec != null ){ + if (declSpec != null) { return declSpec.isVirtual(); } } @@ -156,10 +157,11 @@ public class CPPMethod extends CPPFunction implements ICPPMethod { protected ICPPASTDeclSpecifier getDeclSpec(IASTDeclaration decl) { ICPPASTDeclSpecifier declSpec = null; - if( decl instanceof IASTSimpleDeclaration ) + if (decl instanceof IASTSimpleDeclaration) { declSpec = (ICPPASTDeclSpecifier) ((IASTSimpleDeclaration)decl).getDeclSpecifier(); - else if( decl instanceof IASTFunctionDefinition ) + } else if (decl instanceof IASTFunctionDefinition) { declSpec = (ICPPASTDeclSpecifier) ((IASTFunctionDefinition)decl).getDeclSpecifier(); + } return declSpec; } @@ -169,11 +171,11 @@ public class CPPMethod extends CPPFunction implements ICPPMethod { @Override public boolean isInline() { IASTDeclaration decl = getPrimaryDeclaration(); - if( decl instanceof IASTFunctionDefinition ) + if (decl instanceof IASTFunctionDefinition) return true; - if( decl == null ) + if (decl == null) return false; - + IASTDeclSpecifier declSpec = ((IASTSimpleDeclaration)decl).getDeclSpecifier(); return declSpec.isInline(); } @@ -183,9 +185,9 @@ public class CPPMethod extends CPPFunction implements ICPPMethod { */ @Override public boolean isMutable() { - return hasStorageClass( this, IASTDeclSpecifier.sc_mutable ); + return hasStorageClass(this, IASTDeclSpecifier.sc_mutable); } - + @Override public boolean isStatic(boolean resolveAll) { IASTDeclaration decl = getPrimaryDeclaration(); @@ -205,21 +207,21 @@ public class CPPMethod extends CPPFunction implements ICPPMethod { char[] name = getNameCharArray(); if (name.length > 1 && name[0] == '~') return true; - + return false; } public boolean isImplicit() { return false; } - + /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod#isPureVirtual() */ public boolean isPureVirtual() { if (declarations != null) { for (IASTDeclarator dtor : declarations) { - if (dtor == null) + if (dtor == null) break; dtor = ASTQueries.findOutermostDeclarator(dtor);