1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-05 16:56:04 +02:00

FIx to make it backward compatible with CDT 6.0

This commit is contained in:
Alena Laskavaia 2010-05-17 18:14:01 +00:00
parent f004315ce5
commit 05dc3fac9a

View file

@ -19,24 +19,29 @@ import org.eclipse.cdt.core.dom.ast.ITypedef;
*/
public final class CxxAstUtils {
private static CxxAstUtils instance;
private CxxAstUtils(){
private CxxAstUtils() {
// private constructor
}
public synchronized static CxxAstUtils getInstance(){
if (instance==null) instance = new CxxAstUtils();
public synchronized static CxxAstUtils getInstance() {
if (instance == null) instance = new CxxAstUtils();
return instance;
}
public IType unwindTypedef(IType type) {
if (!(type instanceof IBinding)) return type;
IBinding typeName = (IBinding) type;
// unwind typedef chain
while (typeName instanceof ITypedef) {
IType t = ((ITypedef) typeName).getType();
if (t instanceof IBinding)
typeName = (IBinding) t;
else
return t;
try {
while (typeName instanceof ITypedef) {
IType t = ((ITypedef) typeName).getType();
if (t instanceof IBinding) typeName = (IBinding) t;
else return t;
}
} catch (Exception e) { // in CDT 6.0 getType throws DOMException
Activator.log(e);
}
return (IType)typeName;
return (IType) typeName;
}
}