some diagnostics for EA-28785 (wrong instruction passed to dfa)

This commit is contained in:
peter
2011-07-11 19:35:07 +02:00
parent 3028cbc6cd
commit 674effa5e2
@@ -21,17 +21,21 @@ import org.jetbrains.plugins.groovy.lang.psi.controlFlow.Instruction;
import org.jetbrains.plugins.groovy.lang.psi.controlFlow.ReadWriteVariableInstruction;
import org.jetbrains.plugins.groovy.lang.psi.dataFlow.DfaInstance;
import java.util.Arrays;
/**
* @author ven
*/
public class ReachingDefinitionsDfaInstance implements DfaInstance<TIntObjectHashMap<TIntHashSet>> {
private final TObjectIntHashMap<String> myVarToIndexMap = new TObjectIntHashMap<String>();
private final Instruction[] myFlow;
public int getVarIndex(String varName) {
return myVarToIndexMap.get(varName);
}
public ReachingDefinitionsDfaInstance(Instruction[] flow) {
myFlow = flow;
int num = 0;
for (Instruction instruction : flow) {
if (instruction instanceof ReadWriteVariableInstruction) {
@@ -48,7 +52,7 @@ public class ReachingDefinitionsDfaInstance implements DfaInstance<TIntObjectHas
if (instruction instanceof ReadWriteVariableInstruction) {
final ReadWriteVariableInstruction varInsn = (ReadWriteVariableInstruction) instruction;
final String name = varInsn.getVariableName();
assert myVarToIndexMap.containsKey(name);
assert myVarToIndexMap.containsKey(name) : name + "; " + Arrays.asList(myFlow).contains(instruction);
final int num = myVarToIndexMap.get(name);
if (varInsn.isWrite()) {
registerDef(m, varInsn, num);