mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
further removal of iterators
This commit is contained in:
parent
aa22210b4e
commit
c6c90a1e95
11 changed files with 71 additions and 51 deletions
|
@ -319,6 +319,9 @@ public class DeclarationWrapper implements IDeclaratorOwner
|
||||||
{
|
{
|
||||||
return declarators.iterator();
|
return declarators.iterator();
|
||||||
}
|
}
|
||||||
|
private List getDeclaratorsList(){
|
||||||
|
return declarators;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@ -397,10 +400,10 @@ public class DeclarationWrapper implements IDeclaratorOwner
|
||||||
{
|
{
|
||||||
|
|
||||||
Declarator d = declarator.getOwnedDeclarator();
|
Declarator d = declarator.getOwnedDeclarator();
|
||||||
Iterator i = d.getPointerOperators().iterator();
|
List ptrOps = d.getPointerOperators();
|
||||||
boolean isWithinClass = scope instanceof IASTClassSpecifier;
|
boolean isWithinClass = scope instanceof IASTClassSpecifier;
|
||||||
boolean isFunction = (declarator.getParameters().size() != 0);
|
boolean isFunction = (declarator.getParameters().size() != 0);
|
||||||
if( !i.hasNext() )
|
if( ptrOps.size() == 0 )
|
||||||
{
|
{
|
||||||
|
|
||||||
if (isTypedef())
|
if (isTypedef())
|
||||||
|
@ -427,7 +430,7 @@ public class DeclarationWrapper implements IDeclaratorOwner
|
||||||
declarator.getPointerOperators(),
|
declarator.getPointerOperators(),
|
||||||
declarator.getArrayModifiers(),
|
declarator.getArrayModifiers(),
|
||||||
convertedParms,
|
convertedParms,
|
||||||
(ASTPointerOperator)i.next());
|
(ASTPointerOperator)ptrOps.get( 0 ));
|
||||||
|
|
||||||
ITokenDuple nameDuple = ( d.getPointerOperatorNameDuple() != null ) ? TokenFactory.createTokenDuple( d.getPointerOperatorNameDuple(), d.getNameDuple() ) : d.getNameDuple();
|
ITokenDuple nameDuple = ( d.getPointerOperatorNameDuple() != null ) ? TokenFactory.createTokenDuple( d.getPointerOperatorNameDuple(), d.getNameDuple() ) : d.getNameDuple();
|
||||||
|
|
||||||
|
@ -548,10 +551,10 @@ public class DeclarationWrapper implements IDeclaratorOwner
|
||||||
for( int i = 0; i < currentParameters.size(); ++i )
|
for( int i = 0; i < currentParameters.size(); ++i )
|
||||||
{
|
{
|
||||||
DeclarationWrapper wrapper = (DeclarationWrapper)currentParameters.get(i);
|
DeclarationWrapper wrapper = (DeclarationWrapper)currentParameters.get(i);
|
||||||
Iterator j = wrapper.getDeclarators();
|
List declarators = wrapper.getDeclaratorsList();
|
||||||
while (j.hasNext())
|
for( int j = 0; j < declarators.size(); j++ )
|
||||||
{
|
{
|
||||||
Declarator declarator = (Declarator)j.next();
|
Declarator declarator = (Declarator)declarators.get(j);
|
||||||
|
|
||||||
result.add(
|
result.add(
|
||||||
astFactory.createParameterDeclaration(
|
astFactory.createParameterDeclaration(
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
package org.eclipse.cdt.internal.core.parser;
|
package org.eclipse.cdt.internal.core.parser;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.EndOfFileException;
|
import org.eclipse.cdt.core.parser.EndOfFileException;
|
||||||
import org.eclipse.cdt.core.parser.IParserLogService;
|
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||||
|
@ -250,12 +249,13 @@ public class SelectionParser extends ContextualParser {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int tokensFound = 0;
|
int tokensFound = 0;
|
||||||
Iterator i = tokenDuple.iterator();
|
|
||||||
while( i.hasNext() )
|
for( IToken token = tokenDuple.getFirstToken(); token != null; token = token.getNext() )
|
||||||
{
|
{
|
||||||
IToken token = (IToken) i.next();
|
|
||||||
if( token == firstTokenOfDuple ) ++tokensFound;
|
if( token == firstTokenOfDuple ) ++tokensFound;
|
||||||
if( token == lastTokenOfDuple ) ++tokensFound;
|
if( token == lastTokenOfDuple ) ++tokensFound;
|
||||||
|
if( token == tokenDuple.getLastToken() )
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if( tokensFound == 2 )
|
if( tokensFound == 2 )
|
||||||
{
|
{
|
||||||
|
|
|
@ -129,9 +129,10 @@ public class ASTAbstractDeclaration implements IASTAbstractDeclaration
|
||||||
*/
|
*/
|
||||||
public void acceptElement(ISourceElementRequestor requestor, IReferenceManager manager)
|
public void acceptElement(ISourceElementRequestor requestor, IReferenceManager manager)
|
||||||
{
|
{
|
||||||
Iterator arrayMods = getArrayModifiers();
|
List arrayMods = getArrayModifiersList();
|
||||||
while( arrayMods.hasNext() )
|
int size = arrayMods.size();
|
||||||
((IASTArrayModifier)arrayMods.next()).acceptElement(requestor, manager);
|
for( int i = 0; i< size; i++ )
|
||||||
|
((IASTArrayModifier)arrayMods.get(i)).acceptElement(requestor, manager);
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#enterScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#enterScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||||
|
|
|
@ -128,6 +128,11 @@ public class ASTClassSpecifier extends ASTScope implements IASTClassSpecifier
|
||||||
{
|
{
|
||||||
return new BaseIterator( (IDerivableContainerSymbol)getSymbol() );
|
return new BaseIterator( (IDerivableContainerSymbol)getSymbol() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List getBaseClausesList(){
|
||||||
|
List clauses = ((IDerivableContainerSymbol)getSymbol()).getParents();
|
||||||
|
return (clauses != null) ? clauses : Collections.EMPTY_LIST;
|
||||||
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTClassSpecifier#getCurrentVisibilityMode()
|
* @see org.eclipse.cdt.core.parser.ast.IASTClassSpecifier#getCurrentVisibilityMode()
|
||||||
*/
|
*/
|
||||||
|
@ -175,10 +180,12 @@ public class ASTClassSpecifier extends ASTScope implements IASTClassSpecifier
|
||||||
{
|
{
|
||||||
/* do nothing */
|
/* do nothing */
|
||||||
}
|
}
|
||||||
Iterator i = getBaseClauses();
|
List bases = getBaseClausesList();
|
||||||
while( i.hasNext() )
|
int size = bases.size();
|
||||||
|
for( int i = 0; i < size; i++ )
|
||||||
{
|
{
|
||||||
IASTBaseSpecifier baseSpec = (IASTBaseSpecifier)i.next();
|
IParentSymbol pw = (IParentSymbol)bases.get(i);
|
||||||
|
IASTBaseSpecifier baseSpec = new ASTBaseSpecifier( pw.getParent(), pw.isVirtual(), pw.getAccess(), pw.getOffset(), pw.getReferences() );
|
||||||
baseSpec.acceptElement(requestor, manager);
|
baseSpec.acceptElement(requestor, manager);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.parser.ast.complete;
|
package org.eclipse.cdt.internal.core.parser.ast.complete;
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
|
|
|
@ -193,10 +193,10 @@ public class ASTFunction extends ASTScope implements IASTFunction
|
||||||
*/
|
*/
|
||||||
protected void processParameterInitializersAndArrayMods(ISourceElementRequestor requestor, IReferenceManager manager)
|
protected void processParameterInitializersAndArrayMods(ISourceElementRequestor requestor, IReferenceManager manager)
|
||||||
{
|
{
|
||||||
Iterator i = parameters.iterator();
|
int size = parameters.size();
|
||||||
while( i.hasNext() )
|
for( int i = 0; i < size; i++ )
|
||||||
{
|
{
|
||||||
IASTParameterDeclaration parm = (IASTParameterDeclaration)i.next();
|
IASTParameterDeclaration parm = (IASTParameterDeclaration)parameters.get(i);
|
||||||
if( parm.getDefaultValue() != null )
|
if( parm.getDefaultValue() != null )
|
||||||
parm.getDefaultValue().acceptElement(requestor, manager);
|
parm.getDefaultValue().acceptElement(requestor, manager);
|
||||||
Iterator arrays = parm.getArrayModifiers();
|
Iterator arrays = parm.getArrayModifiers();
|
||||||
|
|
|
@ -81,9 +81,10 @@ public class ASTInitializerClause implements IASTInitializerClause
|
||||||
*/
|
*/
|
||||||
public void acceptElement(ISourceElementRequestor requestor, IReferenceManager manager)
|
public void acceptElement(ISourceElementRequestor requestor, IReferenceManager manager)
|
||||||
{
|
{
|
||||||
Iterator i = getInitializers();
|
List initializers = getInitializersList();
|
||||||
while( i.hasNext() )
|
int size = initializers.size();
|
||||||
((IASTInitializerClause)i.next()).acceptElement(requestor, manager);
|
for( int i = 0; i < size; i++ )
|
||||||
|
((IASTInitializerClause)initializers.get(i)).acceptElement(requestor, manager);
|
||||||
|
|
||||||
if( assignmentExpression != null )
|
if( assignmentExpression != null )
|
||||||
assignmentExpression.acceptElement( requestor, manager );
|
assignmentExpression.acceptElement( requestor, manager );
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.parser.ast.complete;
|
package org.eclipse.cdt.internal.core.parser.ast.complete;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -159,10 +160,10 @@ public class ASTMethod extends ASTFunction implements IASTMethod
|
||||||
{
|
{
|
||||||
if( constructorChain != null )
|
if( constructorChain != null )
|
||||||
{
|
{
|
||||||
Iterator i = getConstructorChainInitializers();
|
List initializers = getConstructorChainInitializersList();
|
||||||
while( i.hasNext() )
|
for( int i = 0; i < initializers.size(); i++ )
|
||||||
{
|
{
|
||||||
IASTConstructorMemberInitializer c = (IASTConstructorMemberInitializer)i.next();
|
IASTConstructorMemberInitializer c = (IASTConstructorMemberInitializer)initializers.get(i);
|
||||||
c.acceptElement(requestor, manager);
|
c.acceptElement(requestor, manager);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -204,6 +205,11 @@ public class ASTMethod extends ASTFunction implements IASTMethod
|
||||||
if( constructorChain == null )
|
if( constructorChain == null )
|
||||||
return EmptyIterator.EMPTY_ITERATOR;
|
return EmptyIterator.EMPTY_ITERATOR;
|
||||||
return constructorChain.iterator();
|
return constructorChain.iterator();
|
||||||
|
}
|
||||||
|
public List getConstructorChainInitializersList(){
|
||||||
|
if( constructorChain == null)
|
||||||
|
return Collections.EMPTY_LIST;
|
||||||
|
return constructorChain;
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTMethod#getOwnerClassSpecifier()
|
* @see org.eclipse.cdt.core.parser.ast.IASTMethod#getOwnerClassSpecifier()
|
||||||
|
|
|
@ -206,10 +206,11 @@ public class ASTTypeId implements IASTTypeId
|
||||||
if( tokenDuple != null )
|
if( tokenDuple != null )
|
||||||
tokenDuple.acceptElement( requestor, manager );
|
tokenDuple.acceptElement( requestor, manager );
|
||||||
|
|
||||||
Iterator arrayMods = getArrayModifiers();
|
List arrayMods = getArrayModifiersList();
|
||||||
while( arrayMods.hasNext() )
|
int size = arrayMods.size();
|
||||||
|
for( int i = 0; i < size; i++ )
|
||||||
{
|
{
|
||||||
((IASTArrayModifier)arrayMods.next()).acceptElement(requestor, manager);
|
((IASTArrayModifier)arrayMods.get(i)).acceptElement(requestor, manager);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1144,15 +1144,17 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
|
|
||||||
if( createConstructorReference( symbol, exp, duple, references ) ){
|
if( createConstructorReference( symbol, exp, duple, references ) ){
|
||||||
//if we have a constructor reference, get rid of the class reference.
|
//if we have a constructor reference, get rid of the class reference.
|
||||||
Iterator i = ((ASTTypeId)typeId).getReferences().iterator();
|
List refs = ((ASTTypeId)typeId).getReferences();
|
||||||
while( i.hasNext() )
|
int size = refs.size();
|
||||||
|
for( int i = 0; i < size; i++ )
|
||||||
{
|
{
|
||||||
ReferenceCache.ASTReference ref = (ReferenceCache.ASTReference) i.next();
|
ReferenceCache.ASTReference ref = (ReferenceCache.ASTReference) refs.get(i);
|
||||||
if( CharArrayUtils.equals( ref.getNameCharArray(), duple.toCharArray() ) &&
|
if( CharArrayUtils.equals( ref.getNameCharArray(), duple.toCharArray() ) &&
|
||||||
ref.getOffset() == duple.getStartOffset() )
|
ref.getOffset() == duple.getStartOffset() )
|
||||||
{
|
{
|
||||||
cache.returnReference( ref );
|
cache.returnReference( ref );
|
||||||
i.remove();
|
refs.remove( i-- );
|
||||||
|
size--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1206,16 +1208,18 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
kind == Kind.POSTFIX_DOT_IDEXPRESSION || kind == Kind.POSTFIX_DOT_TEMPL_IDEXPRESS )
|
kind == Kind.POSTFIX_DOT_IDEXPRESSION || kind == Kind.POSTFIX_DOT_TEMPL_IDEXPRESS )
|
||||||
{
|
{
|
||||||
ASTExpression astExpression = (ASTExpression) rhs;
|
ASTExpression astExpression = (ASTExpression) rhs;
|
||||||
Iterator refs = astExpression.getReferences().iterator();
|
|
||||||
char[] idExpression = astExpression.getIdExpressionCharArray();
|
char[] idExpression = astExpression.getIdExpressionCharArray();
|
||||||
if( idExpression.length > 0 ) //$NON-NLS-1$
|
if( idExpression.length > 0 ) //$NON-NLS-1$
|
||||||
{
|
{
|
||||||
while( refs.hasNext() )
|
List refs = astExpression.getReferences();
|
||||||
|
int size = refs.size();
|
||||||
|
for( int i = 0; i < size; i++ )
|
||||||
{
|
{
|
||||||
IASTReference r = (IASTReference) refs.next();
|
IASTReference r = (IASTReference) refs.get(i);
|
||||||
if( CharArrayUtils.equals( r.getNameCharArray(), idExpression ) )
|
if( CharArrayUtils.equals( r.getNameCharArray(), idExpression ) )
|
||||||
{
|
{
|
||||||
refs.remove();
|
refs.remove(i--);
|
||||||
|
size--;
|
||||||
cache.returnReference(r);
|
cache.returnReference(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2151,7 +2155,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
|
|
||||||
symbol.prepareForParameters( parameters.size() );
|
symbol.prepareForParameters( parameters.size() );
|
||||||
setParameter( symbol, returnType, false, references );
|
setParameter( symbol, returnType, false, references );
|
||||||
setParameters( symbol, references, parameters.iterator() );
|
setParameters( symbol, references, parameters );
|
||||||
|
|
||||||
symbol.setIsForwardDeclaration(!isFunctionDefinition);
|
symbol.setIsForwardDeclaration(!isFunctionDefinition);
|
||||||
boolean previouslyDeclared = false;
|
boolean previouslyDeclared = false;
|
||||||
|
@ -2213,11 +2217,12 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
* @param symbol
|
* @param symbol
|
||||||
* @param iterator
|
* @param iterator
|
||||||
*/
|
*/
|
||||||
protected void setParameters(IParameterizedSymbol symbol, List references, Iterator iterator) throws ASTSemanticException
|
protected void setParameters(IParameterizedSymbol symbol, List references, List params) throws ASTSemanticException
|
||||||
{
|
{
|
||||||
while( iterator.hasNext() )
|
int size = params.size();
|
||||||
|
for( int i = 0; i < size; i++)
|
||||||
{
|
{
|
||||||
setParameter( symbol, (IASTParameterDeclaration)iterator.next(), true, references );
|
setParameter( symbol, (IASTParameterDeclaration)params.get(i), true, references );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2489,7 +2494,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
symbol.prepareForParameters( parameters.size() );
|
symbol.prepareForParameters( parameters.size() );
|
||||||
if( returnType.getTypeSpecifier() != null )
|
if( returnType.getTypeSpecifier() != null )
|
||||||
setParameter( symbol, returnType, false, references );
|
setParameter( symbol, returnType, false, references );
|
||||||
setParameters( symbol, references, parameters.iterator() );
|
setParameters( symbol, references, parameters );
|
||||||
|
|
||||||
IASTClassSpecifier classifier = null;
|
IASTClassSpecifier classifier = null;
|
||||||
if( scope instanceof IASTTemplateDeclaration ){
|
if( scope instanceof IASTTemplateDeclaration ){
|
||||||
|
@ -2555,7 +2560,6 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
{
|
{
|
||||||
functionDeclaration.setForwardSymbol( symbol );
|
functionDeclaration.setForwardSymbol( symbol );
|
||||||
// set the definition visibility = declaration visibility
|
// set the definition visibility = declaration visibility
|
||||||
// ASTMethodReference reference = (ASTMethodReference) functionReferences.iterator().next();
|
|
||||||
visibility = ((IASTMethod)(functionDeclaration.getASTExtension().getPrimaryDeclaration())).getVisiblity();
|
visibility = ((IASTMethod)(functionDeclaration.getASTExtension().getPrimaryDeclaration())).getVisiblity();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2963,8 +2967,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
{
|
{
|
||||||
previouslyDeclared = true;
|
previouslyDeclared = true;
|
||||||
fieldDeclaration.setForwardSymbol( newSymbol );
|
fieldDeclaration.setForwardSymbol( newSymbol );
|
||||||
// // set the definition visibility = declaration visibility
|
// set the definition visibility = declaration visibility
|
||||||
// ASTReference reference = (ASTReference) fieldReferences.iterator().next();
|
|
||||||
visibility = ((IASTField)fieldDeclaration.getASTExtension().getPrimaryDeclaration()).getVisiblity();
|
visibility = ((IASTField)fieldDeclaration.getASTExtension().getPrimaryDeclaration()).getVisiblity();
|
||||||
}
|
}
|
||||||
provider.returnTypeInfo( newInfo );
|
provider.returnTypeInfo( newInfo );
|
||||||
|
|
|
@ -449,13 +449,12 @@ public class BasicTokenDuple implements ITokenDuple {
|
||||||
if( duple == null ) return false;
|
if( duple == null ) return false;
|
||||||
boolean foundFirst = false;
|
boolean foundFirst = false;
|
||||||
boolean foundLast = false;
|
boolean foundLast = false;
|
||||||
Iterator i = iterator();
|
for( IToken current = getFirstToken(); current != null; current = current.getNext() )
|
||||||
while( i.hasNext() )
|
|
||||||
{
|
{
|
||||||
IToken current = (IToken) i.next();
|
if( current == duple.getFirstToken() ) foundFirst = true;
|
||||||
if( current == firstToken ) foundFirst = true;
|
if( current == duple.getLastToken() ) foundLast = true;
|
||||||
if( current == lastToken ) foundLast = true;
|
|
||||||
if( foundFirst && foundLast ) break;
|
if( foundFirst && foundLast ) break;
|
||||||
|
if( current == getLastToken() ) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ( foundFirst && foundLast );
|
return ( foundFirst && foundLast );
|
||||||
|
|
Loading…
Add table
Reference in a new issue