mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-01 21:35:40 +02:00
unified toString() methods for pdom-bindings.
This commit is contained in:
parent
d3a1c826ed
commit
76fda4d2c5
8 changed files with 29 additions and 78 deletions
|
@ -18,9 +18,13 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
import org.eclipse.cdt.core.index.IIndexFileSet;
|
import org.eclipse.cdt.core.index.IIndexFileSet;
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||||
|
@ -223,13 +227,33 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IPDOMBinding
|
||||||
* @see java.lang.Object#toString()
|
* @see java.lang.Object#toString()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public final String toString() {
|
||||||
|
String name;
|
||||||
|
name = toStringBase();
|
||||||
try {
|
try {
|
||||||
return getName() + " " + getConstantNameForValue(getLinkage(), getNodeType()); //$NON-NLS-1$
|
return name + " " + getConstantNameForValue(getLinkage(), getNodeType()); //$NON-NLS-1$
|
||||||
} catch (CoreException ce) {
|
} catch (CoreException ce) {
|
||||||
return getName() + " " + getNodeType(); //$NON-NLS-1$
|
return name + " " + getNodeType(); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected String toStringBase() {
|
||||||
|
if (this instanceof IType) {
|
||||||
|
return ASTTypeUtil.getType((IType) this);
|
||||||
|
} else if (this instanceof IFunction) {
|
||||||
|
IFunctionType t= null;
|
||||||
|
try {
|
||||||
|
t = ((IFunction) this).getType();
|
||||||
|
} catch (DOMException e) {
|
||||||
|
}
|
||||||
|
if (t != null) {
|
||||||
|
return getName() + ASTTypeUtil.getParameterTypeString(t);
|
||||||
|
} else {
|
||||||
|
return getName() + "()"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return getName();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For debug purposes only.
|
* For debug purposes only.
|
||||||
|
|
|
@ -370,11 +370,6 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
|
||||||
PDOMCPPClassScope.acceptViaCache(this, visitor, false);
|
PDOMCPPClassScope.acceptViaCache(this, visitor, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return super.toString() + " <"+ getTemplateParameterMap().toString() + ">"; //$NON-NLS-1$//$NON-NLS-2$
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isAnonymous() {
|
public boolean isAnonymous() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -379,9 +379,4 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return ASTTypeUtil.getType(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||||
|
@ -278,21 +277,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
|
||||||
int cmp = super.pdomCompareTo(other);
|
int cmp = super.pdomCompareTo(other);
|
||||||
return cmp == 0 ? compareSignatures(this, other) : cmp;
|
return cmp == 0 ? compareSignatures(this, other) : cmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
StringBuilder result = new StringBuilder();
|
|
||||||
result.append(getName());
|
|
||||||
IFunctionType t = getType();
|
|
||||||
result.append(t != null ? ASTTypeUtil.getParameterTypeString(t) : "()"); //$NON-NLS-1$
|
|
||||||
try {
|
|
||||||
result.append(" " + getConstantNameForValue(getLinkage(), getNodeType())); //$NON-NLS-1$
|
|
||||||
} catch (CoreException e) {
|
|
||||||
result.append(" " + getNodeType()); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
return result.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static int compareSignatures(IPDOMOverloader a, Object b) {
|
protected static int compareSignatures(IPDOMOverloader a, Object b) {
|
||||||
if (b instanceof IPDOMOverloader) {
|
if (b instanceof IPDOMOverloader) {
|
||||||
IPDOMOverloader bb= (IPDOMOverloader) b;
|
IPDOMOverloader bb= (IPDOMOverloader) b;
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||||
|
@ -101,27 +100,4 @@ class PDOMCPPFunctionInstance extends PDOMCPPFunctionSpecialization implements I
|
||||||
public IType[] getArguments() {
|
public IType[] getArguments() {
|
||||||
return CPPTemplates.getArguments(getTemplateArguments());
|
return CPPTemplates.getArguments(getTemplateArguments());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* For debug purposes only
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("nls")
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
StringBuilder result = new StringBuilder();
|
|
||||||
result.append(getName());
|
|
||||||
result.append("(){");
|
|
||||||
try {
|
|
||||||
result.append(ASTTypeUtil.getType(getType()));
|
|
||||||
} catch (DOMException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
result.append("} ");
|
|
||||||
try {
|
|
||||||
result.append(getConstantNameForValue(getLinkage(), getNodeType()));
|
|
||||||
} catch (CoreException ce) {
|
|
||||||
result.append(getNodeType());
|
|
||||||
}
|
|
||||||
return result.toString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -210,7 +210,7 @@ class PDOMCPPNamespace extends PDOMCPPBinding
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
protected String toStringBase() {
|
||||||
String[] names = getQualifiedName();
|
String[] names = getQualifiedName();
|
||||||
if (names.length == 0) {
|
if (names.length == 0) {
|
||||||
return "<unnamed namespace>"; //$NON-NLS-1$
|
return "<unnamed namespace>"; //$NON-NLS-1$
|
||||||
|
|
|
@ -104,22 +104,4 @@ abstract class PDOMCPPSpecialization extends PDOMCPPBinding implements ICPPSpeci
|
||||||
public int getSignatureHash() throws CoreException {
|
public int getSignatureHash() throws CoreException {
|
||||||
return getDB().getInt(record + SIGNATURE_HASH);
|
return getDB().getInt(record + SIGNATURE_HASH);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* For debug purposes only
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
StringBuilder result = new StringBuilder();
|
|
||||||
result.append(getName());
|
|
||||||
result.append(' ');
|
|
||||||
result.append(getArgumentMap().toString());
|
|
||||||
result.append(' ');
|
|
||||||
try {
|
|
||||||
result.append(getConstantNameForValue(getLinkage(), getNodeType()));
|
|
||||||
} catch (CoreException ce) {
|
|
||||||
result.append(getNodeType());
|
|
||||||
}
|
|
||||||
return result.toString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
|
@ -71,11 +70,6 @@ class PDOMCPPUnknownClassInstance extends PDOMCPPUnknownClassType implements ICP
|
||||||
}
|
}
|
||||||
return arguments;
|
return arguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return getName() + " " + ASTTypeUtil.getArgumentListString(getArguments(), true); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSameType(IType type) {
|
public boolean isSameType(IType type) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue