mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
getEnclosingCodeBlock moved to DfaPsiUtil (used only there)
GitOrigin-RevId: e6dee392a3ee996bdbcd04ff0d4d944855386e2d
This commit is contained in:
committed by
intellij-monorepo-bot
parent
0d3f06afbc
commit
41eb7e72ce
@@ -48,28 +48,6 @@ public class DfaPsiUtil {
|
||||
return var.hasModifierProperty(PsiModifier.FINAL) && !var.hasModifierProperty(PsiModifier.TRANSIENT) && var instanceof PsiField;
|
||||
}
|
||||
|
||||
static PsiElement getEnclosingCodeBlock(final PsiVariable variable, final PsiElement context) {
|
||||
PsiElement codeBlock;
|
||||
if (variable instanceof PsiParameter) {
|
||||
codeBlock = ((PsiParameter)variable).getDeclarationScope();
|
||||
if (codeBlock instanceof PsiMethod) {
|
||||
codeBlock = ((PsiMethod)codeBlock).getBody();
|
||||
}
|
||||
}
|
||||
else if (variable instanceof PsiLocalVariable) {
|
||||
codeBlock = PsiTreeUtil.getParentOfType(variable, PsiCodeBlock.class);
|
||||
}
|
||||
else {
|
||||
codeBlock = getTopmostBlockInSameClass(context);
|
||||
}
|
||||
while (codeBlock != null) {
|
||||
PsiAnonymousClass anon = PsiTreeUtil.getParentOfType(codeBlock, PsiAnonymousClass.class);
|
||||
if (anon == null) break;
|
||||
codeBlock = PsiTreeUtil.getParentOfType(anon, PsiCodeBlock.class);
|
||||
}
|
||||
return codeBlock;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Nullability getElementNullability(@Nullable PsiType resultType, @Nullable PsiModifierListOwner owner) {
|
||||
return getElementNullability(resultType, owner, false);
|
||||
|
||||
@@ -36,7 +36,7 @@ public class DfaUtil {
|
||||
public static @NotNull Collection<PsiExpression> getVariableValues(@Nullable PsiVariable variable, @Nullable PsiElement context) {
|
||||
if (variable == null || context == null) return Collections.emptyList();
|
||||
|
||||
final PsiCodeBlock codeBlock = tryCast(DfaPsiUtil.getEnclosingCodeBlock(variable, context), PsiCodeBlock.class);
|
||||
final PsiCodeBlock codeBlock = tryCast(getEnclosingCodeBlock(variable, context), PsiCodeBlock.class);
|
||||
if (codeBlock == null) return Collections.emptyList();
|
||||
PsiElement[] defs = DefUseUtil.getDefs(codeBlock, variable, context);
|
||||
|
||||
@@ -58,6 +58,28 @@ public class DfaUtil {
|
||||
return results;
|
||||
}
|
||||
|
||||
private static PsiElement getEnclosingCodeBlock(final PsiVariable variable, final PsiElement context) {
|
||||
PsiElement codeBlock;
|
||||
if (variable instanceof PsiParameter) {
|
||||
codeBlock = ((PsiParameter)variable).getDeclarationScope();
|
||||
if (codeBlock instanceof PsiMethod) {
|
||||
codeBlock = ((PsiMethod)codeBlock).getBody();
|
||||
}
|
||||
}
|
||||
else if (variable instanceof PsiLocalVariable) {
|
||||
codeBlock = PsiTreeUtil.getParentOfType(variable, PsiCodeBlock.class);
|
||||
}
|
||||
else {
|
||||
codeBlock = DfaPsiUtil.getTopmostBlockInSameClass(context);
|
||||
}
|
||||
while (codeBlock != null) {
|
||||
PsiAnonymousClass anon = PsiTreeUtil.getParentOfType(codeBlock, PsiAnonymousClass.class);
|
||||
if (anon == null) break;
|
||||
codeBlock = PsiTreeUtil.getParentOfType(anon, PsiCodeBlock.class);
|
||||
}
|
||||
return codeBlock;
|
||||
}
|
||||
|
||||
private static PsiExpression unrollConcatenation(PsiAssignmentExpression assignment, PsiVariable variable, PsiCodeBlock block) {
|
||||
List<PsiExpression> operands = new ArrayList<>();
|
||||
while (true) {
|
||||
|
||||
Reference in New Issue
Block a user