mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 06:32:10 +02:00
Patch for Devin Steffler.
Fixing ArrayUtil.removeNulls().
This commit is contained in:
parent
a5ed254394
commit
8a37c61a8c
32 changed files with 253 additions and 71 deletions
|
@ -190,6 +190,9 @@ public class ArrayUtil {
|
|||
}
|
||||
|
||||
/**
|
||||
* Note that this should only be used when the placement of
|
||||
* nulls within the array is unknown (due to performance efficiency).
|
||||
*
|
||||
* Removes all of the nulls from the array and returns a new
|
||||
* array that contains all of the non-null elements.
|
||||
*
|
||||
|
@ -220,6 +223,29 @@ public class ArrayUtil {
|
|||
return newArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* To improve performance, this method should be used instead of ArrayUtil#removeNulls(Class, Object[]) when
|
||||
* all of the non-null elements in the array are grouped together at the beginning of the array
|
||||
* and all of the nulls are at the end of the array.
|
||||
* The position of the last non-null element in the array must also be known.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static Object[] removeNullsAfter(Class c, Object[] array, int index) {
|
||||
if( array == null || index < 0)
|
||||
return (Object[]) Array.newInstance( c, 0 );
|
||||
|
||||
if( array.length == index + 1 )
|
||||
return array;
|
||||
|
||||
Object[] newArray = (Object[]) Array.newInstance(c, index + 1);
|
||||
for( int i = 0; i <= index; i++ ){
|
||||
newArray[i] = array[i];
|
||||
}
|
||||
|
||||
return newArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert the obj at the beginning of the array, shifting the whole thing one index
|
||||
* @param c
|
||||
|
|
|
@ -29,19 +29,24 @@ public abstract class CASTAmbiguity extends CASTNode {
|
|||
protected static class CASTNameCollector extends CASTVisitor
|
||||
{
|
||||
private IASTName[] names = new IASTName[ 2 ];
|
||||
private int namesPos=-1;
|
||||
|
||||
{
|
||||
shouldVisitNames = true;
|
||||
}
|
||||
|
||||
public int visit(IASTName name) {
|
||||
if (name != null) {
|
||||
namesPos++;
|
||||
names = (IASTName[]) ArrayUtil.append( IASTName.class, names, name );
|
||||
}
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
public IASTName [] getNames()
|
||||
{
|
||||
return (IASTName[]) ArrayUtil.removeNulls( IASTName.class, names );
|
||||
names = (IASTName[]) ArrayUtil.removeNullsAfter( IASTName.class, names, namesPos );
|
||||
return names;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,13 +19,18 @@ public class CASTAmbiguousExpression extends CASTAmbiguity implements
|
|||
IASTAmbiguousExpression {
|
||||
|
||||
private IASTExpression [] expressions = new IASTExpression[2];
|
||||
private int expressionsPos=-1;
|
||||
|
||||
public void addExpression(IASTExpression e) {
|
||||
if (e != null) {
|
||||
expressionsPos++;
|
||||
expressions = (IASTExpression[]) ArrayUtil.append( IASTExpression.class, expressions, e );
|
||||
}
|
||||
}
|
||||
|
||||
public IASTExpression[] getExpressions() {
|
||||
return (IASTExpression[]) ArrayUtil.removeNulls( IASTExpression.class, expressions );
|
||||
expressions = (IASTExpression[]) ArrayUtil.removeNullsAfter( IASTExpression.class, expressions, expressionsPos );
|
||||
return expressions;
|
||||
}
|
||||
|
||||
protected IASTNode[] getNodes() {
|
||||
|
|
|
@ -19,13 +19,18 @@ public class CASTAmbiguousStatement extends CASTAmbiguity implements
|
|||
IASTAmbiguousStatement {
|
||||
|
||||
private IASTStatement [] stmts = new IASTStatement[2];
|
||||
private int stmtsPos=-1;
|
||||
|
||||
public void addStatement(IASTStatement s) {
|
||||
if (s != null) {
|
||||
stmtsPos++;
|
||||
stmts = (IASTStatement[]) ArrayUtil.append( IASTStatement.class, stmts, s );
|
||||
}
|
||||
}
|
||||
|
||||
public IASTStatement[] getStatements() {
|
||||
return (IASTStatement[]) ArrayUtil.removeNulls( IASTStatement.class, stmts );
|
||||
stmts = (IASTStatement[]) ArrayUtil.removeNullsAfter( IASTStatement.class, stmts, stmtsPos );
|
||||
return stmts;
|
||||
}
|
||||
|
||||
protected IASTNode[] getNodes() {
|
||||
|
|
|
@ -22,17 +22,21 @@ public class CASTArrayDeclarator extends CASTDeclarator implements
|
|||
IASTArrayDeclarator {
|
||||
|
||||
private IASTArrayModifier [] arrayMods = null;
|
||||
|
||||
private int arrayModsPos=-1;
|
||||
|
||||
public IASTArrayModifier[] getArrayModifiers() {
|
||||
if( arrayMods == null ) return IASTArrayModifier.EMPTY_ARRAY;
|
||||
return (IASTArrayModifier[]) ArrayUtil.removeNulls( IASTArrayModifier.class, arrayMods );
|
||||
arrayMods = (IASTArrayModifier[]) ArrayUtil.removeNullsAfter( IASTArrayModifier.class, arrayMods, arrayModsPos );
|
||||
return arrayMods;
|
||||
|
||||
}
|
||||
|
||||
public void addArrayModifier(IASTArrayModifier arrayModifier) {
|
||||
if (arrayModifier != null) {
|
||||
arrayModsPos++;
|
||||
arrayMods = (IASTArrayModifier[]) ArrayUtil.append( IASTArrayModifier.class, arrayMods, arrayModifier );
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean postAccept( ASTVisitor action ){
|
||||
IASTArrayModifier [] mods = getArrayModifiers();
|
||||
|
|
|
@ -56,6 +56,7 @@ public class CASTCompositeTypeSpecifier extends CASTBaseDeclSpecifier implements
|
|||
|
||||
|
||||
private IASTDeclaration [] declarations = null;
|
||||
private int declarationsPos=-1;
|
||||
private IScope scope = null;
|
||||
|
||||
|
||||
|
@ -64,15 +65,19 @@ public class CASTCompositeTypeSpecifier extends CASTBaseDeclSpecifier implements
|
|||
*/
|
||||
public IASTDeclaration [] getMembers() {
|
||||
if( declarations == null ) return IASTDeclaration.EMPTY_DECLARATION_ARRAY;
|
||||
return (IASTDeclaration[]) ArrayUtil.removeNulls( IASTDeclaration.class, declarations );
|
||||
declarations = (IASTDeclaration[]) ArrayUtil.removeNullsAfter( IASTDeclaration.class, declarations, declarationsPos );
|
||||
return declarations;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier#addMemberDeclaration(org.eclipse.cdt.core.dom.ast.IASTDeclaration)
|
||||
*/
|
||||
public void addMemberDeclaration(IASTDeclaration declaration) {
|
||||
if (declaration != null) {
|
||||
declarationsPos++;
|
||||
declarations = (IASTDeclaration[]) ArrayUtil.append( IASTDeclaration.class, declarations, declaration );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -33,6 +33,7 @@ public class CASTDeclarator extends CASTNode implements IASTDeclarator {
|
|||
private IASTName name;
|
||||
private IASTDeclarator nestedDeclarator;
|
||||
private IASTPointerOperator [] pointerOps = null;
|
||||
private int pointerOpsPos=-1;
|
||||
|
||||
|
||||
|
||||
|
@ -41,7 +42,8 @@ public class CASTDeclarator extends CASTNode implements IASTDeclarator {
|
|||
*/
|
||||
public IASTPointerOperator[] getPointerOperators() {
|
||||
if( pointerOps == null ) return IASTPointerOperator.EMPTY_ARRAY;
|
||||
return (IASTPointerOperator[]) ArrayUtil.removeNulls( IASTPointerOperator.class, pointerOps );
|
||||
pointerOps = (IASTPointerOperator[]) ArrayUtil.removeNullsAfter( IASTPointerOperator.class, pointerOps, pointerOpsPos );
|
||||
return pointerOps;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -76,8 +78,11 @@ public class CASTDeclarator extends CASTNode implements IASTDeclarator {
|
|||
* @see org.eclipse.cdt.core.dom.ast.IASTDeclarator#addPointerOperator(org.eclipse.cdt.core.dom.ast.IASTPointerOperator)
|
||||
*/
|
||||
public void addPointerOperator(IASTPointerOperator operator) {
|
||||
if (operator != null) {
|
||||
pointerOpsPos++;
|
||||
pointerOps = (IASTPointerOperator[]) ArrayUtil.append( IASTPointerOperator.class, pointerOps, operator );
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTDeclarator#setNestedDeclarator(org.eclipse.cdt.core.dom.ast.IASTDeclarator)
|
||||
|
|
|
@ -28,18 +28,23 @@ public class CASTDesignatedInitializer extends CASTNode implements
|
|||
* @see org.eclipse.cdt.core.dom.ast.c.ICASTDesignatedInitializer#addDesignator(org.eclipse.cdt.core.dom.ast.c.ICASTDesignator)
|
||||
*/
|
||||
public void addDesignator(ICASTDesignator designator) {
|
||||
if (designator != null) {
|
||||
designatorsPos++;
|
||||
designators = (ICASTDesignator[]) ArrayUtil.append( ICASTDesignator.class, designators, designator );
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.c.ICASTDesignatedInitializer#getDesignators()
|
||||
*/
|
||||
public ICASTDesignator[] getDesignators() {
|
||||
if( designators == null ) return ICASTDesignatedInitializer.EMPTY_DESIGNATOR_ARRAY;
|
||||
return (ICASTDesignator[]) ArrayUtil.removeNulls( ICASTDesignator.class, designators );
|
||||
designators = (ICASTDesignator[]) ArrayUtil.removeNullsAfter( ICASTDesignator.class, designators, designatorsPos );
|
||||
return designators;
|
||||
}
|
||||
|
||||
private ICASTDesignator [] designators = null;
|
||||
int designatorsPos=-1;
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.c.ICASTDesignatedInitializer#getRHSInitializer()
|
||||
*/
|
||||
|
|
|
@ -26,18 +26,23 @@ public class CASTEnumerationSpecifier extends CASTBaseDeclSpecifier implements
|
|||
* @see org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier#addEnumerator(org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator)
|
||||
*/
|
||||
public void addEnumerator(IASTEnumerator enumerator) {
|
||||
if (enumerator != null) {
|
||||
enumeratorsPos++;
|
||||
enumerators = (IASTEnumerator[]) ArrayUtil.append( IASTEnumerator.class, enumerators, enumerator );
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier#getEnumerators()
|
||||
*/
|
||||
public IASTEnumerator[] getEnumerators() {
|
||||
if( enumerators == null ) return IASTEnumerator.EMPTY_ENUMERATOR_ARRAY;
|
||||
return (IASTEnumerator[]) ArrayUtil.removeNulls( IASTEnumerator.class, enumerators );
|
||||
enumerators = (IASTEnumerator[]) ArrayUtil.removeNullsAfter( IASTEnumerator.class, enumerators, enumeratorsPos );
|
||||
return enumerators;
|
||||
}
|
||||
|
||||
private IASTEnumerator [] enumerators = null;
|
||||
private int enumeratorsPos=-1;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier#setName(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||
|
|
|
@ -21,6 +21,7 @@ public class CASTFunctionDeclarator extends CASTDeclarator implements
|
|||
IASTStandardFunctionDeclarator {
|
||||
|
||||
private IASTParameterDeclaration [] parameters = null;
|
||||
private int parametersPos=-1;
|
||||
private boolean varArgs;
|
||||
|
||||
|
||||
|
@ -30,15 +31,19 @@ public class CASTFunctionDeclarator extends CASTDeclarator implements
|
|||
*/
|
||||
public IASTParameterDeclaration[] getParameters() {
|
||||
if( parameters == null ) return IASTParameterDeclaration.EMPTY_PARAMETERDECLARATION_ARRAY;
|
||||
return (IASTParameterDeclaration[]) ArrayUtil.removeNulls( IASTParameterDeclaration.class, parameters );
|
||||
parameters = (IASTParameterDeclaration[]) ArrayUtil.removeNullsAfter( IASTParameterDeclaration.class, parameters, parametersPos );
|
||||
return parameters;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator#addParameterDeclaration(org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration)
|
||||
*/
|
||||
public void addParameterDeclaration(IASTParameterDeclaration parameter) {
|
||||
if (parameter != null) {
|
||||
parametersPos++;
|
||||
parameters = (IASTParameterDeclaration[]) ArrayUtil.append( IASTParameterDeclaration.class, parameters, parameter );
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator#takesVarArgs()
|
||||
|
|
|
@ -26,15 +26,20 @@ public class CASTInitializerList extends CASTNode implements
|
|||
*/
|
||||
public IASTInitializer[] getInitializers() {
|
||||
if( initializers == null ) return IASTInitializer.EMPTY_INITIALIZER_ARRAY;
|
||||
return (IASTInitializer[]) ArrayUtil.removeNulls( IASTInitializer.class, initializers );
|
||||
initializers = (IASTInitializer[]) ArrayUtil.removeNullsAfter( IASTInitializer.class, initializers, initializersPos );
|
||||
return initializers;
|
||||
}
|
||||
|
||||
public void addInitializer( IASTInitializer d )
|
||||
{
|
||||
if (d != null) {
|
||||
initializersPos++;
|
||||
initializers = (IASTInitializer[]) ArrayUtil.append( IASTInitializer.class, initializers, d );
|
||||
}
|
||||
}
|
||||
|
||||
private IASTInitializer [] initializers = null;
|
||||
private int initializersPos=-1;
|
||||
|
||||
public boolean accept( ASTVisitor action ){
|
||||
if( action.shouldVisitInitializers ){
|
||||
|
|
|
@ -34,16 +34,21 @@ public class CASTSimpleDeclaration extends CASTNode implements
|
|||
*/
|
||||
public IASTDeclarator[] getDeclarators() {
|
||||
if( declarators == null ) return IASTDeclarator.EMPTY_DECLARATOR_ARRAY;
|
||||
return (IASTDeclarator[]) ArrayUtil.removeNulls( IASTDeclarator.class, declarators );
|
||||
declarators = (IASTDeclarator[]) ArrayUtil.removeNullsAfter( IASTDeclarator.class, declarators, declaratorsPos );
|
||||
return declarators;
|
||||
}
|
||||
|
||||
public void addDeclarator( IASTDeclarator d )
|
||||
{
|
||||
if (d != null) {
|
||||
declaratorsPos++;
|
||||
declarators = (IASTDeclarator[]) ArrayUtil.append( IASTDeclarator.class, declarators, d );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private IASTDeclarator [] declarators = null;
|
||||
private int declaratorsPos=-1;
|
||||
private IASTDeclSpecifier declSpecifier;
|
||||
|
||||
/**
|
||||
|
|
|
@ -50,6 +50,7 @@ public class CASTTranslationUnit extends CASTNode implements
|
|||
IASTTranslationUnit, IRequiresLocationInformation {
|
||||
|
||||
private IASTDeclaration[] decls = null;
|
||||
private int declsPos=-1;
|
||||
|
||||
// Binding
|
||||
private CScope compilationUnit = null;
|
||||
|
@ -71,8 +72,11 @@ public class CASTTranslationUnit extends CASTNode implements
|
|||
private static final IASTName[] EMPTY_NAME_ARRAY = new IASTName[0];
|
||||
|
||||
public void addDeclaration(IASTDeclaration d) {
|
||||
if (d != null) {
|
||||
declsPos++;
|
||||
decls = (IASTDeclaration[]) ArrayUtil.append( IASTDeclaration.class, decls, d );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
@ -81,7 +85,8 @@ public class CASTTranslationUnit extends CASTNode implements
|
|||
*/
|
||||
public IASTDeclaration[] getDeclarations() {
|
||||
if (decls == null) return IASTDeclaration.EMPTY_DECLARATION_ARRAY;
|
||||
return (IASTDeclaration[]) ArrayUtil.removeNulls( IASTDeclaration.class, decls );
|
||||
decls = (IASTDeclaration[]) ArrayUtil.removeNullsAfter( IASTDeclaration.class, decls, declsPos );
|
||||
return decls;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -29,17 +29,22 @@ public abstract class CPPASTAmbiguity extends CPPASTNode {
|
|||
|
||||
protected static class CPPASTNameCollector extends CPPASTVisitor {
|
||||
private IASTName[] names = new IASTName[2];
|
||||
private int namesPos=-1;
|
||||
{
|
||||
shouldVisitNames = true;
|
||||
}
|
||||
|
||||
public int visit(IASTName name) {
|
||||
if (name != null) {
|
||||
namesPos++;
|
||||
names = (IASTName[]) ArrayUtil.append(IASTName.class, names, name);
|
||||
}
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
public IASTName[] getNames() {
|
||||
return (IASTName[]) ArrayUtil.removeNulls(IASTName.class, names);
|
||||
names = (IASTName[]) ArrayUtil.removeNullsAfter(IASTName.class, names, namesPos);
|
||||
return names;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,14 +23,18 @@ public class CPPASTAmbiguousDeclaration extends CPPASTAmbiguity implements
|
|||
}
|
||||
|
||||
private IASTDeclaration [] decls = new IASTDeclaration[2];
|
||||
private int declsPos=-1;
|
||||
|
||||
public void addDeclaration(IASTDeclaration d) {
|
||||
if (d != null) {
|
||||
declsPos++;
|
||||
decls = (IASTDeclaration[]) ArrayUtil.append(IASTDeclaration.class, decls, d );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public IASTDeclaration[] getDeclarations() {
|
||||
return (IASTDeclaration[]) ArrayUtil.removeNulls( IASTDeclaration.class, decls );
|
||||
decls = (IASTDeclaration[]) ArrayUtil.removeNullsAfter( IASTDeclaration.class, decls, declsPos );
|
||||
return decls;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,13 +19,18 @@ public class CPPASTAmbiguousExpression extends CPPASTAmbiguity implements
|
|||
IASTAmbiguousExpression {
|
||||
|
||||
private IASTExpression [] exp = new IASTExpression[2];
|
||||
private int expPos=-1;
|
||||
|
||||
public void addExpression(IASTExpression e) {
|
||||
if (e != null) {
|
||||
expPos++;
|
||||
exp = (IASTExpression[]) ArrayUtil.append( IASTExpression.class, exp, e );
|
||||
}
|
||||
}
|
||||
|
||||
public IASTExpression[] getExpressions() {
|
||||
return (IASTExpression[]) ArrayUtil.removeNulls( IASTExpression.class, exp );
|
||||
exp = (IASTExpression[]) ArrayUtil.removeNullsAfter( IASTExpression.class, exp, expPos );
|
||||
return exp;
|
||||
}
|
||||
|
||||
protected IASTNode[] getNodes() {
|
||||
|
|
|
@ -19,13 +19,18 @@ public class CPPASTAmbiguousStatement extends CPPASTAmbiguity implements
|
|||
IASTAmbiguousStatement {
|
||||
|
||||
private IASTStatement [] stmts = new IASTStatement[2];
|
||||
private int stmtsPos=-1;
|
||||
|
||||
public void addStatement(IASTStatement s) {
|
||||
if (s != null) {
|
||||
stmtsPos++;
|
||||
stmts = (IASTStatement[]) ArrayUtil.append( IASTStatement.class, stmts, s );
|
||||
}
|
||||
}
|
||||
|
||||
public IASTStatement[] getStatements() {
|
||||
return (IASTStatement[]) ArrayUtil.removeNulls( IASTStatement.class, stmts );
|
||||
stmts = (IASTStatement[]) ArrayUtil.removeNullsAfter( IASTStatement.class, stmts, stmtsPos );
|
||||
return stmts;
|
||||
}
|
||||
|
||||
protected IASTNode[] getNodes() {
|
||||
|
|
|
@ -23,16 +23,20 @@ public class CPPASTArrayDeclarator extends CPPASTDeclarator implements
|
|||
IASTArrayDeclarator {
|
||||
|
||||
private IASTArrayModifier [] arrayMods = null;
|
||||
|
||||
private int arrayModsPos=-1;
|
||||
|
||||
public IASTArrayModifier[] getArrayModifiers() {
|
||||
if( arrayMods == null ) return IASTArrayModifier.EMPTY_ARRAY;
|
||||
return (IASTArrayModifier[]) ArrayUtil.removeNulls( IASTArrayModifier.class, arrayMods );
|
||||
arrayMods = (IASTArrayModifier[]) ArrayUtil.removeNullsAfter( IASTArrayModifier.class, arrayMods, arrayModsPos );
|
||||
return arrayMods;
|
||||
}
|
||||
|
||||
public void addArrayModifier(IASTArrayModifier arrayModifier) {
|
||||
if (arrayModifier != null) {
|
||||
arrayModsPos++;
|
||||
arrayMods = (IASTArrayModifier[]) ArrayUtil.append( IASTArrayModifier.class, arrayMods, arrayModifier );
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean postAccept( ASTVisitor action ){
|
||||
IASTArrayModifier [] mods = getArrayModifiers();
|
||||
|
|
|
@ -41,15 +41,19 @@ public class CPPASTCompositeTypeSpecifier extends CPPASTBaseDeclSpecifier
|
|||
*/
|
||||
public ICPPASTBaseSpecifier[] getBaseSpecifiers() {
|
||||
if( baseSpecs == null ) return ICPPASTBaseSpecifier.EMPTY_BASESPECIFIER_ARRAY;
|
||||
return (ICPPASTBaseSpecifier[]) ArrayUtil.removeNulls( ICPPASTBaseSpecifier.class, baseSpecs );
|
||||
baseSpecs = (ICPPASTBaseSpecifier[]) ArrayUtil.removeNullsAfter( ICPPASTBaseSpecifier.class, baseSpecs, baseSpecsPos );
|
||||
return baseSpecs;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier#addBaseSpecifier(org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier)
|
||||
*/
|
||||
public void addBaseSpecifier(ICPPASTBaseSpecifier baseSpec) {
|
||||
if (baseSpec != null) {
|
||||
baseSpecsPos++;
|
||||
baseSpecs = (ICPPASTBaseSpecifier[]) ArrayUtil.append( ICPPASTBaseSpecifier.class, baseSpecs, baseSpec );
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier#getKey()
|
||||
|
@ -98,6 +102,7 @@ public class CPPASTCompositeTypeSpecifier extends CPPASTBaseDeclSpecifier
|
|||
|
||||
private IASTDeclaration [] declarations = new IASTDeclaration[4];
|
||||
private ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier [] baseSpecs = null;
|
||||
private int baseSpecsPos=-1;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier#getScope()
|
||||
|
|
|
@ -33,7 +33,7 @@ public class CPPASTDeclarator extends CPPASTNode implements IASTDeclarator {
|
|||
private IASTName name;
|
||||
private IASTDeclarator nestedDeclarator;
|
||||
private IASTPointerOperator [] pointerOps = null;
|
||||
|
||||
private int pointerOpsPos=-1;
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -41,7 +41,8 @@ public class CPPASTDeclarator extends CPPASTNode implements IASTDeclarator {
|
|||
*/
|
||||
public IASTPointerOperator[] getPointerOperators() {
|
||||
if( pointerOps == null ) return IASTPointerOperator.EMPTY_ARRAY;
|
||||
return (IASTPointerOperator[]) ArrayUtil.removeNulls( IASTPointerOperator.class, pointerOps );
|
||||
pointerOps = (IASTPointerOperator[]) ArrayUtil.removeNullsAfter( IASTPointerOperator.class, pointerOps, pointerOpsPos );
|
||||
return pointerOps;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -76,8 +77,11 @@ public class CPPASTDeclarator extends CPPASTNode implements IASTDeclarator {
|
|||
* @see org.eclipse.cdt.core.dom.ast.IASTDeclarator#addPointerOperator(org.eclipse.cdt.core.dom.ast.IASTPointerOperator)
|
||||
*/
|
||||
public void addPointerOperator(IASTPointerOperator operator) {
|
||||
if (operator != null) {
|
||||
pointerOpsPos++;
|
||||
pointerOps = (IASTPointerOperator[]) ArrayUtil.append( IASTPointerOperator.class, pointerOps, operator );
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTDeclarator#setNestedDeclarator(org.eclipse.cdt.core.dom.ast.IASTDeclarator)
|
||||
|
|
|
@ -30,8 +30,11 @@ public class CPPASTEnumerationSpecifier extends CPPASTBaseDeclSpecifier
|
|||
* @see org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier#addEnumerator(org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator)
|
||||
*/
|
||||
public void addEnumerator(IASTEnumerator enumerator) {
|
||||
if (enumerator != null) {
|
||||
enumeratorsPos++;
|
||||
enumerators = (IASTEnumerator[]) ArrayUtil.append( IASTEnumerator.class, enumerators, enumerator );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
@ -41,11 +44,13 @@ public class CPPASTEnumerationSpecifier extends CPPASTBaseDeclSpecifier
|
|||
public IASTEnumerator[] getEnumerators() {
|
||||
if (enumerators == null)
|
||||
return IASTEnumerator.EMPTY_ENUMERATOR_ARRAY;
|
||||
return (IASTEnumerator[]) ArrayUtil.removeNulls( IASTEnumerator.class, enumerators );
|
||||
enumerators = (IASTEnumerator[]) ArrayUtil.removeNullsAfter( IASTEnumerator.class, enumerators, enumeratorsPos );
|
||||
return enumerators;
|
||||
}
|
||||
|
||||
|
||||
private IASTEnumerator[] enumerators = null;
|
||||
private int enumeratorsPos=-1;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
|
|
@ -29,6 +29,7 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements
|
|||
ICPPASTFunctionDeclarator {
|
||||
|
||||
private IASTParameterDeclaration [] parameters = null;
|
||||
private int parametersPos=-1;
|
||||
private ICPPFunctionScope scope = null;
|
||||
private boolean varArgs;
|
||||
private boolean pureVirtual;
|
||||
|
@ -42,15 +43,19 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements
|
|||
*/
|
||||
public IASTParameterDeclaration [] getParameters() {
|
||||
if( parameters == null ) return IASTParameterDeclaration.EMPTY_PARAMETERDECLARATION_ARRAY;
|
||||
return (IASTParameterDeclaration[]) ArrayUtil.removeNulls( IASTParameterDeclaration.class, parameters );
|
||||
parameters = (IASTParameterDeclaration[]) ArrayUtil.removeNullsAfter( IASTParameterDeclaration.class, parameters, parametersPos );
|
||||
return parameters;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator#addParameterDeclaration(org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration)
|
||||
*/
|
||||
public void addParameterDeclaration(IASTParameterDeclaration parameter) {
|
||||
if (parameter != null) {
|
||||
parametersPos++;
|
||||
parameters = (IASTParameterDeclaration []) ArrayUtil.append( IASTParameterDeclaration.class, parameters, parameter );
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator#takesVarArgs()
|
||||
|
@ -99,12 +104,14 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements
|
|||
}
|
||||
|
||||
private IASTTypeId [] typeIds = null;
|
||||
private int typeIdsPos=-1;
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator#getExceptionSpecification()
|
||||
*/
|
||||
public IASTTypeId[] getExceptionSpecification() {
|
||||
if( typeIds == null ) return IASTTypeId.EMPTY_TYPEID_ARRAY;
|
||||
return (IASTTypeId[]) ArrayUtil.removeNulls( IASTTypeId.class, typeIds );
|
||||
typeIds = (IASTTypeId[]) ArrayUtil.removeNullsAfter( IASTTypeId.class, typeIds, typeIdsPos );
|
||||
return typeIds;
|
||||
}
|
||||
|
||||
|
||||
|
@ -112,8 +119,11 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements
|
|||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator#addExceptionSpecificationTypeId(org.eclipse.cdt.core.dom.ast.IASTTypeId)
|
||||
*/
|
||||
public void addExceptionSpecificationTypeId(IASTTypeId typeId) {
|
||||
if (typeId != null) {
|
||||
typeIdsPos++;
|
||||
typeIds = (IASTTypeId[]) ArrayUtil.append( IASTTypeId.class, typeIds, typeId );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -133,13 +143,15 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements
|
|||
|
||||
|
||||
private ICPPASTConstructorChainInitializer [] constructorChain = null;
|
||||
private int constructorChainPos=-1;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator#getConstructorChain()
|
||||
*/
|
||||
public ICPPASTConstructorChainInitializer[] getConstructorChain() {
|
||||
if( constructorChain == null ) return ICPPASTConstructorChainInitializer.EMPTY_CONSTRUCTORCHAININITIALIZER_ARRAY;
|
||||
return (ICPPASTConstructorChainInitializer[]) ArrayUtil.removeNulls( ICPPASTConstructorChainInitializer.class, constructorChain );
|
||||
constructorChain = (ICPPASTConstructorChainInitializer[]) ArrayUtil.removeNullsAfter( ICPPASTConstructorChainInitializer.class, constructorChain, constructorChainPos );
|
||||
return constructorChain;
|
||||
}
|
||||
|
||||
|
||||
|
@ -147,8 +159,11 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements
|
|||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator#addConstructorToChain(org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer)
|
||||
*/
|
||||
public void addConstructorToChain(ICPPASTConstructorChainInitializer initializer) {
|
||||
if (initializer != null) {
|
||||
constructorChainPos++;
|
||||
constructorChain = (ICPPASTConstructorChainInitializer[]) ArrayUtil.append( ICPPASTConstructorChainInitializer.class, constructorChain, initializer );
|
||||
}
|
||||
}
|
||||
|
||||
public ICPPFunctionScope getFunctionScope(){
|
||||
if( scope != null )
|
||||
|
|
|
@ -25,19 +25,24 @@ public class CPPASTFunctionTryBlockDeclarator extends CPPASTFunctionDeclarator
|
|||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionTryBlockDeclarator#addCatchHandler(org.eclipse.cdt.core.dom.ast.IASTStatement)
|
||||
*/
|
||||
public void addCatchHandler(ICPPASTCatchHandler statement) {
|
||||
if (statement != null) {
|
||||
catchHandlersPos++;
|
||||
catchHandlers = (ICPPASTCatchHandler[]) ArrayUtil.append( ICPPASTCatchHandler.class, catchHandlers, statement );
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionTryBlockDeclarator#getCatchHandlers()
|
||||
*/
|
||||
public ICPPASTCatchHandler [] getCatchHandlers() {
|
||||
if( catchHandlers == null ) return ICPPASTCatchHandler.EMPTY_CATCHHANDLER_ARRAY;
|
||||
return (ICPPASTCatchHandler[]) ArrayUtil.removeNulls( ICPPASTCatchHandler.class, catchHandlers );
|
||||
catchHandlers = (ICPPASTCatchHandler[]) ArrayUtil.removeNullsAfter( ICPPASTCatchHandler.class, catchHandlers, catchHandlersPos );
|
||||
return catchHandlers;
|
||||
}
|
||||
|
||||
|
||||
private ICPPASTCatchHandler [] catchHandlers = null;
|
||||
private int catchHandlersPos=-1;
|
||||
protected boolean postAccept( ASTVisitor action ){
|
||||
if( !super.postAccept( action ) ) return false;
|
||||
|
||||
|
|
|
@ -27,16 +27,21 @@ public class CPPASTInitializerList extends CPPASTNode implements
|
|||
*/
|
||||
public IASTInitializer [] getInitializers() {
|
||||
if( initializers == null ) return IASTInitializer.EMPTY_INITIALIZER_ARRAY;
|
||||
return (IASTInitializer[]) ArrayUtil.removeNulls( IASTInitializer.class, initializers );
|
||||
initializers = (IASTInitializer[]) ArrayUtil.removeNullsAfter( IASTInitializer.class, initializers, initializersPos );
|
||||
return initializers;
|
||||
}
|
||||
|
||||
public void addInitializer( IASTInitializer d )
|
||||
{
|
||||
if (d != null) {
|
||||
initializersPos++;
|
||||
initializers = (IASTInitializer[]) ArrayUtil.append( IASTInitializer.class, initializers, d );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private IASTInitializer [] initializers = null;
|
||||
private int initializersPos=-1;
|
||||
|
||||
public boolean accept( ASTVisitor action ){
|
||||
if( action.shouldVisitInitializers ){
|
||||
|
|
|
@ -66,18 +66,21 @@ public class CPPASTQualifiedName extends CPPASTNode implements
|
|||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName#addName(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||
*/
|
||||
public void addName(IASTName name) {
|
||||
if (name != null) {
|
||||
namesPos++;
|
||||
names = (IASTName[]) ArrayUtil.append( IASTName.class, names, name );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param decls2
|
||||
*/
|
||||
private void removeNullNames() {
|
||||
names = (IASTName[]) ArrayUtil.removeNulls( IASTName.class, names );
|
||||
|
||||
names = (IASTName[]) ArrayUtil.removeNullsAfter( IASTName.class, names, namesPos );
|
||||
}
|
||||
|
||||
private IASTName[] names = null;
|
||||
private int namesPos=-1;
|
||||
private boolean value;
|
||||
private String signature;
|
||||
|
||||
|
|
|
@ -36,15 +36,20 @@ public class CPPASTSimpleDeclaration extends CPPASTNode implements
|
|||
*/
|
||||
public IASTDeclarator[] getDeclarators() {
|
||||
if( declarators == null ) return IASTDeclarator.EMPTY_DECLARATOR_ARRAY;
|
||||
return (IASTDeclarator[]) ArrayUtil.removeNulls( IASTDeclarator.class, declarators );
|
||||
declarators = (IASTDeclarator[]) ArrayUtil.removeNullsAfter( IASTDeclarator.class, declarators, declaratorsPos );
|
||||
return declarators;
|
||||
}
|
||||
|
||||
public void addDeclarator( IASTDeclarator d )
|
||||
{
|
||||
if (d != null) {
|
||||
declaratorsPos++;
|
||||
declarators = (IASTDeclarator[]) ArrayUtil.append( IASTDeclarator.class, declarators, d );
|
||||
}
|
||||
}
|
||||
|
||||
private IASTDeclarator [] declarators = null;
|
||||
private int declaratorsPos=-1;
|
||||
private IASTDeclSpecifier declSpecifier;
|
||||
|
||||
/**
|
||||
|
|
|
@ -62,17 +62,22 @@ public class CPPASTTemplateDeclaration extends CPPASTNode implements
|
|||
*/
|
||||
public ICPPASTTemplateParameter [] getTemplateParameters() {
|
||||
if( parameters == null ) return ICPPASTTemplateParameter.EMPTY_TEMPLATEPARAMETER_ARRAY;
|
||||
return (ICPPASTTemplateParameter[]) ArrayUtil.removeNulls( ICPPASTTemplateParameter.class, parameters );
|
||||
parameters = (ICPPASTTemplateParameter[]) ArrayUtil.removeNullsAfter( ICPPASTTemplateParameter.class, parameters, parametersPos );
|
||||
return parameters;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration#addTemplateParamter(org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter)
|
||||
*/
|
||||
public void addTemplateParamter(ICPPASTTemplateParameter parm) {
|
||||
if (parm != null) {
|
||||
parametersPos++;
|
||||
parameters = (ICPPASTTemplateParameter[]) ArrayUtil.append( ICPPASTTemplateParameter.class, parameters, parm );
|
||||
}
|
||||
}
|
||||
|
||||
private ICPPASTTemplateParameter [] parameters = null;
|
||||
private int parametersPos=-1;
|
||||
public boolean accept( ASTVisitor action ){
|
||||
if( action.shouldVisitDeclarations ){
|
||||
switch( action.visit( this ) ){
|
||||
|
|
|
@ -28,14 +28,19 @@ public class CPPASTTemplatedTypeTemplateParameter extends CPPASTNode implements
|
|||
|
||||
public ICPPASTTemplateParameter[] getTemplateParameters() {
|
||||
if( parameters == null ) return ICPPASTTemplateParameter.EMPTY_TEMPLATEPARAMETER_ARRAY;
|
||||
return (ICPPASTTemplateParameter[]) ArrayUtil.removeNulls( ICPPASTTemplateParameter.class, parameters );
|
||||
parameters = (ICPPASTTemplateParameter[]) ArrayUtil.removeNullsAfter( ICPPASTTemplateParameter.class, parameters, parametersPos );
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public void addTemplateParamter(ICPPASTTemplateParameter parm) {
|
||||
if(parm != null) {
|
||||
parametersPos++;
|
||||
parameters = (ICPPASTTemplateParameter[]) ArrayUtil.append( ICPPASTTemplateParameter.class, parameters, parm );
|
||||
}
|
||||
}
|
||||
|
||||
private ICPPASTTemplateParameter [] parameters = null;
|
||||
private int parametersPos=-1;
|
||||
private IASTName name;
|
||||
private IASTExpression defaultValue;
|
||||
|
||||
|
|
|
@ -28,19 +28,24 @@ public class CPPASTTryBlockStatement extends CPPASTNode implements
|
|||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionTryBlockDeclarator#addCatchHandler(org.eclipse.cdt.core.dom.ast.IASTStatement)
|
||||
*/
|
||||
public void addCatchHandler(ICPPASTCatchHandler statement) {
|
||||
if (statement != null) {
|
||||
catchHandlersPos++;
|
||||
catchHandlers = (ICPPASTCatchHandler[]) ArrayUtil.append( ICPPASTCatchHandler.class, catchHandlers, statement );
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionTryBlockDeclarator#getCatchHandlers()
|
||||
*/
|
||||
public ICPPASTCatchHandler[] getCatchHandlers() {
|
||||
if( catchHandlers == null ) return ICPPASTCatchHandler.EMPTY_CATCHHANDLER_ARRAY;
|
||||
return (ICPPASTCatchHandler[]) ArrayUtil.removeNulls( ICPPASTCatchHandler.class, catchHandlers );
|
||||
catchHandlers = (ICPPASTCatchHandler[]) ArrayUtil.removeNullsAfter( ICPPASTCatchHandler.class, catchHandlers, catchHandlersPos );
|
||||
return catchHandlers;
|
||||
}
|
||||
|
||||
|
||||
private ICPPASTCatchHandler [] catchHandlers = null;
|
||||
private int catchHandlersPos=-1;
|
||||
private IASTStatement tryBody;
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTryBlockStatement#setTryBody(org.eclipse.cdt.core.dom.ast.IASTStatement)
|
||||
|
|
|
@ -27,14 +27,18 @@ public class DependencyTree implements IASTTranslationUnit.IDependencyTree, IDep
|
|||
}
|
||||
|
||||
private IASTInclusionNode [] incs = new IASTInclusionNode[2];
|
||||
private int incsPos=-1;
|
||||
|
||||
public IASTInclusionNode[] getInclusions() {
|
||||
incs = (IASTInclusionNode[]) ArrayUtil.removeNulls( IASTInclusionNode.class, incs );
|
||||
incs = (IASTInclusionNode[]) ArrayUtil.removeNullsAfter( IASTInclusionNode.class, incs, incsPos );
|
||||
return incs;
|
||||
}
|
||||
|
||||
public void addInclusionNode(IASTInclusionNode node) {
|
||||
if (node != null) {
|
||||
incsPos++;
|
||||
incs = (IASTInclusionNode[]) ArrayUtil.append( IASTInclusionNode.class, incs, node );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,15 +27,19 @@ public class InclusionNode implements IASTInclusionNode, IDependencyNodeHost {
|
|||
}
|
||||
|
||||
private IASTInclusionNode [] incs = new IASTInclusionNode[2];
|
||||
private int incsPos=-1;
|
||||
|
||||
public IASTInclusionNode[] getNestedInclusions() {
|
||||
incs = (IASTInclusionNode[]) ArrayUtil.removeNulls( IASTInclusionNode.class, incs );
|
||||
incs = (IASTInclusionNode[]) ArrayUtil.removeNullsAfter( IASTInclusionNode.class, incs, incsPos );
|
||||
return incs;
|
||||
}
|
||||
|
||||
public void addInclusionNode(IASTInclusionNode node) {
|
||||
if (node != null) {
|
||||
incsPos++;
|
||||
incs = (IASTInclusionNode[]) ArrayUtil.append( IASTInclusionNode.class, incs, node );
|
||||
}
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return stmt.toString();
|
||||
|
|
|
@ -1154,14 +1154,18 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
|
|||
}
|
||||
|
||||
IMacroDefinition [] builtins = new IMacroDefinition[2];
|
||||
private int builtinsPos=-1;
|
||||
|
||||
public void addBuiltinMacro(IMacroDefinition def) {
|
||||
if (def != null) {
|
||||
builtinsPos++;
|
||||
builtins = (IMacroDefinition[]) ArrayUtil.append( IMacroDefinition.class, builtins, def );
|
||||
}
|
||||
}
|
||||
|
||||
public IMacroDefinition [] getBuiltinMacroDefinitions()
|
||||
{
|
||||
builtins = (IMacroDefinition[]) ArrayUtil.removeNulls( IMacroDefinition.class, builtins );
|
||||
builtins = (IMacroDefinition[]) ArrayUtil.removeNullsAfter( IMacroDefinition.class, builtins, builtinsPos );
|
||||
return builtins;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue