mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[groovy] dfa: test dependent conditions
This commit is contained in:
+11
-3
@@ -15,12 +15,14 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.lang.psi.controlFlow.impl;
|
||||
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.controlFlow.Instruction;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@@ -32,13 +34,19 @@ public class ConditionInstruction extends InstructionImpl implements Instruction
|
||||
|
||||
public ConditionInstruction(@NotNull PsiElement element, @NotNull Collection<ConditionInstruction> dependent) {
|
||||
super(element);
|
||||
myDependent = new HashSet<>(dependent);
|
||||
myDependent = new LinkedHashSet<>(dependent);
|
||||
myDependent.add(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getElementPresentation() {
|
||||
return "Condition " + getElement();
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("Condition ").append(getElement());
|
||||
if (myDependent.size() > 1) {
|
||||
builder.append(", dependent: ");
|
||||
builder.append(StringUtil.join(ContainerUtil.filter(myDependent, d -> d != this), i -> String.valueOf(i.num()), ", "));
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public Set<ConditionInstruction> getDependentConditions() {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
-----
|
||||
0(1) element: null
|
||||
1(2) Condition Logical expression
|
||||
2(3) Condition Unary expression
|
||||
2(3) Condition Unary expression, dependent: 1
|
||||
3(4,5) READ list
|
||||
4(7) Positive goto instruction, condition=2Unary expression
|
||||
5(6) element: Logical expression
|
||||
|
||||
@@ -12,9 +12,9 @@ else b = 3
|
||||
7(8) WRITE b
|
||||
8(22) element: Assignment expression MAYBE_RETURN
|
||||
9(10) element: IF statement
|
||||
10(11) Condition Unary expression
|
||||
10(11) Condition Unary expression, dependent: 3
|
||||
11(12) READ o
|
||||
12(13,15) Condition Instanceof expression
|
||||
12(13,15) Condition Instanceof expression, dependent: 10, 3
|
||||
13(14) instanceof: o instanceof Integer
|
||||
14(17) Negating goto instruction, condition=12Instanceof expression
|
||||
15(16) instanceof: o instanceof Integer
|
||||
|
||||
Reference in New Issue
Block a user