void (final PsiTreeChangeEvent event, PsiElement parent, PsiElement child) { PsiFile psiFile = event.getFile(); if (processConfigFileChange(psiFile)) return; if (!(psiFile instanceof PsiClassOwner)) { return; } // do not load file content on file creation (`MyVirtualFileListener` will signal itself) // see `ListenerListTest.test all methods resolved` if (parent instanceof PsiFile && child == null) { return; } final var possiblePsiTypes = getPossiblePsiTypesFor(psiFile.getLanguage().getID()); if (possiblePsiTypes == null) { return; } final var newChild = event.getNewChild(); final var grandParent = parent == null ? null : parent.getParent(); final var firstSibling = parent != null && parent.isValid() ? parent.getFirstChild() : null; PsiElement unsafeGrandChild = null; if (!(child instanceof LazyParseablePsiElement)) { // Chameleons unconditionally log an error IDEA-255174 try { unsafeGrandChild = child == null ? null : child.getFirstChild(); } catch (PsiInvalidElementAccessException ignored) { // we can not check if the child is valid since most of the time // they are indeed invalid due to user typing, so the `getFirstChild()` // may throw an exception. But we are forced here to ask for the child // since we do not have any other information. } } if (isRelevantAnnotation(child, possiblePsiTypes) // removed annotation || isRelevantAnnotation(unsafeGrandChild, possiblePsiTypes) // removed annotation || isRelevantAnnotation(newChild, possiblePsiTypes) // added annotation || (isInstanceOf(grandParent, possiblePsiTypes.forClasses) // modifier changed (static, public) && !isInstanceOf(parent, possiblePsiTypes.forAnnotationOwners)) || ((isInstanceOf(parent, possiblePsiTypes.forClasses) // added/removed inner class || isInstanceOf(grandParent, possiblePsiTypes.forClasses)) && (isInstanceOf(child, possiblePsiTypes.forClasses) || isInstanceOf(event.getNewChild(), possiblePsiTypes.forClasses) || isInstanceOf(event.getOldChild(), possiblePsiTypes.forClasses))) || isInstanceOf(firstSibling, possiblePsiTypes.forImports) // added import || isInstanceOf(unsafeGrandChild, possiblePsiTypes.forImports) // removed import || isInstanceOf(child, possiblePsiTypes.forImports) // removed import || null != PsiTreeUtil.findFirstParent(parent, it -> isInstanceOf(it, possiblePsiTypes.forImports) // changed import (completion, typing) || isRelevantAnnotation(it, possiblePsiTypes))// editing on or inside annotation || child instanceof LazyParseablePsiElement ) { incModificationCount(); } }