1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 17:56:01 +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 { public final class CxxAstUtils {
private static CxxAstUtils instance; private static CxxAstUtils instance;
private CxxAstUtils(){
private CxxAstUtils() {
// private constructor // 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; return instance;
} }
public IType unwindTypedef(IType type) { public IType unwindTypedef(IType type) {
if (!(type instanceof IBinding)) return type; if (!(type instanceof IBinding)) return type;
IBinding typeName = (IBinding) type; IBinding typeName = (IBinding) type;
// unwind typedef chain // unwind typedef chain
try {
while (typeName instanceof ITypedef) { while (typeName instanceof ITypedef) {
IType t = ((ITypedef) typeName).getType(); IType t = ((ITypedef) typeName).getType();
if (t instanceof IBinding) if (t instanceof IBinding) typeName = (IBinding) t;
typeName = (IBinding) t; else return t;
else
return t;
} }
return (IType)typeName; } catch (Exception e) { // in CDT 6.0 getType throws DOMException
Activator.log(e);
}
return (IType) typeName;
} }
} }