}
public ICompilationUnit generate(WidgetAdapter root, IProgressMonitor monitor) {
try {
IParser parser = (IParser) root.getAdapter(IParser.class);
if (parser == null)
return null;
ICompilationUnit unit = root.getCompilationUnit();
ICompilationUnit copy = unit.getWorkingCopy(monitor);
IType type = getUnitMainType(copy);
if (type != null) {
ImportRewrite imports = createImportRewrite(copy);
boolean success = parser.generateCode(type, imports, monitor);
if (!success)
return null;
removeRemovedComponent(root, monitor, unit, type);
createPreferredLnf(root, monitor, type, imports);
if (success) {