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

cleaning up more strings

This commit is contained in:
Andrew Niefer 2004-07-28 21:48:27 +00:00
parent 0dda631a21
commit 89010e954f
5 changed files with 20 additions and 15 deletions

View file

@ -20,5 +20,6 @@ public interface IASTConstructorMemberInitializer extends ISourceElementCallback
{ {
public IASTExpression getExpressionList(); public IASTExpression getExpressionList();
public String getName(); public String getName();
public char[] getNameCharArray();
} }

View file

@ -42,6 +42,7 @@ import org.eclipse.cdt.core.parser.ast.IASTTypeId;
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind; import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind; import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind;
import org.eclipse.cdt.core.parser.extension.IParserExtension; import org.eclipse.cdt.core.parser.extension.IParserExtension;
import org.eclipse.cdt.internal.core.parser.scanner2.CharArrayUtils;
import org.eclipse.cdt.internal.core.parser.token.TokenFactory; import org.eclipse.cdt.internal.core.parser.token.TokenFactory;
import org.eclipse.cdt.internal.core.parser.util.TraceUtil; import org.eclipse.cdt.internal.core.parser.util.TraceUtil;
@ -2300,7 +2301,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
.getIdExpressionCharArray()); .getIdExpressionCharArray());
else if (firstExpression.getRHSExpression() != null else if (firstExpression.getRHSExpression() != null
&& firstExpression.getRHSExpression() && firstExpression.getRHSExpression()
.getIdExpression() != null) { .getIdExpressionCharArray() != null) {
setCurrentFunctionName(firstExpression setCurrentFunctionName(firstExpression
.getRHSExpression().getIdExpressionCharArray()); .getRHSExpression().getIdExpressionCharArray());
context = astFactory context = astFactory
@ -2386,7 +2387,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0; endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0;
if (secondExpression != null if (secondExpression != null
&& secondExpression.getExpressionKind() == Kind.ID_EXPRESSION && secondExpression.getExpressionKind() == Kind.ID_EXPRESSION
&& secondExpression.getIdExpression().indexOf('~') != -1) && CharArrayUtils.indexOf( '~', secondExpression.getIdExpressionCharArray() ) != -1)
memberCompletionKind = Kind.POSTFIX_DOT_DESTRUCTOR; memberCompletionKind = Kind.POSTFIX_DOT_DESTRUCTOR;
try { try {
@ -2424,7 +2425,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0; endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0;
if (secondExpression != null if (secondExpression != null
&& secondExpression.getExpressionKind() == Kind.ID_EXPRESSION && secondExpression.getExpressionKind() == Kind.ID_EXPRESSION
&& secondExpression.getIdExpression().indexOf('~') != -1) && CharArrayUtils.indexOf( '~', secondExpression.getIdExpressionCharArray() ) != -1)
arrowCompletionKind = Kind.POSTFIX_ARROW_DESTRUCTOR; arrowCompletionKind = Kind.POSTFIX_ARROW_DESTRUCTOR;
try { try {
firstExpression = astFactory.createExpression(scope, firstExpression = astFactory.createExpression(scope,

View file

@ -54,7 +54,7 @@ public class ASTConstructorMemberInitializer
{ {
return String.valueOf( name ); return String.valueOf( name );
} }
public char[] getNameArray(){ public char[] getNameCharArray(){
return name; return name;
} }
/* (non-Javadoc) /* (non-Javadoc)

View file

@ -1197,7 +1197,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
while( i.hasNext() ) while( i.hasNext() )
{ {
ReferenceCache.ASTReference ref = (ReferenceCache.ASTReference) i.next(); ReferenceCache.ASTReference ref = (ReferenceCache.ASTReference) i.next();
if( ref.getName().equals( duple.toString() ) && if( CharArrayUtils.equals( ref.getNameCharArray(), duple.toCharArray() ) &&
ref.getOffset() == duple.getStartOffset() ) ref.getOffset() == duple.getStartOffset() )
{ {
cache.returnReference( ref ); cache.returnReference( ref );
@ -1256,13 +1256,13 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
{ {
ASTExpression astExpression = (ASTExpression) rhs; ASTExpression astExpression = (ASTExpression) rhs;
Iterator refs = astExpression.getReferences().iterator(); Iterator refs = astExpression.getReferences().iterator();
String idExpression = astExpression.getIdExpression(); char[] idExpression = astExpression.getIdExpressionCharArray();
if( !idExpression.equals( "")) //$NON-NLS-1$ if( idExpression.length > 0 ) //$NON-NLS-1$
{ {
while( refs.hasNext() ) while( refs.hasNext() )
{ {
IASTReference r = (IASTReference) refs.next(); IASTReference r = (IASTReference) refs.next();
if( r.getName().equals( idExpression ) ) if( CharArrayUtils.equals( r.getNameCharArray(), idExpression ) )
{ {
refs.remove(); refs.remove();
cache.returnReference(r); cache.returnReference(r);
@ -2633,13 +2633,13 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
while( initializers.hasNext()) while( initializers.hasNext())
{ {
IASTConstructorMemberInitializer initializer = (IASTConstructorMemberInitializer)initializers.next(); IASTConstructorMemberInitializer initializer = (IASTConstructorMemberInitializer)initializers.next();
if( !initializer.getName().equals( EMPTY_STRING) && if( initializer.getNameCharArray().length > 0 &&
initializer instanceof ASTConstructorMemberInitializer && initializer instanceof ASTConstructorMemberInitializer &&
((ASTConstructorMemberInitializer)initializer).requiresNameResolution() ) ((ASTConstructorMemberInitializer)initializer).requiresNameResolution() )
{ {
ASTConstructorMemberInitializer realInitializer = ((ASTConstructorMemberInitializer)initializer); ASTConstructorMemberInitializer realInitializer = ((ASTConstructorMemberInitializer)initializer);
IDerivableContainerSymbol container = (IDerivableContainerSymbol) symbol.getContainingSymbol(); IDerivableContainerSymbol container = (IDerivableContainerSymbol) symbol.getContainingSymbol();
lookupQualifiedName(container, realInitializer.getNameArray(), ITypeInfo.t_any, null, realInitializer.getNameOffset(), realInitializer.getReferences(), false, LookupType.QUALIFIED); lookupQualifiedName(container, realInitializer.getNameCharArray(), ITypeInfo.t_any, null, realInitializer.getNameOffset(), realInitializer.getReferences(), false, LookupType.QUALIFIED);
// TODO try and resolve parameter references now in the expression list // TODO try and resolve parameter references now in the expression list
} }
} }
@ -3608,9 +3608,9 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
if( reference instanceof ASTExpression ) if( reference instanceof ASTExpression )
{ {
ASTExpression expression = (ASTExpression) reference; ASTExpression expression = (ASTExpression) reference;
final String dupleAsString = duple.toString(); final char[] dupleAsCharArray = duple.toCharArray();
if( expression.getExpressionKind() == IASTExpression.Kind.ID_EXPRESSION && if( expression.getExpressionKind() == IASTExpression.Kind.ID_EXPRESSION &&
expression.getLHSExpression().equals( dupleAsString )) CharArrayUtils.equals( expression.getLHSExpression().getIdExpressionCharArray(), dupleAsCharArray ))
{ {
try { try {
s = lookupQualifiedName( scopeToSymbol( scope ), duple, null, false ); s = lookupQualifiedName( scopeToSymbol( scope ), duple, null, false );
@ -3653,7 +3653,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
} }
else if( expression.getExpressionKind() == Kind.POSTFIX_FUNCTIONCALL && else if( expression.getExpressionKind() == Kind.POSTFIX_FUNCTIONCALL &&
expression.getLHSExpression().getIdExpression().equals( dupleAsString )) CharArrayUtils.equals( expression.getLHSExpression().getIdExpressionCharArray(), dupleAsCharArray ))
{ {
try { try {
ISymbol symbol = getExpressionSymbol( scope, expression.getExpressionKind(), expression.getLHSExpression(), expression.getRHSExpression(), null, null ); ISymbol symbol = getExpressionSymbol( scope, expression.getExpressionKind(), expression.getLHSExpression(), expression.getRHSExpression(), null, null );

View file

@ -26,14 +26,14 @@ public class ASTConstructorMemberInitializer
* @param string * @param string
* @param expressionList * @param expressionList
*/ */
public ASTConstructorMemberInitializer(String name, IASTExpression expressionList) public ASTConstructorMemberInitializer(char[] name, IASTExpression expressionList)
{ {
this.name = name; this.name = name;
this.expressionList = expressionList; this.expressionList = expressionList;
} }
private final IASTExpression expressionList; private final IASTExpression expressionList;
private final String name; private final char[] name;
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTConstructorMemberInitializer#getExpressionList() * @see org.eclipse.cdt.core.parser.ast.IASTConstructorMemberInitializer#getExpressionList()
*/ */
@ -46,6 +46,9 @@ public class ASTConstructorMemberInitializer
*/ */
public String getName() public String getName()
{ {
return String.valueOf(name);
}
public char[] getNameCharArray(){
return name; return name;
} }
/* (non-Javadoc) /* (non-Javadoc)