public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) { if (!CodeInsightUtilBase.preparePsiElementForWrite(descriptor.getPsiElement())) return; final PsiMethod psiMethod = PsiTreeUtil.getParentOfType(descriptor.getPsiElement(), PsiMethod.class); if (psiMethod != null) { final ArrayList<PsiElement> psiParameters = new ArrayList<PsiElement>(); final RefElement refMethod = myManager != null ? myManager.getReference(psiMethod) : null; if (refMethod != null) { for (final RefParameter refParameter : getUnusedParameters((RefMethod) refMethod)) { psiParameters.add(refParameter.getElement()); } } else { final PsiParameter[] parameters = psiMethod.getParameterList().getParameters(); for (PsiParameter parameter : parameters) { if (Comparing.strEqual(parameter.getName(), myHint)) { psiParameters.add(parameter); break; } } } final PsiModificationTracker tracker = psiMethod.getManager().getModificationTracker(); final long startModificationCount = tracker.getModificationCount(); removeUnusedParameterViaChangeSignature(psiMethod, psiParameters); if (refMethod != null && startModificationCount != tracker.getModificationCount()) { myProcessor.ignoreElement(refMethod); } } }
protected void childrenChanged( PsiElement parent, final boolean stopProcessingForThisModificationCount) { if (parent instanceof PsiDirectory && isFlattenPackages()) { getUpdater().addSubtreeToUpdate(getRootNode()); return; } long newModificationCount = myModificationTracker.getOutOfCodeBlockModificationCount(); if (newModificationCount == myOutOfCodeBlockModificationCount) return; if (stopProcessingForThisModificationCount) { myOutOfCodeBlockModificationCount = newModificationCount; } while (true) { if (parent == null) break; if (parent instanceof PsiFile) { VirtualFile virtualFile = ((PsiFile) parent).getVirtualFile(); if (virtualFile != null && myFileTypeManager.getFileTypeByFile(virtualFile) != FileTypes.PLAIN_TEXT) { // adding a class within a file causes a new node to appear in project view => entire dir // should be updated parent = ((PsiFile) parent).getContainingDirectory(); if (parent == null) break; } } if (getUpdater().addSubtreeToUpdateByElement(parent)) { break; } if (parent instanceof PsiFile || parent instanceof PsiDirectory) break; parent = parent.getParent(); } }
protected ProjectViewPsiTreeChangeListener(Project project) { myFileTypeManager = FileTypeManager.getInstance(); myModificationTracker = PsiManager.getInstance(project).getModificationTracker(); myOutOfCodeBlockModificationCount = myModificationTracker.getOutOfCodeBlockModificationCount(); }