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:
parent
f004315ce5
commit
05dc3fac9a
1 changed files with 15 additions and 10 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue