1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2009-05-31 00:29:07 +00:00
parent fc4176c35f
commit aecdc9e38c

View file

@ -37,54 +37,54 @@ import org.eclipse.core.runtime.PlatformObject;
*/
public class CEnumeration extends PlatformObject implements IEnumeration, ICInternalBinding {
private IASTName [] declarations = null;
private IASTName[] declarations = null;
private IASTName definition = null;
public CEnumeration( IASTName enumeration ){
public CEnumeration(IASTName enumeration) {
ASTNodeProperty prop = enumeration.getPropertyInParent();
if( prop == IASTElaboratedTypeSpecifier.TYPE_NAME )
if (prop == IASTElaboratedTypeSpecifier.TYPE_NAME)
declarations = new IASTName[] { enumeration };
else
definition = enumeration;
enumeration.setBinding( this );
enumeration.setBinding(this);
}
public void addDeclaration(IASTName decl) {
if (!decl.isActive())
return;
if( decl.getPropertyInParent() != IASTElaboratedTypeSpecifier.TYPE_NAME )
if (decl.getPropertyInParent() != IASTElaboratedTypeSpecifier.TYPE_NAME)
return;
decl.setBinding( this );
if( declarations == null ){
decl.setBinding(this);
if (declarations == null) {
declarations = new IASTName[] { decl };
return;
}
for( int i = 0; i < declarations.length; i++ ){
if( declarations[i] == null ){
for (int i = 0; i < declarations.length; i++) {
if (declarations[i] == null) {
declarations[i] = decl;
return;
}
}
IASTName tmp [] = new IASTName [ declarations.length * 2 ];
System.arraycopy( declarations, 0, tmp, 0, declarations.length );
tmp[ declarations.length ] = decl;
IASTName tmp[] = new IASTName[declarations.length * 2];
System.arraycopy(declarations, 0, tmp, 0, declarations.length);
tmp[declarations.length] = decl;
declarations = tmp;
}
public IASTNode getPhysicalNode(){
if( definition != null )
public IASTNode getPhysicalNode() {
if (definition != null)
return definition;
return declarations[0];
}
private void checkForDefinition(){
IASTDeclSpecifier spec = CVisitor.findDefinition( (ICASTElaboratedTypeSpecifier) declarations[0].getParent() );
if( spec != null && spec instanceof ICASTEnumerationSpecifier ){
private void checkForDefinition() {
IASTDeclSpecifier spec = CVisitor.findDefinition((ICASTElaboratedTypeSpecifier) declarations[0].getParent());
if (spec != null && spec instanceof ICASTEnumerationSpecifier) {
ICASTEnumerationSpecifier enumSpec = (ICASTEnumerationSpecifier) spec;
enumSpec.getName().setBinding( this );
enumSpec.getName().setBinding(this);
definition = enumSpec.getName();
}
return;
@ -94,13 +94,13 @@ public class CEnumeration extends PlatformObject implements IEnumeration, ICInte
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
*/
public String getName() {
if( definition != null )
if (definition != null)
return definition.toString();
return declarations[0].toString();
}
public char[] getNameCharArray(){
if( definition != null )
public char[] getNameCharArray() {
if (definition != null)
return definition.toCharArray();
return declarations[0].toCharArray();
@ -110,15 +110,15 @@ public class CEnumeration extends PlatformObject implements IEnumeration, ICInte
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
*/
public IScope getScope() {
return CVisitor.getContainingScope( definition != null ? definition : declarations[0].getParent() );
return CVisitor.getContainingScope(definition != null ? definition : declarations[0].getParent());
}
@Override
public Object clone(){
public Object clone() {
IType t = null;
try {
t = (IType) super.clone();
} catch ( CloneNotSupportedException e ) {
} catch (CloneNotSupportedException e) {
//not going to happen
}
return t;
@ -128,17 +128,17 @@ public class CEnumeration extends PlatformObject implements IEnumeration, ICInte
* @see org.eclipse.cdt.core.dom.ast.IEnumeration#getEnumerators()
*/
public IEnumerator[] getEnumerators() {
if( definition == null ){
if (definition == null) {
checkForDefinition();
if( definition == null )
return new IEnumerator[] { new CEnumerator.CEnumeratorProblem( declarations[0], IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, declarations[0].toCharArray() ) };
if (definition == null)
return new IEnumerator[] { new CEnumerator.CEnumeratorProblem(declarations[0], IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, declarations[0].toCharArray()) };
}
IASTEnumerationSpecifier enumSpec = (IASTEnumerationSpecifier) definition.getParent();
IASTEnumerationSpecifier.IASTEnumerator[] enums = enumSpec.getEnumerators();
IEnumerator [] bindings = new IEnumerator [ enums.length ];
IEnumerator[] bindings = new IEnumerator[enums.length];
for( int i = 0; i < enums.length; i++ ){
for (int i = 0; i < enums.length; i++) {
bindings[i] = (IEnumerator) enums[i].getName().resolveBinding();
}
return bindings;
@ -152,11 +152,11 @@ public class CEnumeration extends PlatformObject implements IEnumeration, ICInte
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType)
*/
public boolean isSameType( IType type ) {
if( type == this )
public boolean isSameType(IType type) {
if (type == this)
return true;
if( type instanceof ITypedef || type instanceof IIndexType)
return type.isSameType( this );
if (type instanceof ITypedef || type instanceof IIndexType)
return type.isSameType(this);
return false;
}