[java] deprecate and scheduler for removal PsiModifiableCodeBlock

interface is not used externally, and after removing PsiModificationTracker#getOutOfCodeBlockModificationCount() it makes no sense anymore.

^IDEA-340901 fixed

GitOrigin-RevId: e121babc02bf14f820dd8b3f974111e8240d692b
This commit is contained in:
Anna Kozlova
2023-12-14 21:16:04 +00:00
committed by intellij-monorepo-bot
parent 5ffec85cf9
commit 6aebaca523
6 changed files with 17 additions and 28 deletions
@@ -21,7 +21,7 @@ import org.jetbrains.annotations.Nullable;
/**
* Represents a Java code block, usually surrounded by curly braces.
*/
public interface PsiCodeBlock extends PsiElement, PsiModifiableCodeBlock {
public interface PsiCodeBlock extends PsiElement {
/**
* The empty array of PSI code blocks which can be reused to avoid unnecessary allocations.
*/
@@ -81,4 +81,11 @@ public interface PsiCodeBlock extends PsiElement, PsiModifiableCodeBlock {
default boolean isEmpty() {
return getStatementCount() == 0;
}
@SuppressWarnings("unused") //keep for binary compatibility.
default boolean shouldChangeModificationCount(PsiElement place) {
PsiElement parent = getParent();
return !(parent instanceof PsiMethod || parent instanceof PsiClassInitializer);
}
}
@@ -15,9 +15,15 @@
*/
package com.intellij.psi;
import com.intellij.psi.util.PsiModificationTracker;
import org.jetbrains.annotations.ApiStatus;
/**
* Represents psi element, which can be modified without caches reset.
* @deprecated because {@link PsiModificationTracker}.getOutOfCodeBlockModificationCount() was removed, there is no more code that calls the method
*/
@ApiStatus.ScheduledForRemoval
@Deprecated
public interface PsiModifiableCodeBlock {
/**
* @param place where change was detected
@@ -276,10 +276,4 @@ public final class PsiCodeBlockImpl extends LazyParseablePsiElement implements P
}
return true;
}
@Override
public boolean shouldChangeModificationCount(PsiElement place) {
PsiElement parent = getParent();
return !(parent instanceof PsiMethod || parent instanceof PsiClassInitializer);
}
}
@@ -12,7 +12,6 @@ import com.intellij.psi.stubs.StubElement;
import com.intellij.psi.util.CachedValueProvider;
import com.intellij.psi.util.CachedValuesManager;
import com.intellij.psi.util.PsiModificationTracker;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.ArrayUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
@@ -45,7 +44,7 @@ import static org.jetbrains.plugins.groovy.lang.resolve.bindings.BindingsKt.proc
/**
* Implements all abstractions related to Groovy file
*/
public class GroovyFileImpl extends GroovyFileBaseImpl implements GroovyFile, PsiModifiableCodeBlock {
public class GroovyFileImpl extends GroovyFileBaseImpl implements GroovyFile {
private static final Logger LOG = Logger.getInstance(GroovyFileImpl.class);
@@ -351,16 +350,6 @@ public class GroovyFileImpl extends GroovyFileBaseImpl implements GroovyFile, Ps
return PsiImplUtilKt.getScriptDeclarations(this, topLevelOnly);
}
@Override
public boolean shouldChangeModificationCount(PsiElement place) {
if (!isContentsLoaded()) return true;
// 1. We actually should never get GrTypeDefinition as a parent, because it is a PsiClass,
// and PsiClasses prevent to go up in a tree any further
// 2. If place is under a variable then @BaseScript or @Field may be changed,
// which actually is a change in Java Structure
return !isScript() || PsiTreeUtil.getParentOfType(place, GrTypeDefinition.class, GrVariableDeclaration.class) != null;
}
@NotNull
@Override
public GroovyFileImports getImports() {
@@ -3,7 +3,6 @@
package org.jetbrains.plugins.groovy.lang.psi.impl.statements.blocks;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiModifiableCodeBlock;
import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor;
@@ -11,7 +10,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrClassInitializer;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrOpenBlock;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
public class GrOpenBlockImpl extends GrBlockImpl implements GrOpenBlock, PsiModifiableCodeBlock {
public class GrOpenBlockImpl extends GrBlockImpl implements GrOpenBlock {
public GrOpenBlockImpl(@NotNull IElementType type, CharSequence buffer) {
super(type, buffer);
@@ -32,10 +31,4 @@ public class GrOpenBlockImpl extends GrBlockImpl implements GrOpenBlock, PsiModi
final PsiElement parent = getParent();
return parent instanceof GrMethod || parent instanceof GrClassInitializer;
}
@Override
public boolean shouldChangeModificationCount(PsiElement place) {
final PsiElement parent = getParent();
return !(parent instanceof GrMethod) && !(parent instanceof GrClassInitializer);
}
}
@@ -73,7 +73,7 @@ public class JavaStreamChainBuilder implements StreamChainBuilder {
while (current != null) {
final PsiElement parent = current.getParent();
if (parent instanceof PsiModifiableCodeBlock || parent instanceof PsiLambdaExpression || parent instanceof PsiStatement) {
if (parent instanceof PsiCodeBlock || parent instanceof PsiLambdaExpression || parent instanceof PsiStatement) {
break;
}