public void visitClosure(GrClosableBlock closure) { // do not go inside closures except gstring injections if (closure.getParent() instanceof GrStringInjection) { for (GrParameter parameter : closure.getAllParameters()) { if (myPolicy.isVariableInitialized(parameter)) { addNode(new ReadWriteVariableInstruction(parameter.getName(), parameter, WRITE)); } } addNode(new ReadWriteVariableInstruction("owner", closure.getLBrace(), WRITE)); super.visitClosure(closure); return; } ReadWriteVariableInstruction[] reads = ControlFlowBuilderUtil.getReadsWithoutPriorWrites(closure.getControlFlow(), false); for (ReadWriteVariableInstruction read : reads) { PsiElement element = read.getElement(); if (!(element instanceof GrReferenceExpression) || myPolicy.isReferenceAccepted((GrReferenceExpression) element)) { addNodeAndCheckPending( new ReadWriteVariableInstruction(read.getVariableName(), closure, READ)); } } addNodeAndCheckPending(new InstructionImpl(closure)); }
@Override public void visitClosure(GrClosableBlock closure) { if (closure == expr) { super.visitClosure(closure); } else { closure.accept(new ConstantChecker(closure, scope)); } }