use of gnu.trove.TIntArrayList in project intellij-community by JetBrains.
the class ArrangementMatchingRulesControl method onMouseClicked.
private void onMouseClicked(@NotNull MouseEvent e) {
final int count = e.getClickCount();
if (count != 2) {
return;
}
final TIntArrayList rows = getSelectedModelRows();
if (rows.size() != 1) {
return;
}
final int row = rows.get(0);
showEditor(row);
scrollRowToVisible(row);
}
use of gnu.trove.TIntArrayList in project intellij-community by JetBrains.
the class EditArrangementRuleAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
ArrangementMatchingRulesControl control = getRulesControl(e);
if (control == null) {
return;
}
TIntArrayList rows = control.getSelectedModelRows();
if (rows.size() != 1) {
return;
}
final int row = rows.get(0);
control.showEditor(row);
scrollRowToVisible(control, row);
}
use of gnu.trove.TIntArrayList in project intellij-community by JetBrains.
the class LoopAnalyzer method calcInLoop.
static int[] calcInLoop(ControlFlow controlFlow) {
// loop[i] = loop number(strongly connected component number) of i-th instruction or 0 if outside loop
final int[] loop = new int[controlFlow.getInstructionCount()];
MyGraph graph = new MyGraph(controlFlow);
final DFSTBuilder<Instruction> builder = new DFSTBuilder<>(graph);
TIntArrayList sccs = builder.getSCCs();
sccs.forEach(new TIntProcedure() {
private int myTNumber;
private int component;
@Override
public boolean execute(int size) {
int value = size > 1 ? ++component : 0;
for (int i = 0; i < size; i++) {
Instruction instruction = builder.getNodeByTNumber(myTNumber + i);
loop[instruction.getIndex()] = value;
}
myTNumber += size;
return true;
}
});
return loop;
}
use of gnu.trove.TIntArrayList in project intellij-community by JetBrains.
the class OriginsAnalysis method resultOrigins.
/**
*
* @param frames fixpoint of frames
* @param instructions method instructions
* @param graph method control flow graph
* @return array, array[i] == true means that the result of a method execution may originate at an i-th instruction
* @throws AnalyzerException
*/
@NotNull
public static boolean[] resultOrigins(Frame<Value>[] frames, InsnList instructions, ControlFlowGraph graph) throws AnalyzerException {
TIntArrayList[] backTransitions = new TIntArrayList[instructions.size()];
for (int i = 0; i < backTransitions.length; i++) {
backTransitions[i] = new TIntArrayList();
}
LinkedList<InsnLocation> queue = new LinkedList<>();
HashSet<InsnLocation> queued = new HashSet<>();
for (int from = 0; from < instructions.size(); from++) {
for (int to : graph.transitions[from]) {
TIntArrayList froms = backTransitions[to];
froms.add(from);
int opcode = instructions.get(to).getOpcode();
if (opcode >= Opcodes.IRETURN && opcode <= Opcodes.ARETURN) {
InsnLocation sourceLoc = new InsnLocation(false, from, frames[to].getStackSize() - 1);
if (queued.add(sourceLoc)) {
queue.push(sourceLoc);
}
}
}
}
boolean[] result = new boolean[instructions.size()];
while (!queue.isEmpty()) {
InsnLocation resultLocation = queue.pop();
int insnIndex = resultLocation.insnIndex;
AbstractInsnNode insn = instructions.get(insnIndex);
int opcode = insn.getOpcode();
Location preLocation = previousLocation(frames[insnIndex], resultLocation, insn);
if (preLocation == null) {
if (opcode != Opcodes.INVOKEINTERFACE && opcode != Opcodes.GETFIELD && !(opcode >= Opcodes.IALOAD && opcode <= Opcodes.SALOAD)) {
result[insnIndex] = true;
}
} else {
TIntArrayList froms = backTransitions[insnIndex];
for (int i = 0; i < froms.size(); i++) {
InsnLocation preILoc = new InsnLocation(preLocation.local, froms.getQuick(i), preLocation.slot);
if (queued.add(preILoc)) {
queue.push(preILoc);
}
}
}
}
return result;
}
use of gnu.trove.TIntArrayList in project intellij-community by JetBrains.
the class SliceTreeTest method testTypingDoesNotInterfereWithDuplicates.
public void testTypingDoesNotInterfereWithDuplicates() throws Exception {
SliceTreeStructure treeStructure = configureTree("DupSlice");
SliceNode root = (SliceNode) treeStructure.getRootElement();
List<SliceNode> nodes = new ArrayList<>();
expandNodesTo(root, nodes);
TIntArrayList hasDups = new TIntArrayList();
for (SliceNode node : nodes) {
if (node.getDuplicate() != null) {
PsiElement element = node.getValue().getElement();
hasDups.add(element.getTextRange().getStartOffset());
assertTrue(element instanceof PsiParameter && "i".equals(((PsiParameter) element).getName()) || element instanceof PsiLiteralExpression);
}
}
type(" xx");
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
backspace();
backspace();
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
backspace();
backspace();
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
backspace();
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
nodes.clear();
expandNodesTo(root, nodes);
for (SliceNode node : nodes) {
if (node.getDuplicate() != null) {
PsiElement element = node.getValue().getElement();
int offset = element.getTextRange().getStartOffset();
int i = hasDups.indexOf(offset);
assertTrue(i != -1);
hasDups.remove(i);
assertTrue(element instanceof PsiParameter && "i".equals(((PsiParameter) element).getName()) || element instanceof PsiLiteralExpression);
}
}
assertTrue(hasDups.isEmpty());
}
Aggregations