Search in sources :

Example 26 with Instruction

use of org.jetbrains.plugins.groovy.lang.psi.controlFlow.Instruction in project intellij-community by JetBrains.

the class ThrowingInstruction method toString.

@Override
public String toString() {
    final StringBuilder builder = new StringBuilder();
    builder.append(num());
    builder.append("(");
    for (Instruction successor : allSuccessors()) {
        builder.append(successor.num());
        builder.append(',');
    }
    if (allPredecessors().iterator().hasNext())
        builder.delete(builder.length() - 1, builder.length());
    builder.append(") ").append("THROW. ").append(getElementPresentation());
    return builder.toString();
}
Also used : Instruction(org.jetbrains.plugins.groovy.lang.psi.controlFlow.Instruction)

Example 27 with Instruction

use of org.jetbrains.plugins.groovy.lang.psi.controlFlow.Instruction in project intellij-community by JetBrains.

the class ReachingDefinitionsCollector method getReachable.

private static LinkedHashSet<Integer> getReachable(final LinkedHashSet<Integer> fragmentInsns, final Instruction[] flow, final DefinitionMap dfaResult, final int[] postorder) {
    final LinkedHashSet<Integer> result = new LinkedHashSet<>();
    for (final Instruction insn : flow) {
        if (isReadInsn(insn)) {
            final int ref = insn.num();
            int[] definitions = dfaResult.getDefinitions(ref);
            if (definitions != null) {
                for (final int def : definitions) {
                    if (fragmentInsns.contains(def) && (!fragmentInsns.contains(ref) || postorder[ref] < postorder[def] && checkPathIsOutsideOfFragment(def, ref, flow, fragmentInsns))) {
                        result.add(ref);
                        break;
                    }
                }
            }
        }
    }
    return result;
}
Also used : Instruction(org.jetbrains.plugins.groovy.lang.psi.controlFlow.Instruction) ReadWriteVariableInstruction(org.jetbrains.plugins.groovy.lang.psi.controlFlow.ReadWriteVariableInstruction)

Aggregations

Instruction (org.jetbrains.plugins.groovy.lang.psi.controlFlow.Instruction)27 ReadWriteVariableInstruction (org.jetbrains.plugins.groovy.lang.psi.controlFlow.ReadWriteVariableInstruction)18 PsiElement (com.intellij.psi.PsiElement)10 Nullable (org.jetbrains.annotations.Nullable)8 GrControlFlowOwner (org.jetbrains.plugins.groovy.lang.psi.GrControlFlowOwner)7 GrExpression (org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression)7 IfEndInstruction (org.jetbrains.plugins.groovy.lang.psi.controlFlow.impl.IfEndInstruction)7 NotNull (org.jetbrains.annotations.NotNull)6 GroovyPsiElement (org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement)6 GrMethod (org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod)6 GrVariable (org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable)5 GrOpenBlock (org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrOpenBlock)5 AfterCallInstruction (org.jetbrains.plugins.groovy.lang.psi.controlFlow.AfterCallInstruction)5 MaybeReturnInstruction (org.jetbrains.plugins.groovy.lang.psi.controlFlow.impl.MaybeReturnInstruction)5 GrClosableBlock (org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock)4 GrReferenceExpression (org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression)4 ThrowingInstruction (org.jetbrains.plugins.groovy.lang.psi.controlFlow.impl.ThrowingInstruction)4 BitSet (java.util.BitSet)3 ControlFlowUtils (org.jetbrains.plugins.groovy.codeInspection.utils.ControlFlowUtils)3 GrStatement (org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement)3