/** * Removes all generated sources */ private void vanishGeneratedSources() { final PsiShortNamesCache cache = PsiShortNamesCache.getInstance(myProject); final PsiMethod[] methods = cache.getMethodsByName(AsmCodeGenerator.SETUP_METHOD_NAME, GlobalSearchScope.projectScope(myProject)); CodeInsightUtil.preparePsiElementsForWrite(methods); for (int i = 0; i < methods.length; i++) { final PsiMethod method = methods[i]; final PsiClass aClass = method.getContainingClass(); if (aClass != null) { try { final PsiFile psiFile = aClass.getContainingFile(); LOG.assertTrue(psiFile != null); final VirtualFile vFile = psiFile.getVirtualFile(); LOG.assertTrue(vFile != null); myProgressWindow.setText(UIDesignerBundle.message("progress.converting", vFile.getPresentableUrl())); myProgressWindow.setFraction(((double)i) / ((double)methods.length)); if (vFile.isWritable()) { FormSourceCodeGenerator.cleanup(aClass); } } catch (IncorrectOperationException e) { LOG.error(e); } } } }
/** * Removes all generated sources */ private void vanishGeneratedSources() { final PsiShortNamesCache cache = PsiShortNamesCache.getInstance(myProject); final PsiMethod[] methods = cache.getMethodsByName(AsmCodeGenerator.SETUP_METHOD_NAME, GlobalSearchScope.projectScope(myProject)); CodeInsightUtil.preparePsiElementsForWrite(methods); for(int i = 0; i < methods.length; i++) { final PsiMethod method = methods[i]; final PsiClass aClass = method.getContainingClass(); if(aClass != null) { try { final PsiFile psiFile = aClass.getContainingFile(); LOG.assertTrue(psiFile != null); final VirtualFile vFile = psiFile.getVirtualFile(); LOG.assertTrue(vFile != null); myProgressWindow.setText(UIDesignerBundle.message("progress.converting", vFile.getPresentableUrl())); myProgressWindow.setFraction(((double) i) / ((double) methods.length)); if(vFile.isWritable()) { FormSourceCodeGenerator.cleanup(aClass); } } catch(IncorrectOperationException e) { LOG.error(e); } } } }