1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 10:16:03 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2013-09-04 15:17:29 -07:00
parent 364783cb62
commit afecac9ccd
7 changed files with 81 additions and 92 deletions

View file

@ -39,8 +39,8 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTProblem;
import org.eclipse.cdt.internal.core.model.ASTStringUtil; import org.eclipse.cdt.internal.core.model.ASTStringUtil;
/** /**
* This is a utility class to help convert AST elements to Strings corresponding to the AST element's * This is a utility class to help convert AST elements to Strings corresponding to the AST
* signature. * element's signature.
* *
* @noextend This interface is not intended to be extended by clients. * @noextend This interface is not intended to be extended by clients.
* @noinstantiate This class is not intended to be instantiated by clients. * @noinstantiate This class is not intended to be instantiated by clients.
@ -52,13 +52,11 @@ public class ASTSignatureUtil {
private static final String COMMA_SPACE = ", "; //$NON-NLS-1$ private static final String COMMA_SPACE = ", "; //$NON-NLS-1$
private static final String EMPTY_STRING = ""; //$NON-NLS-1$ private static final String EMPTY_STRING = ""; //$NON-NLS-1$
private static final String SPACE = " "; //$NON-NLS-1$ private static final String SPACE = " "; //$NON-NLS-1$
private static final String[] EMPTY_STRING_ARRAY = new String[0]; private static final String[] EMPTY_STRING_ARRAY = {};
/** /**
* Return's the String representation of a node's type (if available). This is currently only being used * Return's the String representation of a node's type (if available). This is currently only
* for testing. * being used for testing.
*
* TODO Remove this function when done testing if it is no longer needed
* *
* @param node * @param node
*/ */
@ -71,7 +69,7 @@ public class ASTSignatureUtil {
return getSignature((IASTTypeId) node); return getSignature((IASTTypeId) node);
if (node instanceof IASTSimpleDeclaration) { if (node instanceof IASTSimpleDeclaration) {
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) node; IASTSimpleDeclaration decl = (IASTSimpleDeclaration) node;
StringBuffer buffer = new StringBuffer(getSignature(decl.getDeclSpecifier())); StringBuilder buffer = new StringBuilder(getSignature(decl.getDeclSpecifier()));
IASTDeclarator[] declarators = decl.getDeclarators(); IASTDeclarator[] declarators = decl.getDeclarators();
for (int i = 0; i < declarators.length; ++i) { for (int i = 0; i < declarators.length; ++i) {
@ -108,7 +106,7 @@ public class ASTSignatureUtil {
if (!(decltor instanceof IASTStandardFunctionDeclarator || decltor instanceof ICASTKnRFunctionDeclarator)) if (!(decltor instanceof IASTStandardFunctionDeclarator || decltor instanceof ICASTKnRFunctionDeclarator))
return EMPTY_STRING; return EMPTY_STRING;
StringBuffer result = new StringBuffer(); StringBuilder result = new StringBuilder();
String[] parms = getParameterSignatureArray(decltor); String[] parms = getParameterSignatureArray(decltor);
@ -175,7 +173,7 @@ public class ASTSignatureUtil {
} }
private static String getDeclaratorSpecificSignature(IASTDeclarator declarator) { private static String getDeclaratorSpecificSignature(IASTDeclarator declarator) {
StringBuffer result = new StringBuffer(); StringBuilder result = new StringBuilder();
IASTPointerOperator[] ops = declarator.getPointerOperators(); IASTPointerOperator[] ops = declarator.getPointerOperators();
boolean needSpace = false; boolean needSpace = false;
@ -278,7 +276,7 @@ public class ASTSignatureUtil {
if (declarator == null) if (declarator == null)
return EMPTY_STRING; return EMPTY_STRING;
StringBuffer result = new StringBuffer(); StringBuilder result = new StringBuilder();
result.append(getDeclaratorSpecificSignature(declarator)); result.append(getDeclaratorSpecificSignature(declarator));
@ -298,14 +296,11 @@ public class ASTSignatureUtil {
/** /**
* This function is used to return the signature of an IASTInitializer. * This function is used to return the signature of an IASTInitializer.
* *
* TODO this function is used for testing and probably should not public once this Utility class has been * @param init an initializer
* finalized as it will likely never be used publicly except for testing
*
* @param init
* @return the signature of an IASTInitializer * @return the signature of an IASTInitializer
*/ */
public static String getInitializerString(IASTInitializer init) { public static String getInitializerString(IASTInitializer init) {
StringBuffer result = new StringBuffer(); StringBuilder result = new StringBuilder();
if (init instanceof IASTEqualsInitializer) { if (init instanceof IASTEqualsInitializer) {
result.append(Keywords.cpASSIGN); result.append(Keywords.cpASSIGN);
@ -332,7 +327,7 @@ public class ASTSignatureUtil {
return result.toString(); return result.toString();
} }
private static void appendExpressionList(StringBuffer result, IASTInitializerClause[] inits) { private static void appendExpressionList(StringBuilder result, IASTInitializerClause[] inits) {
for (int i = 0; i < inits.length; i++) { for (int i = 0; i < inits.length; i++) {
result.append(getInitializerClauseString(inits[i])); result.append(getInitializerClauseString(inits[i]));
if (i < inits.length - 1) if (i < inits.length - 1)
@ -351,7 +346,7 @@ public class ASTSignatureUtil {
} }
private static String getDesignatorSignature(ICASTDesignator designator) { private static String getDesignatorSignature(ICASTDesignator designator) {
StringBuffer result = new StringBuffer(); StringBuilder result = new StringBuilder();
if (designator instanceof ICASTArrayDesignator) { if (designator instanceof ICASTArrayDesignator) {
result.append(Keywords.cpLBRACKET); result.append(Keywords.cpLBRACKET);
@ -374,15 +369,15 @@ public class ASTSignatureUtil {
} }
/** /**
* Returns the String signature corresponding to an IASTDeclarator. This includes the signature of the * Returns the String signature corresponding to an IASTDeclarator. This includes the signature
* parameters which is built via ASTSignatureUtil#getParameterSignature(IASTDeclarator) if the declarator * of the parameters which is built via ASTSignatureUtil#getParameterSignature(IASTDeclarator)
* is for a function. * if the declarator is for a function.
* *
* @param declarator * @param declarator
* @return the String signature corresponding to an IASTDeclarator * @return the String signature corresponding to an IASTDeclarator
*/ */
public static String getSignature(IASTDeclarator declarator) { public static String getSignature(IASTDeclarator declarator) {
StringBuffer result = new StringBuffer(); StringBuilder result = new StringBuilder();
// get the declSpec // get the declSpec
IASTDeclSpecifier declSpec = null; IASTDeclSpecifier declSpec = null;
@ -429,7 +424,7 @@ public class ASTSignatureUtil {
return EMPTY_STRING; return EMPTY_STRING;
boolean needSpace = false; boolean needSpace = false;
StringBuffer result = new StringBuffer(); StringBuilder result = new StringBuilder();
if (declSpec.getStorageClass() == IASTDeclSpecifier.sc_mutable) { if (declSpec.getStorageClass() == IASTDeclSpecifier.sc_mutable) {
result.append(Keywords.MUTABLE); result.append(Keywords.MUTABLE);
@ -863,7 +858,7 @@ public class ASTSignatureUtil {
} }
private static String getArraySubscriptExpression(IASTArraySubscriptExpression expression) { private static String getArraySubscriptExpression(IASTArraySubscriptExpression expression) {
StringBuffer result = new StringBuffer(); StringBuilder result = new StringBuilder();
result.append(getExpressionString(expression.getArrayExpression())); result.append(getExpressionString(expression.getArrayExpression()));
result.append(Keywords.cpLBRACKET); result.append(Keywords.cpLBRACKET);
result.append(getInitializerClauseString(expression.getArgument())); result.append(getInitializerClauseString(expression.getArgument()));
@ -872,7 +867,7 @@ public class ASTSignatureUtil {
} }
private static String getCastExpression(IASTCastExpression expression) { private static String getCastExpression(IASTCastExpression expression) {
StringBuffer result = new StringBuffer(); StringBuilder result = new StringBuilder();
boolean normalCast = false; boolean normalCast = false;
if (expression.getOperator() == IASTCastExpression.op_cast) if (expression.getOperator() == IASTCastExpression.op_cast)
@ -897,7 +892,7 @@ public class ASTSignatureUtil {
} }
private static String getFieldReference(IASTFieldReference expression) { private static String getFieldReference(IASTFieldReference expression) {
StringBuffer result = new StringBuffer(); StringBuilder result = new StringBuilder();
result.append(getExpressionString(expression.getFieldOwner())); result.append(getExpressionString(expression.getFieldOwner()));
if (expression.isPointerDereference()) if (expression.isPointerDereference())
result.append(Keywords.cpARROW); result.append(Keywords.cpARROW);
@ -909,7 +904,7 @@ public class ASTSignatureUtil {
} }
private static String getFunctionCallExpression(IASTFunctionCallExpression expression) { private static String getFunctionCallExpression(IASTFunctionCallExpression expression) {
StringBuffer result = new StringBuffer(); StringBuilder result = new StringBuilder();
result.append(getExpressionString(expression.getFunctionNameExpression())); result.append(getExpressionString(expression.getFunctionNameExpression()));
result.append(Keywords.cpLPAREN); result.append(Keywords.cpLPAREN);
IASTInitializerClause[] clauses = expression.getArguments(); IASTInitializerClause[] clauses = expression.getArguments();
@ -924,7 +919,7 @@ public class ASTSignatureUtil {
} }
private static String getTypeIdInitializerExpression(ICASTTypeIdInitializerExpression expression) { private static String getTypeIdInitializerExpression(ICASTTypeIdInitializerExpression expression) {
StringBuffer result = new StringBuffer(); StringBuilder result = new StringBuilder();
result.append(Keywords.cpLPAREN); result.append(Keywords.cpLPAREN);
result.append(getSignature(expression.getTypeId())); result.append(getSignature(expression.getTypeId()));
result.append(Keywords.cpRPAREN); result.append(Keywords.cpRPAREN);
@ -933,7 +928,7 @@ public class ASTSignatureUtil {
} }
private static String getDeleteExpression(ICPPASTDeleteExpression expression) { private static String getDeleteExpression(ICPPASTDeleteExpression expression) {
StringBuffer result = new StringBuffer(); StringBuilder result = new StringBuilder();
result.append(Keywords.DELETE); result.append(Keywords.DELETE);
result.append(SPACE); result.append(SPACE);
if (expression.getOperand() != null) if (expression.getOperand() != null)
@ -942,7 +937,7 @@ public class ASTSignatureUtil {
} }
private static String getSimpleTypeConstructorExpression(ICPPASTSimpleTypeConstructorExpression expression) { private static String getSimpleTypeConstructorExpression(ICPPASTSimpleTypeConstructorExpression expression) {
StringBuffer result = new StringBuffer(); StringBuilder result = new StringBuilder();
result.append(getSignature(expression.getDeclSpecifier())); result.append(getSignature(expression.getDeclSpecifier()));
result.append(getInitializerString(expression.getInitializer())); result.append(getInitializerString(expression.getInitializer()));
return result.toString(); return result.toString();
@ -954,7 +949,7 @@ public class ASTSignatureUtil {
} }
private static String getTypeIdExpression(IASTTypeIdExpression expression) { private static String getTypeIdExpression(IASTTypeIdExpression expression) {
StringBuffer result = new StringBuffer(); StringBuilder result = new StringBuilder();
String operator = getTypeIdExpressionOperator(expression); String operator = getTypeIdExpressionOperator(expression);
if (operator != null && !operator.equals(EMPTY_STRING)) if (operator != null && !operator.equals(EMPTY_STRING))
result.append(operator); result.append(operator);
@ -970,7 +965,7 @@ public class ASTSignatureUtil {
} }
private static String getExpressionList(IASTExpressionList expression) { private static String getExpressionList(IASTExpressionList expression) {
StringBuffer result = new StringBuffer(); StringBuilder result = new StringBuilder();
IASTExpression[] exps = expression.getExpressions(); IASTExpression[] exps = expression.getExpressions();
if (exps != null && exps.length > 0) { if (exps != null && exps.length > 0) {
for (int i = 0; i < exps.length; i++) { for (int i = 0; i < exps.length; i++) {
@ -996,7 +991,7 @@ public class ASTSignatureUtil {
} }
private static String getConditionalExpression(IASTConditionalExpression expression) { private static String getConditionalExpression(IASTConditionalExpression expression) {
StringBuffer result = new StringBuffer(); StringBuilder result = new StringBuilder();
result.append(getExpressionString(expression.getLogicalConditionExpression())); result.append(getExpressionString(expression.getLogicalConditionExpression()));
result.append(SPACE); result.append(SPACE);
result.append(Keywords.cpQUESTION); result.append(Keywords.cpQUESTION);
@ -1013,7 +1008,7 @@ public class ASTSignatureUtil {
} }
private static String getNewExpression(ICPPASTNewExpression expression) { private static String getNewExpression(ICPPASTNewExpression expression) {
StringBuffer result = new StringBuffer(); StringBuilder result = new StringBuilder();
result.append(Keywords.NEW); result.append(Keywords.NEW);
result.append(SPACE); result.append(SPACE);
final IASTInitializerClause[] args = expression.getPlacementArguments(); final IASTInitializerClause[] args = expression.getPlacementArguments();
@ -1030,7 +1025,7 @@ public class ASTSignatureUtil {
} }
private static String getBinaryExpression(IASTBinaryExpression expression) { private static String getBinaryExpression(IASTBinaryExpression expression) {
StringBuffer buffer = new StringBuffer(); StringBuilder buffer = new StringBuilder();
buffer.append(getExpressionString(expression.getOperand1())); buffer.append(getExpressionString(expression.getOperand1()));
buffer.append(SPACE); buffer.append(SPACE);
buffer.append(getBinaryOperatorString(expression)); buffer.append(getBinaryOperatorString(expression));
@ -1040,7 +1035,7 @@ public class ASTSignatureUtil {
} }
private static String getUnaryExpression(IASTUnaryExpression expression) { private static String getUnaryExpression(IASTUnaryExpression expression) {
StringBuffer buffer = new StringBuffer(); StringBuilder buffer = new StringBuilder();
boolean postOperator = false; boolean postOperator = false;
boolean primaryBracketed = false; boolean primaryBracketed = false;

View file

@ -193,8 +193,8 @@ public class ASTTypeUtil {
} }
/** /**
* Returns an array of normalized string representations for the parameter types of the * Returns an array of normalized string representations for the parameter types of the given
* given function type. * function type.
* @see #getType(IType, boolean) * @see #getType(IType, boolean)
*/ */
public static String[] getParameterTypeStringArray(IFunctionType type) { public static String[] getParameterTypeStringArray(IFunctionType type) {
@ -367,7 +367,7 @@ public class ASTTypeUtil {
boolean qualify = normalize || (type instanceof ITypedef && type instanceof ICPPSpecialization); boolean qualify = normalize || (type instanceof ITypedef && type instanceof ICPPSpecialization);
appendCppName((ICPPBinding) type, normalize, qualify, result); appendCppName((ICPPBinding) type, normalize, qualify, result);
} else if (type instanceof ICompositeType) { } else if (type instanceof ICompositeType) {
// 101114 fix, do not display class, and for consistency don't display struct/union as well // Don't display class, and for consistency don't display struct/union as well (bug 101114).
appendNameCheckAnonymous((ICompositeType) type, result); appendNameCheckAnonymous((ICompositeType) type, result);
} else if (type instanceof ITypedef) { } else if (type instanceof ITypedef) {
result.append(((ITypedef) type).getNameCharArray()); result.append(((ITypedef) type).getNameCharArray());
@ -511,26 +511,26 @@ public class ASTTypeUtil {
} }
} else { } else {
if (type instanceof ICPPReferenceType) { if (type instanceof ICPPReferenceType) {
// reference types ignore cv-qualifiers // Reference types ignore cv-qualifiers
cvq= null; cvq= null;
// lvalue references win over rvalue references // Lvalue references win over rvalue references
if (ref == null || ref.isRValueReference()) { if (ref == null || ref.isRValueReference()) {
// delay reference to see if there are more // Delay reference to see if there are more
ref= (ICPPReferenceType) type; ref= (ICPPReferenceType) type;
} }
} else { } else {
if (cvq != null) { if (cvq != null) {
// merge cv qualifiers // Merge cv qualifiers
if (type instanceof IQualifierType || type instanceof IPointerType) { if (type instanceof IQualifierType || type instanceof IPointerType) {
type= SemanticUtil.addQualifiers(type, cvq.isConst(), cvq.isVolatile(), false); type= SemanticUtil.addQualifiers(type, cvq.isConst(), cvq.isVolatile(), false);
cvq= null; cvq= null;
} }
} }
if (type instanceof IQualifierType) { if (type instanceof IQualifierType) {
// delay cv qualifier to merge it with others // Delay cv qualifier to merge it with others
cvq= (IQualifierType) type; cvq= (IQualifierType) type;
} else { } else {
// no reference, no cv qualifier: output reference and cv-qualifier // No reference, no cv qualifier: output reference and cv-qualifier
if (ref != null) { if (ref != null) {
types = ArrayUtil.append(IType.class, types, ref); types = ArrayUtil.append(IType.class, types, ref);
ref= null; ref= null;
@ -552,12 +552,12 @@ public class ASTTypeUtil {
} }
} }
// pop all of the types off of the stack, and build the string representation while doing so // Pop all of the types off of the stack, and build the string representation while doing so.
List<IType> postfix= null; List<IType> postfix= null;
BitSet parenthesis= null; BitSet parenthesis= null;
boolean needParenthesis= false; boolean needParenthesis= false;
boolean needSpace= false; boolean needSpace= false;
for (int j = types.length - 1; j >= 0; j--) { for (int j = types.length; --j >= 0;) {
IType tj = types[j]; IType tj = types[j];
if (tj != null) { if (tj != null) {
if (j > 0 && types[j - 1] instanceof IQualifierType) { if (j > 0 && types[j - 1] instanceof IQualifierType) {
@ -569,7 +569,7 @@ public class ASTTypeUtil {
needSpace= true; needSpace= true;
--j; --j;
} else { } else {
// handle post-fix // Handle post-fix
if (tj instanceof IFunctionType || tj instanceof IArrayType) { if (tj instanceof IFunctionType || tj instanceof IArrayType) {
if (j == 0) { if (j == 0) {
if (needSpace) if (needSpace)

View file

@ -61,35 +61,32 @@ public interface ICPPClassType extends ICompositeType, ICPPBinding {
public IField findField(String name); public IField findField(String name);
/** /**
* Returns a list of ICPPField objects representing fields declared in this * Returns a list of ICPPField objects representing fields declared in this class. It does not
* class. It does not include fields inherited from base classes. * include fields inherited from base classes.
* *
* @return List of ICPPField * @return List of ICPPField
*/ */
public ICPPField[] getDeclaredFields(); public ICPPField[] getDeclaredFields();
/** /**
* Returns a list of ICPPMethod objects representing all methods defined for * Returns a list of ICPPMethod objects representing all methods defined for this class
* this class including those declared, inherited, or generated (e.g. * including those declared, inherited, or generated (e.g. default constructors and the like).
* default constructors and the like).
* *
* @return List of ICPPMethod * @return List of ICPPMethod
*/ */
public ICPPMethod[] getMethods(); public ICPPMethod[] getMethods();
/** /**
* Returns a list of ICPPMethod objects representing all method explicitly * Returns a list of ICPPMethod objects representing all method explicitly declared by this
* declared by this class and inherited from base classes. It does not * class and inherited from base classes. It does not include automatically generated methods.
* include automatically generated methods.
* *
* @return List of ICPPMethod * @return List of ICPPMethod
*/ */
public ICPPMethod[] getAllDeclaredMethods(); public ICPPMethod[] getAllDeclaredMethods();
/** /**
* Returns a list of ICPPMethod objects representing all methods explicitly * Returns a list of ICPPMethod objects representing all methods explicitly declared by this
* declared by this class. It does not include inherited methods or * class. It does not include inherited methods or automatically generated methods.
* automatically generated methods.
* *
* @return List of ICPPMethod * @return List of ICPPMethod
*/ */
@ -97,14 +94,12 @@ public interface ICPPClassType extends ICompositeType, ICPPBinding {
/** /**
* Returns an array of ICPPConstructor objects representing the constructors * Returns an array of ICPPConstructor objects representing the constructors
* for this class. This list includes both declared and implicit * for this class. This list includes both declared and implicit constructors.
* constructors.
*/ */
public ICPPConstructor[] getConstructors(); public ICPPConstructor[] getConstructors();
/** /**
* Returns an array of bindings for those classes/functions declared as * Returns an array of bindings for those classes/functions declared as friends of this class.
* friends of this class.
*/ */
public IBinding[] getFriends(); public IBinding[] getFriends();
@ -121,14 +116,13 @@ public interface ICPPClassType extends ICompositeType, ICPPBinding {
public boolean isFinal(); public boolean isFinal();
/** /**
* Gets the access specifier of the <code>member</code>. * Gets the access specifier of the {@code member}.
* *
* @param member The binding of the member to get the visibility for. * @param member The binding of the member to get the visibility for.
* <code>member</code> must be a member of this type. * {@code member} must be a member of this class.
* *
* @return the visibility of the specified member. * @return the visibility of the specified member.
* * @throws IllegalArgumentException if {@code member} is not a member of this class.
* @throws IllegalArgumentException if <code>member</code> is not a member of this type.
* *
* @since 5.5 * @since 5.5
*/ */

View file

@ -22,6 +22,13 @@ import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUti
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getNestedType; import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getNestedType;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getUltimateTypeUptoPointers; import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getUltimateTypeUptoPointers;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.eclipse.cdt.core.dom.ast.ASTGenericVisitor; import org.eclipse.cdt.core.dom.ast.ASTGenericVisitor;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty; import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.ASTVisitor;
@ -208,13 +215,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownType; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownType;
import org.eclipse.cdt.internal.core.index.IIndexScope; import org.eclipse.cdt.internal.core.index.IIndexScope;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/** /**
* Collection of methods to extract information from a C++ translation unit. * Collection of methods to extract information from a C++ translation unit.
*/ */
@ -2381,21 +2381,21 @@ public class CPPVisitor extends ASTQueries {
if (owner instanceof ICPPEnumeration && !((ICPPEnumeration) owner).isScoped()) { if (owner instanceof ICPPEnumeration && !((ICPPEnumeration) owner).isScoped()) {
continue; continue;
} }
String n= owner.getName(); String name= owner.getName();
if (n == null) if (name == null)
break; break;
if (owner instanceof ICPPFunction) if (owner instanceof ICPPFunction)
break; break;
if (owner instanceof ICPPNamespace && n.length() == 0) { if (owner instanceof ICPPNamespace && name.length() == 0) {
// TODO(sprigogin): Do not ignore anonymous namespaces. // TODO(sprigogin): Do not ignore anonymous namespaces.
continue; continue;
} }
ns = ArrayUtil.append(String.class, ns, n); ns = ArrayUtil.append(String.class, ns, name);
} }
ns = ArrayUtil.trim(String.class, ns); ns = ArrayUtil.trim(String.class, ns);
String[] result = new String[ns.length + 1]; String[] result = new String[ns.length + 1];
for (int i = ns.length - 1; i >= 0; i--) { for (int i = ns.length; --i >= 0;) {
result[ns.length - i - 1] = ns[i]; result[ns.length - i - 1] = ns[i];
} }
result[ns.length]= binding.getName(); result[ns.length]= binding.getName();
@ -2406,15 +2406,15 @@ public class CPPVisitor extends ASTQueries {
char[][] ns = EMPTY_CHAR_ARRAY_ARRAY; char[][] ns = EMPTY_CHAR_ARRAY_ARRAY;
ns = ArrayUtil.append(ns, binding.getNameCharArray()); ns = ArrayUtil.append(ns, binding.getNameCharArray());
for (IBinding owner= binding.getOwner(); owner != null; owner= owner.getOwner()) { for (IBinding owner= binding.getOwner(); owner != null; owner= owner.getOwner()) {
char[] n= owner.getNameCharArray(); char[] name= owner.getNameCharArray();
if (n == null) if (name == null)
break; break;
if (owner instanceof ICPPFunction) if (owner instanceof ICPPFunction)
break; break;
if (owner instanceof ICPPNamespace && n.length == 0) if (owner instanceof ICPPNamespace && name.length == 0)
continue; continue;
ns = ArrayUtil.append(ns, n); ns = ArrayUtil.append(ns, name);
} }
ns = ArrayUtil.trim(ns); ns = ArrayUtil.trim(ns);
ArrayUtil.reverse(ns); ArrayUtil.reverse(ns);

View file

@ -14,6 +14,10 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp; package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
@ -130,10 +134,6 @@ import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode; import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
/** /**
* Container for c++-entities. * Container for c++-entities.
*/ */
@ -341,7 +341,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
PDOMBinding pdomBinding= attemptFastAdaptBinding(inputBinding); PDOMBinding pdomBinding= attemptFastAdaptBinding(inputBinding);
if (pdomBinding == null) { if (pdomBinding == null) {
// assign names to anonymous types. // Assign names to anonymous types.
IBinding binding= PDOMASTAdapter.getAdapterForAnonymousASTBinding(inputBinding); IBinding binding= PDOMASTAdapter.getAdapterForAnonymousASTBinding(inputBinding);
if (binding == null) if (binding == null)
return null; return null;