[java-dfa] Report DFA exception if myFlow.toString() fails

GitOrigin-RevId: 59409b57cb752d53d48122510925cf59be4b2ea3
This commit is contained in:
Tagir Valeev
2024-03-14 19:34:34 +00:00
committed by intellij-monorepo-bot
parent c2c2b450f1
commit 746cb5401f
@@ -22,7 +22,10 @@ import one.util.streamex.StreamEx;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* Standard interpreter implementation
@@ -362,13 +365,22 @@ public class StandardDataFlowInterpreter implements DataFlowInterpreter {
private void reportDfaProblem(@Nullable DfaInstructionState lastInstructionState, @NotNull Throwable e) {
Attachment[] attachments = {new Attachment("method_body.txt", myPsiAnchor.getText())};
String flowText = myFlow.toString();
if (lastInstructionState != null) {
int index = lastInstructionState.getInstruction().getIndex();
flowText = flowText.replaceAll("(?m)^", " ");
flowText = flowText.replaceFirst("(?m)^ {2}" + index + ": ", "* " + index + ": ");
try {
String flowText = myFlow.toString();
if (lastInstructionState != null) {
int index = lastInstructionState.getInstruction().getIndex();
flowText = flowText.replaceAll("(?m)^", " ");
flowText = flowText.replaceFirst("(?m)^ {2}" + index + ": ", "* " + index + ": ");
}
attachments = ArrayUtil.append(attachments, new Attachment("flow.txt", flowText));
}
catch (ProcessCanceledException pce) {
throw pce;
}
catch (Exception ex) {
ex.addSuppressed(e);
LOG.error("While gathering flow text", ex);
}
attachments = ArrayUtil.append(attachments, new Attachment("flow.txt", flowText));
if (lastInstructionState != null) {
DfaMemoryState memoryState = lastInstructionState.getMemoryState();
String memStateText = null;