1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-06 17:26:01 +02:00

Code formatting.

This commit is contained in:
Sergey Prigogin 2008-11-09 05:01:57 +00:00
parent 4f541baeb7
commit fc22e5fdce
10 changed files with 94 additions and 119 deletions

View file

@ -21,7 +21,7 @@ import org.eclipse.cdt.core.dom.ast.IField;
* @author Doug Schaefer
*/
public interface ICPPClassType extends ICompositeType, ICPPBinding {
public static final ICPPClassType [] EMPTY_CLASS_ARRAY = new ICPPClassType[0];
public static final ICPPClassType[] EMPTY_CLASS_ARRAY = new ICPPClassType[0];
public static final int k_class = ICPPASTCompositeTypeSpecifier.k_class;
/**
@ -103,5 +103,5 @@ public interface ICPPClassType extends ICompositeType, ICPPBinding {
* return an array of nested classes/structures
* @throws DOMException
*/
public ICPPClassType [] getNestedClasses() throws DOMException;
public ICPPClassType[] getNestedClasses() throws DOMException;
}

View file

@ -33,13 +33,11 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
* @author jcamelon
*/
public class CASTDeclarator extends ASTNode implements IASTDeclarator, IASTAmbiguityParent {
private IASTInitializer initializer;
private IASTName name;
private IASTDeclarator nestedDeclarator;
private IASTPointerOperator [] pointerOps = null;
private int pointerOpsPos=-1;
private IASTPointerOperator[] pointerOps = null;
private int pointerOpsPos= -1;
public CASTDeclarator() {
}
@ -54,8 +52,8 @@ public class CASTDeclarator extends ASTNode implements IASTDeclarator, IASTAmbig
}
public IASTPointerOperator[] getPointerOperators() {
if( pointerOps == null ) return IASTPointerOperator.EMPTY_ARRAY;
pointerOps = (IASTPointerOperator[]) ArrayUtil.removeNullsAfter( IASTPointerOperator.class, pointerOps, pointerOpsPos );
if (pointerOps == null) return IASTPointerOperator.EMPTY_ARRAY;
pointerOps = (IASTPointerOperator[]) ArrayUtil.removeNullsAfter(IASTPointerOperator.class, pointerOps, pointerOpsPos);
return pointerOps;
}
@ -71,7 +69,6 @@ public class CASTDeclarator extends ASTNode implements IASTDeclarator, IASTAmbig
return initializer;
}
public void setInitializer(IASTInitializer initializer) {
this.initializer = initializer;
if (initializer != null) {
@ -84,7 +81,7 @@ public class CASTDeclarator extends ASTNode implements IASTDeclarator, IASTAmbig
if (operator != null) {
operator.setParent(this);
operator.setPropertyInParent(POINTER_OPERATOR);
pointerOps = (IASTPointerOperator[]) ArrayUtil.append( IASTPointerOperator.class, pointerOps, ++pointerOpsPos, operator );
pointerOps = (IASTPointerOperator[]) ArrayUtil.append(IASTPointerOperator.class, pointerOps, ++pointerOpsPos, operator);
}
}
@ -105,35 +102,36 @@ public class CASTDeclarator extends ASTNode implements IASTDeclarator, IASTAmbig
}
@Override
public boolean accept( ASTVisitor action ){
if( action.shouldVisitDeclarators ){
switch( action.visit( this ) ){
public boolean accept(ASTVisitor action) {
if (action.shouldVisitDeclarators) {
switch(action.visit(this)) {
case ASTVisitor.PROCESS_ABORT : return false;
case ASTVisitor.PROCESS_SKIP : return true;
default : break;
}
}
if( getPropertyInParent() != IASTTypeId.ABSTRACT_DECLARATOR &&
nestedDeclarator == null )
{
if( getParent() instanceof IASTDeclarator )
{
if (getPropertyInParent() != IASTTypeId.ABSTRACT_DECLARATOR && nestedDeclarator == null) {
if (getParent() instanceof IASTDeclarator) {
IASTDeclarator outermostDeclarator = (IASTDeclarator) getParent();
while( outermostDeclarator.getParent() instanceof IASTDeclarator )
while (outermostDeclarator.getParent() instanceof IASTDeclarator)
outermostDeclarator = (IASTDeclarator) outermostDeclarator.getParent();
if( outermostDeclarator.getPropertyInParent() != IASTTypeId.ABSTRACT_DECLARATOR )
if( name != null ) if( !name.accept( action ) ) return false;
if (outermostDeclarator.getPropertyInParent() != IASTTypeId.ABSTRACT_DECLARATOR &&
name != null && !name.accept(action)) {
return false;
}
} else if (name != null && !name.accept(action)) {
return false;
}
else
if( name != null ) if( !name.accept( action ) ) return false;
}
if( nestedDeclarator != null ) if( !nestedDeclarator.accept( action ) ) return false;
if (nestedDeclarator != null && !nestedDeclarator.accept(action)) {
return false;
}
IASTPointerOperator [] ptrOps = getPointerOperators();
for ( int i = 0; i < ptrOps.length; i++ ) {
if( !ptrOps[i].accept( action ) ) return false;
IASTPointerOperator[] ptrOps = getPointerOperators();
for (int i = 0; i < ptrOps.length; i++) {
if (!ptrOps[i].accept(action))
return false;
}
if (!postAccept(action))
@ -145,67 +143,59 @@ public class CASTDeclarator extends ASTNode implements IASTDeclarator, IASTAmbig
return true;
}
protected boolean postAccept( ASTVisitor action ){
protected boolean postAccept(ASTVisitor action) {
if (initializer != null && !initializer.accept(action))
return false;
return true;
}
public int getRoleForName(IASTName n ) {
if( n == this.name )
{
public int getRoleForName(IASTName n) {
if (n == this.name) {
IASTNode getParent = getParent();
boolean fnDtor = ( this instanceof IASTFunctionDeclarator );
if( getParent instanceof IASTDeclaration )
{
if( getParent instanceof IASTFunctionDefinition )
boolean fnDtor = (this instanceof IASTFunctionDeclarator);
if (getParent instanceof IASTDeclaration) {
if (getParent instanceof IASTFunctionDefinition)
return r_definition;
if( getParent instanceof IASTSimpleDeclaration )
{
if (getParent instanceof IASTSimpleDeclaration) {
IASTSimpleDeclaration sd = (IASTSimpleDeclaration) getParent;
int storage = sd.getDeclSpecifier().getStorageClass();
if( getInitializer() != null || storage == IASTDeclSpecifier.sc_typedef )
if (getInitializer() != null || storage == IASTDeclSpecifier.sc_typedef)
return r_definition;
if( storage == IASTDeclSpecifier.sc_extern ||
storage == IASTDeclSpecifier.sc_static )
{
return r_declaration;
}
if (storage == IASTDeclSpecifier.sc_extern || storage == IASTDeclSpecifier.sc_static) {
return r_declaration;
}
return fnDtor ? r_declaration : r_definition;
}
}
if( getParent instanceof IASTTypeId )
if (getParent instanceof IASTTypeId)
return r_reference;
if( getParent instanceof IASTDeclarator )
{
if (getParent instanceof IASTDeclarator) {
IASTNode t = getParent;
while ( t instanceof IASTDeclarator )
while (t instanceof IASTDeclarator)
t = t.getParent();
if( t instanceof IASTDeclaration )
{
if( getParent instanceof IASTFunctionDefinition )
if (t instanceof IASTDeclaration) {
if (getParent instanceof IASTFunctionDefinition)
return r_definition;
if( getParent instanceof IASTSimpleDeclaration )
{
if( getInitializer() != null )
if (getParent instanceof IASTSimpleDeclaration) {
if (getInitializer() != null)
return r_definition;
IASTSimpleDeclaration sd = (IASTSimpleDeclaration) getParent;
int storage = sd.getDeclSpecifier().getStorageClass();
if( storage == IASTDeclSpecifier.sc_extern ||
storage == IASTDeclSpecifier.sc_static)
if (storage == IASTDeclSpecifier.sc_extern || storage == IASTDeclSpecifier.sc_static) {
return r_declaration;
}
}
return fnDtor ? r_declaration : r_definition;
}
if( t instanceof IASTTypeId )
if (t instanceof IASTTypeId)
return r_reference;
}
if( getParent instanceof IASTParameterDeclaration )
return ( n.toCharArray().length > 0 ) ? r_definition : r_declaration;
if (getParent instanceof IASTParameterDeclaration)
return (n.toCharArray().length > 0) ? r_definition : r_declaration;
}
return r_unclear;
}

View file

@ -35,9 +35,8 @@ public class CPPASTDeclarator extends ASTNode implements IASTDeclarator {
private IASTInitializer initializer;
private IASTName name;
private IASTDeclarator nestedDeclarator;
private IASTPointerOperator [] pointerOps = null;
private int pointerOpsPos=-1;
private IASTPointerOperator[] pointerOps = null;
private int pointerOpsPos= -1;
public CPPASTDeclarator() {
}
@ -52,8 +51,8 @@ public class CPPASTDeclarator extends ASTNode implements IASTDeclarator {
}
public IASTPointerOperator[] getPointerOperators() {
if( pointerOps == null ) return IASTPointerOperator.EMPTY_ARRAY;
pointerOps = (IASTPointerOperator[]) ArrayUtil.removeNullsAfter( IASTPointerOperator.class, pointerOps, pointerOpsPos );
if (pointerOps == null) return IASTPointerOperator.EMPTY_ARRAY;
pointerOps = (IASTPointerOperator[]) ArrayUtil.removeNullsAfter(IASTPointerOperator.class, pointerOps, pointerOpsPos);
return pointerOps;
}
@ -81,7 +80,7 @@ public class CPPASTDeclarator extends ASTNode implements IASTDeclarator {
if (operator != null) {
operator.setParent(this);
operator.setPropertyInParent(POINTER_OPERATOR);
pointerOps = (IASTPointerOperator[]) ArrayUtil.append( IASTPointerOperator.class, pointerOps, ++pointerOpsPos, operator );
pointerOps = (IASTPointerOperator[]) ArrayUtil.append(IASTPointerOperator.class, pointerOps, ++pointerOpsPos, operator);
}
}
@ -93,7 +92,6 @@ public class CPPASTDeclarator extends ASTNode implements IASTDeclarator {
}
}
public void setName(IASTName name) {
this.name = name;
if (name != null) {
@ -103,18 +101,18 @@ public class CPPASTDeclarator extends ASTNode implements IASTDeclarator {
}
@Override
public boolean accept( ASTVisitor action ){
if( action.shouldVisitDeclarators ){
switch( action.visit( this ) ){
case ASTVisitor.PROCESS_ABORT : return false;
case ASTVisitor.PROCESS_SKIP : return true;
public boolean accept(ASTVisitor action) {
if (action.shouldVisitDeclarators) {
switch(action.visit(this)) {
case ASTVisitor.PROCESS_ABORT: return false;
case ASTVisitor.PROCESS_SKIP: return true;
default : break;
}
}
IASTPointerOperator [] ptrOps = getPointerOperators();
for ( int i = 0; i < ptrOps.length; i++ ) {
if( !ptrOps[i].accept( action ) ) return false;
IASTPointerOperator[] ptrOps = getPointerOperators();
for (int i = 0; i < ptrOps.length; i++) {
if (!ptrOps[i].accept(action)) return false;
}
if (nestedDeclarator == null && name != null) {
@ -147,55 +145,47 @@ public class CPPASTDeclarator extends ASTNode implements IASTDeclarator {
public int getRoleForName(IASTName n) {
IASTNode getParent = getParent();
boolean fnDtor = ( this instanceof IASTFunctionDeclarator );
if( getParent instanceof IASTDeclaration )
{
if( getParent instanceof IASTFunctionDefinition )
boolean fnDtor = (this instanceof IASTFunctionDeclarator);
if (getParent instanceof IASTDeclaration) {
if (getParent instanceof IASTFunctionDefinition)
return r_definition;
if( getParent instanceof IASTSimpleDeclaration ) {
if (getParent instanceof IASTSimpleDeclaration) {
final int storage = ((IASTSimpleDeclaration) getParent).getDeclSpecifier().getStorageClass();
if( getInitializer() != null || storage == IASTDeclSpecifier.sc_typedef)
if (getInitializer() != null || storage == IASTDeclSpecifier.sc_typedef)
return r_definition;
if( storage == IASTDeclSpecifier.sc_extern ||
storage == IASTDeclSpecifier.sc_static )
{
if (storage == IASTDeclSpecifier.sc_extern || storage == IASTDeclSpecifier.sc_static) {
return r_declaration;
}
}
return fnDtor ? r_declaration : r_definition;
}
if( getParent instanceof IASTTypeId )
if (getParent instanceof IASTTypeId)
return r_reference;
if( getParent instanceof IASTDeclarator )
{
if (getParent instanceof IASTDeclarator) {
IASTNode t = getParent;
while ( t instanceof IASTDeclarator )
while (t instanceof IASTDeclarator)
t = t.getParent();
if( t instanceof IASTDeclaration )
{
if( getParent instanceof IASTFunctionDefinition )
if (t instanceof IASTDeclaration) {
if (getParent instanceof IASTFunctionDefinition)
return r_definition;
if( getParent instanceof IASTSimpleDeclaration )
{
if( getInitializer() != null )
if (getParent instanceof IASTSimpleDeclaration) {
if (getInitializer() != null)
return r_definition;
IASTSimpleDeclaration sd = (IASTSimpleDeclaration) getParent;
int storage = sd.getDeclSpecifier().getStorageClass();
if( storage == IASTDeclSpecifier.sc_extern ||
storage == IASTDeclSpecifier.sc_typedef ||
storage == IASTDeclSpecifier.sc_static )
{
if (storage == IASTDeclSpecifier.sc_extern || storage == IASTDeclSpecifier.sc_typedef ||
storage == IASTDeclSpecifier.sc_static) {
return r_declaration;
}
}
return fnDtor ? r_declaration : r_definition;
}
if( t instanceof IASTTypeId )
if (t instanceof IASTTypeId)
return r_reference;
}
if( getParent instanceof IASTParameterDeclaration )
return ( n.toCharArray().length > 0 ) ? r_definition : r_declaration;
if (getParent instanceof IASTParameterDeclaration)
return (n.toCharArray().length > 0) ? r_definition : r_declaration;
return r_unclear;
}

View file

@ -107,7 +107,7 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements
private ICPPClassTemplatePartialSpecialization[] partialSpecializations = null;
public CPPClassTemplate(IASTName name) {
public CPPClassTemplate(IASTName name) {
super(name);
}

View file

@ -251,7 +251,7 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
int pos= templateParameter.getParameterPosition() & 0xff;
int tdeclLen= declarations == null ? 0 : declarations.length;
for (int i=-1; i<tdeclLen; i++) {
for (int i= -1; i < tdeclLen; i++) {
IASTName tdecl;
if (i == -1) {
tdecl= definition;
@ -277,7 +277,7 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
int k=0;
int tdeclLen= declarations == null ? 0 : declarations.length;
for (int i=-1; i<tdeclLen && k<updateParams.length; i++) {
for (int i= -1; i < tdeclLen && k < updateParams.length; i++) {
IASTName tdecl;
if (i == -1) {
tdecl= definition;

View file

@ -211,7 +211,7 @@ public abstract class CPPTemplateParameter extends PlatformObject
return null;
IASTNode node= declarations[0];
while (node instanceof ICPPASTTemplateParameter == false) {
while (!(node instanceof ICPPASTTemplateParameter)) {
if (node == null)
return null;

View file

@ -395,7 +395,7 @@ public class CPPTemplates {
ICPPASTTemplatedTypeTemplateParameter templatedParam = (ICPPASTTemplatedTypeTemplateParameter) parent;
binding = templatedParam.getName().resolveBinding();
}
return (binding instanceof ICPPTemplateDefinition) ? (ICPPTemplateDefinition) binding : null;
return (binding instanceof ICPPTemplateDefinition) ? (ICPPTemplateDefinition) binding : null;
}
public static IBinding createBinding(ICPPASTTemplateParameter templateParameter) {

View file

@ -66,8 +66,7 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
private ICPPClassScope fScope;
public PDOMCPPClassType(PDOM pdom, PDOMNode parent, ICPPClassType classType)
throws CoreException {
public PDOMCPPClassType(PDOM pdom, PDOMNode parent, ICPPClassType classType) throws CoreException {
super(pdom, parent, classType.getNameCharArray());
setKind(classType);
@ -89,7 +88,6 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
return IIndexCPPBindingConstants.CPPCLASSTYPE;
}
@Override
public void update(PDOMLinkage linkage, IBinding newBinding) throws CoreException {
if (newBinding instanceof ICPPClassType) {
@ -142,7 +140,6 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
list.accept(visitor);
}
private PDOMCPPBase getFirstBase() throws CoreException {
int rec = pdom.getDB().getInt(record + FIRSTBASE);
return rec != 0 ? new PDOMCPPBase(pdom, rec) : null;

View file

@ -85,7 +85,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
Integer sigHash = IndexCPPSignatureUtil.getSignatureHash(function);
pdom.getDB().putInt(record + SIGNATURE_HASH, sigHash != null ? sigHash.intValue() : 0);
if(setTypes) {
if (setTypes) {
initData((ICPPFunctionType) function.getType(), function.getParameters());
}
db.putByte(record + ANNOTATION, PDOMCPPAnnotation.encodeAnnotation(function));
@ -94,7 +94,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
}
}
public void initData(ICPPFunctionType ftype, IParameter[] params) throws CoreException {
public void initData(ICPPFunctionType ftype, IParameter[] params) throws CoreException {
PDOMCPPFunctionType pft= setType(ftype);
setParameters(pft, params);
}
@ -132,8 +132,8 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
db.putInt(record + NUM_PARAMS, params.length);
db.putInt(record + FIRST_PARAM, 0);
IType[] paramTypes= pft.getParameterTypes();
for (int i=0; i<params.length; ++i) {
int ptRecord= i<paramTypes.length && paramTypes[i]!=null ? ((PDOMNode) paramTypes[i]).getRecord() : 0;
for (int i= 0; i < params.length; ++i) {
int ptRecord= i < paramTypes.length && paramTypes[i] != null ? ((PDOMNode) paramTypes[i]).getRecord() : 0;
setFirstParameter(new PDOMCPPParameter(pdom, this, params[i], ptRecord));
}
}
@ -268,7 +268,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
}
protected static int compareSignatures(IPDOMOverloader a, Object b) {
if(b instanceof IPDOMOverloader) {
if (b instanceof IPDOMOverloader) {
IPDOMOverloader bb= (IPDOMOverloader) b;
try {
int mySM = a.getSignatureHash();

View file

@ -49,7 +49,6 @@ import org.eclipse.cdt.internal.core.browser.ASTTypeInfo;
*
*/
public abstract class PDOMSearchQuery implements ISearchQuery {
public static final int FIND_DECLARATIONS = 0x1;
public static final int FIND_DEFINITIONS = 0x2;
public static final int FIND_REFERENCES = 0x4;
@ -155,10 +154,9 @@ public abstract class PDOMSearchQuery implements ISearchQuery {
names.addAll(Arrays.asList(ast.getReferences(binding)));
for (IASTName name : names) {
if ( ((flags & FIND_DECLARATIONS) != 0 && name.isDeclaration())
|| ((flags & FIND_DEFINITIONS) != 0 && name.isDefinition())
|| ((flags & FIND_REFERENCES) != 0 && name.isReference())) {
if (((flags & FIND_DECLARATIONS) != 0 && name.isDeclaration()) ||
((flags & FIND_DEFINITIONS) != 0 && name.isDefinition()) ||
((flags & FIND_REFERENCES) != 0 && name.isReference())) {
ASTTypeInfo typeInfo= ASTTypeInfo.create(name);
if (typeInfo != null) {
ITypeReference ref= typeInfo.getResolvedReference();