try {
// TypeConverter is used instead of SourceTypeConverter because the type
// to convert can be a binary type or a source type
TypeDeclaration typeDeclaration = null;
if (type instanceof SourceType) {
SourceType sourceType = (SourceType) type;
ISourceType info = (ISourceType) sourceType.getElementInfo();
compilationUnit = SourceTypeConverter.buildCompilationUnit(
new ISourceType[] {info},//sourceTypes[0] is always toplevel here
SourceTypeConverter.FIELD_AND_METHOD // need field and methods
| SourceTypeConverter.MEMBER_TYPE, // need member types
// no need for field initialization