1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2011-07-17 19:38:57 -07:00
parent d3264a7418
commit 72b6075733

View file

@ -40,7 +40,7 @@ public class CPPMethod extends CPPFunction implements ICPPMethod {
public CPPMethod(IASTDeclarator declarator) { public CPPMethod(IASTDeclarator declarator) {
super(declarator); super(declarator);
} }
public IASTDeclaration getPrimaryDeclaration() { public IASTDeclaration getPrimaryDeclaration() {
//first check if we already know it //first check if we already know it
if (declarations != null) { if (declarations != null) {
@ -60,7 +60,7 @@ public class CPPMethod extends CPPFunction implements ICPPMethod {
if (decl.getParent() instanceof ICPPASTCompositeTypeSpecifier) if (decl.getParent() instanceof ICPPASTCompositeTypeSpecifier)
return decl; return decl;
} }
final char[] myName = getASTName().getLookupKey(); final char[] myName = getASTName().getLookupKey();
ICPPClassScope scope = (ICPPClassScope) getScope(); ICPPClassScope scope = (ICPPClassScope) getScope();
ICPPASTCompositeTypeSpecifier compSpec = (ICPPASTCompositeTypeSpecifier) ASTInternal.getPhysicalNodeOfScope(scope); ICPPASTCompositeTypeSpecifier compSpec = (ICPPASTCompositeTypeSpecifier) ASTInternal.getPhysicalNodeOfScope(scope);
@ -91,33 +91,34 @@ public class CPPMethod extends CPPFunction implements ICPPMethod {
*/ */
public int getVisibility() { public int getVisibility() {
IASTDeclaration decl = getPrimaryDeclaration(); IASTDeclaration decl = getPrimaryDeclaration();
if( decl == null ){ if (decl == null) {
IScope scope = getScope(); IScope scope = getScope();
if( scope instanceof ICPPClassScope ){ if (scope instanceof ICPPClassScope) {
ICPPClassType cls = ((ICPPClassScope)scope).getClassType(); ICPPClassType cls = ((ICPPClassScope)scope).getClassType();
if( cls != null ) if (cls != null)
return ( cls.getKey() == ICPPClassType.k_class ) ? ICPPASTVisibilityLabel.v_private : ICPPASTVisibilityLabel.v_public; return (cls.getKey() == ICPPClassType.k_class) ? ICPPASTVisibilityLabel.v_private : ICPPASTVisibilityLabel.v_public;
} }
return ICPPASTVisibilityLabel.v_private; return ICPPASTVisibilityLabel.v_private;
} }
IASTCompositeTypeSpecifier cls = (IASTCompositeTypeSpecifier) decl.getParent(); IASTCompositeTypeSpecifier cls = (IASTCompositeTypeSpecifier) decl.getParent();
IASTDeclaration [] members = cls.getMembers(); IASTDeclaration [] members = cls.getMembers();
ICPPASTVisibilityLabel vis = null; ICPPASTVisibilityLabel vis = null;
for (IASTDeclaration member : members) { for (IASTDeclaration member : members) {
if( member instanceof ICPPASTVisibilityLabel ) if (member instanceof ICPPASTVisibilityLabel) {
vis = (ICPPASTVisibilityLabel) member; vis = (ICPPASTVisibilityLabel) member;
else if( member == decl ) } else if (member == decl) {
break; break;
}
} }
if( vis != null ){ if (vis != null) {
return vis.getVisibility(); return vis.getVisibility();
} else if( cls.getKey() == ICPPASTCompositeTypeSpecifier.k_class ){ } else if (cls.getKey() == ICPPASTCompositeTypeSpecifier.k_class) {
return ICPPASTVisibilityLabel.v_private; return ICPPASTVisibilityLabel.v_private;
} }
return ICPPASTVisibilityLabel.v_public; return ICPPASTVisibilityLabel.v_public;
} }
public ICPPClassType getClassOwner() { public ICPPClassType getClassOwner() {
ICPPClassScope scope = (ICPPClassScope)getScope(); ICPPClassScope scope = (ICPPClassScope)getScope();
return scope.getClassType(); return scope.getClassType();
@ -139,15 +140,15 @@ public class CPPMethod extends CPPFunction implements ICPPMethod {
public IScope getScope() { public IScope getScope() {
return CPPVisitor.getContainingScope(getASTName()); return CPPVisitor.getContainingScope(getASTName());
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod#isVirtual() * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod#isVirtual()
*/ */
public boolean isVirtual() { public boolean isVirtual() {
IASTDeclaration decl = getPrimaryDeclaration(); IASTDeclaration decl = getPrimaryDeclaration();
if( decl != null ){ if (decl != null) {
ICPPASTDeclSpecifier declSpec = getDeclSpec(decl); ICPPASTDeclSpecifier declSpec = getDeclSpec(decl);
if( declSpec != null ){ if (declSpec != null) {
return declSpec.isVirtual(); return declSpec.isVirtual();
} }
} }
@ -156,10 +157,11 @@ public class CPPMethod extends CPPFunction implements ICPPMethod {
protected ICPPASTDeclSpecifier getDeclSpec(IASTDeclaration decl) { protected ICPPASTDeclSpecifier getDeclSpec(IASTDeclaration decl) {
ICPPASTDeclSpecifier declSpec = null; ICPPASTDeclSpecifier declSpec = null;
if( decl instanceof IASTSimpleDeclaration ) if (decl instanceof IASTSimpleDeclaration) {
declSpec = (ICPPASTDeclSpecifier) ((IASTSimpleDeclaration)decl).getDeclSpecifier(); declSpec = (ICPPASTDeclSpecifier) ((IASTSimpleDeclaration)decl).getDeclSpecifier();
else if( decl instanceof IASTFunctionDefinition ) } else if (decl instanceof IASTFunctionDefinition) {
declSpec = (ICPPASTDeclSpecifier) ((IASTFunctionDefinition)decl).getDeclSpecifier(); declSpec = (ICPPASTDeclSpecifier) ((IASTFunctionDefinition)decl).getDeclSpecifier();
}
return declSpec; return declSpec;
} }
@ -169,11 +171,11 @@ public class CPPMethod extends CPPFunction implements ICPPMethod {
@Override @Override
public boolean isInline() { public boolean isInline() {
IASTDeclaration decl = getPrimaryDeclaration(); IASTDeclaration decl = getPrimaryDeclaration();
if( decl instanceof IASTFunctionDefinition ) if (decl instanceof IASTFunctionDefinition)
return true; return true;
if( decl == null ) if (decl == null)
return false; return false;
IASTDeclSpecifier declSpec = ((IASTSimpleDeclaration)decl).getDeclSpecifier(); IASTDeclSpecifier declSpec = ((IASTSimpleDeclaration)decl).getDeclSpecifier();
return declSpec.isInline(); return declSpec.isInline();
} }
@ -183,9 +185,9 @@ public class CPPMethod extends CPPFunction implements ICPPMethod {
*/ */
@Override @Override
public boolean isMutable() { public boolean isMutable() {
return hasStorageClass( this, IASTDeclSpecifier.sc_mutable ); return hasStorageClass(this, IASTDeclSpecifier.sc_mutable);
} }
@Override @Override
public boolean isStatic(boolean resolveAll) { public boolean isStatic(boolean resolveAll) {
IASTDeclaration decl = getPrimaryDeclaration(); IASTDeclaration decl = getPrimaryDeclaration();
@ -205,21 +207,21 @@ public class CPPMethod extends CPPFunction implements ICPPMethod {
char[] name = getNameCharArray(); char[] name = getNameCharArray();
if (name.length > 1 && name[0] == '~') if (name.length > 1 && name[0] == '~')
return true; return true;
return false; return false;
} }
public boolean isImplicit() { public boolean isImplicit() {
return false; return false;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod#isPureVirtual() * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod#isPureVirtual()
*/ */
public boolean isPureVirtual() { public boolean isPureVirtual() {
if (declarations != null) { if (declarations != null) {
for (IASTDeclarator dtor : declarations) { for (IASTDeclarator dtor : declarations) {
if (dtor == null) if (dtor == null)
break; break;
dtor = ASTQueries.findOutermostDeclarator(dtor); dtor = ASTQueries.findOutermostDeclarator(dtor);