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

toString method.

This commit is contained in:
Sergey Prigogin 2008-04-28 02:57:27 +00:00
parent 60d02ba145
commit f0be726ff0

View file

@ -65,12 +65,14 @@ public class CPPNamespace extends PlatformObject implements ICPPNamespace, ICPPI
throw new DOMException(this);
}
}
private static final char[] EMPTY_CHAR_ARRAY = { };
IASTName[] namespaceDefinitions = null;
ICPPNamespaceScope scope = null;
ICPPASTTranslationUnit tu = null;
public CPPNamespace(ICPPASTNamespaceDefinition nsDef) {
findAllDefinitions(nsDef);
if (namespaceDefinitions.length == 0) {
@ -256,7 +258,7 @@ public class CPPNamespace extends PlatformObject implements ICPPNamespace, ICPPI
* @see org.eclipse.cdt.core.dom.ast.IBinding#getPhysicalNode()
*/
public IASTNode getPhysicalNode() {
return ( tu != null ? (IASTNode) tu : namespaceDefinitions[0] );
return tu != null ? (IASTNode) tu : namespaceDefinitions[0];
}
/* (non-Javadoc)
@ -344,4 +346,21 @@ public class CPPNamespace extends PlatformObject implements ICPPNamespace, ICPPI
public ILinkage getLinkage() {
return Linkage.CPP_LINKAGE;
}
@Override
public String toString() {
String[] names = getQualifiedName();
if (names.length == 0) {
return "<unnamed namespace>"; //$NON-NLS-1$
} else if (names.length == 1) {
return names[0];
} else {
StringBuilder buf = new StringBuilder(names[0]);
for (int i = 1; i < names.length; i++) {
buf.append("::"); //$NON-NLS-1$
buf.append(names[i]);
}
return buf.toString();
}
}
}