void (@NotNull PsiTreeChangeEventImpl event) { boolean changedInsideCodeBlock = false; switch (event.getCode()) { case BEFORE_CHILDREN_CHANGE: if (event.getParent() instanceof PsiFile) { changedInsideCodeBlock = true; break; // May be caused by fake PSI event from PomTransaction. A real event will anyway follow. } case CHILDREN_CHANGED : if (event.isGenericChange()) return; changedInsideCodeBlock = isInsideCodeBlock(event.getParent()); break; case BEFORE_CHILD_ADDITION: case BEFORE_CHILD_REMOVAL: case CHILD_ADDED : case CHILD_REMOVED : case BEFORE_CHILD_REPLACEMENT: case CHILD_REPLACED : changedInsideCodeBlock = isInsideCodeBlock(event.getParent()) && isInsideCodeBlock(event.getChild()) && isInsideCodeBlock(event.getOldChild()) && isInsideCodeBlock(event.getNewChild()); break; case BEFORE_CHILD_MOVEMENT: case CHILD_MOVED : changedInsideCodeBlock = isInsideCodeBlock(event.getOldParent()) && isInsideCodeBlock(event.getNewParent()) && isInsideCodeBlock(event.getChild()); break; case BEFORE_PROPERTY_CHANGE: case PROPERTY_CHANGED : changedInsideCodeBlock = false; break; } if (!changedInsideCodeBlock) { processOutOfCodeBlockModification(event); } }