Unnamed: 0 int64 0 305k | body stringlengths 7 52.9k | name stringlengths 1 185 |
|---|---|---|
33,800 | Iterable<Instruction> (@NotNull CallEnvironment environment) { final Deque<CallInstruction> callStack = environment.callStack(this); if (callStack.isEmpty()) return Collections.emptyList(); //can be true in case env was not populated (e.g. by DFA) final CallInstruction callInstruction = callStack.peek(); final Iterable<Instruction> successors = callInstruction.allSuccessors(); final Deque<CallInstruction> copy = new ArrayDeque<>(callStack); copy.pop(); for (Instruction instruction : successors) { environment.update(copy, instruction); } return successors; } | successors |
33,801 | void (@NotNull GrOpenBlock block) { final PsiElement parent = block.getParent(); final PsiElement lbrace = block.getLBrace(); if (lbrace != null && parent instanceof GrMethod) { for (GrParameter parameter : ((GrMethod)parent).getParameters()) { if (myPolicy.isVariableInitialized(parameter)) { addNode(new ReadWriteVariableInstruction(getDescriptorId(createDescriptor(parameter)), parameter, ReadWriteVariableInstruction.WRITE)); } } } super.visitOpenBlock(block); if (!(block.getParent() instanceof GrBlockStatement && block.getParent().getParent() instanceof GrLoopStatement)) { final GrStatement[] statements = block.getStatements(); if (statements.length > 0) { handlePossibleYield(statements[statements.length - 1]); handlePossibleReturn(statements[statements.length - 1]); } } } | visitOpenBlock |
33,802 | void (@NotNull GrExpressionLambdaBody body) { addFunctionalExpressionParameters(body.getLambdaExpression()); body.getExpression().accept(this); } | visitExpressionLambdaBody |
33,803 | void (@NotNull GrBlockLambdaBody body) { addFunctionalExpressionParameters(body.getLambdaExpression()); addControlFlowInstructions(body); } | visitBlockLambdaBody |
33,804 | void (@NotNull GroovyFileBase file) { super.visitFile(file); final GrStatement[] statements = file.getStatements(); if (statements.length > 0) { handlePossibleReturn(statements[statements.length - 1]); } } | visitFile |
33,805 | InstructionImpl (@NotNull GrStatement possibleReturn) { if (possibleReturn instanceof GrExpression && ControlFlowBuilderUtil.isCertainlyReturnStatement(possibleReturn)) { return addNodeAndCheckPending(new MaybeReturnInstruction((GrExpression)possibleReturn)); } return null; } | handlePossibleReturn |
33,806 | GroovyControlFlow (@NotNull GroovyPsiElement scope) { return buildControlFlow(scope, GrResolverPolicy.getInstance()); } | buildControlFlow |
33,807 | GroovyControlFlow (@NotNull GroovyPsiElement scope) { return new ControlFlowBuilder(GrResolverPolicy.getInstance(), true).doBuildFlatControlFlow(scope); } | buildFlatControlFlow |
33,808 | GroovyControlFlow (@NotNull GroovyPsiElement scope, @NotNull GrControlFlowPolicy policy) { return new ControlFlowBuilder(policy, false).doBuildControlFlow(scope); } | buildControlFlow |
33,809 | GroovyControlFlow (GroovyPsiElement scope) { var topOwner = ControlFlowUtils.getTopmostOwner(scope); if (topOwner == null) { return new GroovyControlFlow(Instruction.EMPTY_ARRAY, getDescriptorMapping()); } myFinallyCount = 0; myInstructionNumber = 0; myScope = scope; startNode(null); topOwner.accept(this); InstructionImpl end = startNode(null); checkPending(end); return new GroovyControlFlow(myInstructions.toArray(Instruction.EMPTY_ARRAY), getDescriptorMapping()); } | doBuildFlatControlFlow |
33,810 | int (VariableDescriptor actualDescriptor) { myVariableMapping.putIfAbsent(actualDescriptor, myVariableMapping.size() + 1); return myVariableMapping.get(actualDescriptor); } | getDescriptorId |
33,811 | VariableDescriptor[] () { VariableDescriptor[] array = new VariableDescriptor[myVariableMapping.size() + 1]; for (var entry : myVariableMapping.entrySet()) { array[entry.getValue()] = entry.getKey(); } return array; } | getDescriptorMapping |
33,812 | GroovyControlFlow (GroovyPsiElement scope) { if (scope instanceof GrLambdaExpression) { GrLambdaBody body = ((GrLambdaExpression)scope).getBody(); Instruction[] flow = body != null ? body.getControlFlow() : Instruction.EMPTY_ARRAY; return new GroovyControlFlow(flow, getDescriptorMapping()); } myFinallyCount = 0; myInstructionNumber = 0; myScope = scope; startNode(null); if (scope instanceof GrClosableBlock) { addFunctionalExpressionParameters((GrFunctionalExpression)scope); addControlFlowInstructions((GrStatementOwner)scope); } else { scope.accept(this); } final InstructionImpl end = startNode(null); checkPending(end); //collect return edges return new GroovyControlFlow(myInstructions.toArray(Instruction.EMPTY_ARRAY), getDescriptorMapping()); } | doBuildControlFlow |
33,813 | void (final GrStatementOwner owner) { PsiElement child = owner.getFirstChild(); while (child != null) { if (child instanceof GroovyPsiElement) { ((GroovyPsiElement)child).accept(this); } child = child.getNextSibling(); } final GrStatement[] statements = owner.getStatements(); if (statements.length > 0) { handlePossibleReturn(statements[statements.length - 1]); } } | addControlFlowInstructions |
33,814 | void (GrFunctionalExpression expression) { for (GrParameter parameter : expression.getAllParameters()) { if (myPolicy.isVariableInitialized(parameter)) { addNode(new ReadWriteVariableInstruction(getDescriptorId(createDescriptor(parameter)), parameter, ReadWriteVariableInstruction.WRITE)); } } } | addFunctionalExpressionParameters |
33,815 | void (InstructionImpl begin, InstructionImpl end) { begin.addSuccessor(end); end.addPredecessor(begin); if (!(begin instanceof MixinTypeInstruction)) { end.addNegationsFrom(begin); } } | addEdge |
33,816 | void (@NotNull GrLambdaExpression expression) { GrLambdaBody body = expression.getBody(); if (body == null) return; if (isFlatFlow) { FunctionalBlockBeginInstruction startClosure = new FunctionalBlockBeginInstruction(expression); myFunctionalScopeStack.addLast(expression); addNode(startClosure); addPendingEdge(expression, startClosure); addFunctionalExpressionParameters(expression); if (body instanceof GrBlockLambdaBody) { addControlFlowInstructions((GrStatementOwner)body); } else { super.visitLambdaBody(body); } InstructionImpl endClosure = new FunctionalBlockEndInstruction(startClosure); addNode(endClosure); checkPending(expression.getParent(), endClosure); myFunctionalScopeStack.removeLast(); } else { List<kotlin.Pair<ReadWriteVariableInstruction, VariableDescriptor>> reads = ControlFlowBuilderUtil.getReadsWithoutPriorWrites(ControlFlowUtils.getGroovyControlFlow(body), false); addReadFromNestedControlFlow(expression, reads); } } | visitLambdaExpression |
33,817 | void (@NotNull GrClosableBlock closure) { if (isFlatFlow) { FunctionalBlockBeginInstruction startClosure = new FunctionalBlockBeginInstruction(closure); myFunctionalScopeStack.addLast(closure); addNodeAndCheckPending(startClosure); addPendingEdge(closure, startClosure); addFunctionalExpressionParameters(closure); addControlFlowInstructions(closure); InstructionImpl endClosure = new FunctionalBlockEndInstruction(startClosure); addNode(endClosure); checkPending(closure.getParent(), endClosure); myFunctionalScopeStack.removeLast(); } else { //do not go inside closures except gstring injections if (closure.getParent() instanceof GrStringInjection) { addFunctionalExpressionParameters(closure); super.visitClosure(closure); return; } List<kotlin.Pair<ReadWriteVariableInstruction, VariableDescriptor>> reads = ControlFlowBuilderUtil.getReadsWithoutPriorWrites(ControlFlowUtils.getGroovyControlFlow(closure), false); addReadFromNestedControlFlow(closure, reads); } } | visitClosure |
33,818 | void (@NotNull PsiElement anchor, List<kotlin.Pair<ReadWriteVariableInstruction, VariableDescriptor>> reads) { for (kotlin.Pair<ReadWriteVariableInstruction, VariableDescriptor> read : reads) { PsiElement element = read.getFirst().getElement(); if (!(element instanceof GrReferenceExpression) || myPolicy.isReferenceAccepted((GrReferenceExpression)element)) { addNodeAndCheckPending(new ReadWriteVariableInstruction(getDescriptorId(read.getSecond()), anchor, ReadWriteVariableInstruction.READ)); } } addNodeAndCheckPending(new InstructionImpl(anchor)); } | addReadFromNestedControlFlow |
33,819 | void (@NotNull GrBreakStatement breakStatement) { super.visitBreakStatement(breakStatement); GrStatement target = breakStatement.resolveLabel(); if (target == null) target = breakStatement.findTargetStatement(); if (target != null) { if (myHead != null) { addPendingEdge(target, myHead); } readdPendingEdge(target); } interruptFlow(); } | visitBreakStatement |
33,820 | void (@NotNull GrContinueStatement continueStatement) { super.visitContinueStatement(continueStatement); GrStatement target = continueStatement.resolveLabel(); if (target == null) target = continueStatement.findTargetStatement(); if (target != null) { final InstructionImpl instruction = findInstruction(target); if (instruction != null) { if (myHead != null) { addEdge(myHead, instruction); } checkPending(continueStatement, instruction); } interruptFlow(); } } | visitContinueStatement |
33,821 | void (@NotNull GrReturnStatement returnStatement) { boolean isNodeNeeded = myHead == null || myHead.getElement() != returnStatement; final GrExpression value = returnStatement.getReturnValue(); if (value != null) value.accept(this); GroovyPsiElement scopeElement = myFunctionalScopeStack.isEmpty() ? null : returnStatement; if (isNodeNeeded) { InstructionImpl returnInstruction = startNode(returnStatement); addPendingEdge(scopeElement, myHead); finishNode(returnInstruction); } else { addPendingEdge(scopeElement, myHead); } interruptFlow(); } | visitReturnStatement |
33,822 | void (@NotNull GrAssertStatement assertStatement) { final InstructionImpl assertInstruction = startNode(assertStatement); final GrExpression assertion = assertStatement.getAssertion(); if (assertion != null) { assertion.accept(this); InstructionImpl positiveHead = myHead; List<GotoInstruction> negations = collectAndRemoveAllPendingNegations(assertStatement); if (!negations.isEmpty()) { interruptFlow(); reduceAllNegationsIntoInstruction(assertStatement, negations); } GrExpression errorMessage = assertStatement.getErrorMessage(); if (errorMessage != null) { errorMessage.accept(this); } addNode(new ThrowingInstruction(assertStatement)); final PsiType type = TypesUtil.createTypeByFQClassName(CommonClassNames.JAVA_LANG_ASSERTION_ERROR, assertStatement); ExceptionInfo info = findCatch(type); if (info != null) { info.myThrowers.add(myHead); } else { addPendingEdge(null, myHead); } myHead = positiveHead; } finishNode(assertInstruction); } | visitAssertStatement |
33,823 | void (@NotNull GrThrowStatement throwStatement) { final GrExpression exception = throwStatement.getException(); if (exception == null) return; exception.accept(this); final InstructionImpl throwInstruction = new ThrowingInstruction(throwStatement); addNodeAndCheckPending(throwInstruction); interruptFlow(); final PsiType type = getNominalTypeNoRecursion(exception); // it is impossible to follow the consequences of throwing in closure, so throw will just interrupt the closure it was invoked within final GroovyPsiElement scopeElement = myFunctionalScopeStack.isEmpty() ? null : throwStatement; if (type != null) { ExceptionInfo info = findCatch(type); if (info != null) { info.myThrowers.add(throwInstruction); } else { addPendingEdge(scopeElement, throwInstruction); } } else { addPendingEdge(scopeElement, throwInstruction); } } | visitThrowStatement |
33,824 | PsiType (@NotNull final GrExpression expression) { if (expression instanceof GrNewExpression) { return expression.getType(); } else if (expression instanceof GrReferenceExpression && ((GrReferenceExpression)expression).getQualifier() == null) { return getTypeByRef((GrReferenceExpression)expression); } return null; } | getNominalTypeNoRecursion |
33,825 | PsiType (@NotNull GrReferenceExpression invoked) { PsiElement resolved = invoked.getStaticReference().resolve(); return resolved instanceof PsiVariable ? ((PsiVariable)resolved).getType() : null; } | getTypeByRef |
33,826 | void () { myHead = null; } | interruptFlow |
33,827 | ExceptionInfo (PsiType thrownType) { final Iterator<ExceptionInfo> iterator = myCaughtExceptionInfos.descendingIterator(); while (iterator.hasNext()) { final ExceptionInfo info = iterator.next(); final GrCatchClause clause = info.myClause; final GrParameter parameter = clause.getParameter(); if (parameter != null) { final PsiType type = parameter.getType(); if (type.isAssignableFrom(thrownType)) return info; } } return null; } | findCatch |
33,828 | void (@NotNull GrLabeledStatement labeledStatement) { final InstructionImpl instruction = startNode(labeledStatement); super.visitLabeledStatement(labeledStatement); finishNode(instruction); } | visitLabeledStatement |
33,829 | void (@NotNull GrAssignmentExpression expression) { GrExpression lValue = expression.getLValue(); if (expression.isOperatorAssignment() || expression.getOperationTokenType() == T_ELVIS_ASSIGN) { if (lValue instanceof GrReferenceExpression && myPolicy.isReferenceAccepted((GrReferenceExpression)lValue)) { VariableDescriptor descriptor = createDescriptor((GrReferenceExpression)lValue); if (descriptor != null) { addNodeAndCheckPending(new ReadWriteVariableInstruction(getDescriptorId(descriptor), lValue, ReadWriteVariableInstruction.READ)); } } } GrExpression rValue = expression.getRValue(); if (rValue != null) { rValue.accept(this); } lValue.accept(this); } | visitAssignmentExpression |
33,830 | void (@NotNull GrTupleAssignmentExpression expression) { GrExpression rValue = expression.getRValue(); if (rValue != null) { rValue.accept(this); } expression.getLValue().accept(this); } | visitTupleAssignmentExpression |
33,831 | void (@NotNull GrParenthesizedExpression expression) { final GrExpression operand = expression.getOperand(); if (operand != null) operand.accept(this); } | visitParenthesizedExpression |
33,832 | void (@NotNull GrUnaryExpression expression) { final GrExpression operand = expression.getOperand(); if (operand == null) return; if (expression.getOperationTokenType() != GroovyTokenTypes.mLNOT) { operand.accept(this); visitCall(expression); return; } FList<ConditionInstruction> conditionsBefore = myConditions; ConditionInstruction cond = registerCondition(expression, false); addNodeAndCheckPending(cond); operand.accept(this); visitCall(expression); myConditions = conditionsBefore; List<GotoInstruction> negations = collectAndRemoveAllPendingNegations(expression); InstructionImpl head = myHead; addNodeAndCheckPending(new PositiveGotoInstruction(expression, cond)); handlePossibleReturn(expression); addPendingEdge(expression, myHead); if (negations.isEmpty()) { myHead = head; } else { myHead = reduceAllNegationsIntoInstruction(expression, negations); } } | visitUnaryExpression |
33,833 | InstructionImpl (GroovyPsiElement currentScope, List<? extends GotoInstruction> negations) { if (negations.size() > 1) { InstructionImpl instruction = addNode(new InstructionImpl(currentScope)); for (GotoInstruction negation : negations) { addEdge(negation, instruction); } return instruction; } else if (negations.size() == 1) { GotoInstruction instruction = negations.get(0); myHead = instruction; return instruction; } return null; } | reduceAllNegationsIntoInstruction |
33,834 | List<GotoInstruction> (GroovyPsiElement currentScope) { List<GotoInstruction> negations = new ArrayList<>(); for (Iterator<Pair<InstructionImpl, GroovyPsiElement>> iterator = myPending.iterator(); iterator.hasNext(); ) { Pair<InstructionImpl, GroovyPsiElement> pair = iterator.next(); InstructionImpl instruction = pair.first; GroovyPsiElement scope = pair.second; if (!PsiTreeUtil.isAncestor(scope, currentScope, true) && instruction instanceof GotoInstruction) { negations.add((GotoInstruction)instruction); iterator.remove(); } } return negations; } | collectAndRemoveAllPendingNegations |
33,835 | void (@NotNull GrInstanceOfExpression expression) { expression.getOperand().accept(this); processInstanceOf(expression, GrInstanceOfExpression.isNegated(expression)); } | visitInstanceofExpression |
33,836 | void (@NotNull GrReferenceExpression refExpr) { super.visitReferenceExpression(refExpr); if (myPolicy.isReferenceAccepted(refExpr)) { VariableDescriptor descriptor = createDescriptor(refExpr); if (descriptor == null) return; if (ControlFlowUtils.isIncOrDecOperand(refExpr)) { final InstructionImpl i = new ReadWriteVariableInstruction(getDescriptorId(descriptor), refExpr, ReadWriteVariableInstruction.READ); addNodeAndCheckPending(i); addNode(new ReadWriteVariableInstruction(getDescriptorId(descriptor), refExpr, ReadWriteVariableInstruction.WRITE)); } else { final int type = PsiUtil.isLValue(refExpr) ? ReadWriteVariableInstruction.WRITE : ReadWriteVariableInstruction.READ; addNodeAndCheckPending(new ReadWriteVariableInstruction(getDescriptorId(descriptor), refExpr, type)); } } if (refExpr.isQualified() && !(refExpr.getParent() instanceof GrCall)) { visitCall(refExpr); } } | visitReferenceExpression |
33,837 | void (@NotNull GrMethodCall call) { super.visitMethodCall(call); addNodeAndCheckPending(new ArgumentsInstruction(call, myVariableMapping)); visitCall(call); } | visitMethodCall |
33,838 | void (@NotNull GrConstructorInvocation invocation) { super.visitConstructorInvocation(invocation); addNodeAndCheckPending(new ArgumentsInstruction(invocation, myVariableMapping)); visitCall(invocation); } | visitConstructorInvocation |
33,839 | void (@NotNull GrNewExpression newExpression) { super.visitNewExpression(newExpression); addNodeAndCheckPending(new ArgumentsInstruction(newExpression, myVariableMapping)); visitCall(newExpression); } | visitNewExpression |
33,840 | void (@NotNull GrBinaryExpression expression) { final GrExpression left = expression.getLeftOperand(); final GrExpression right = expression.getRightOperand(); final IElementType opType = expression.getOperationTokenType(); if (ControlFlowBuilderUtil.isInstanceOfBinary(expression)) { expression.getLeftOperand().accept(this); processInstanceOf(expression, GrInExpression.isNegated((GrInExpression)expression)); return; } if (opType == T_EQ || opType == T_NEQ) { if (isNullLiteral(right)) { left.accept(this); processInstanceOf(expression, opType == T_NEQ); return; } else if (right != null && isNullLiteral(left)) { right.accept(this); processInstanceOf(expression, opType == T_NEQ); return; } } if (opType != GroovyTokenTypes.mLOR && opType != GroovyTokenTypes.mLAND && opType != KW_IN && opType != T_NOT_IN) { left.accept(this); if (right != null) { right.accept(this); } visitCall(expression); return; } FList<ConditionInstruction> conditionsBefore = myConditions; ConditionInstruction condition = registerCondition(expression, false); addNodeAndCheckPending(condition); left.accept(this); if (right == null) return; final List<GotoInstruction> negations = collectAndRemoveAllPendingNegations(expression); visitCall(expression); if (opType == GroovyTokenTypes.mLAND) { InstructionImpl head = myHead; if (negations.isEmpty()) { addNode(new NegatingGotoInstruction(expression, condition)); handlePossibleReturn(expression); addPendingEdge(expression, myHead); } else { for (GotoInstruction negation : negations) { myHead = negation; handlePossibleReturn(expression); addPendingEdge(expression, myHead); } } myHead = head; } else /*if (opType == mLOR)*/ { final InstructionImpl instruction = addNodeAndCheckPending(new InstructionImpl(expression));//collect all pending edges from left argument handlePossibleReturn(expression); addPendingEdge(expression, myHead); myHead = instruction; InstructionImpl head = reduceAllNegationsIntoInstruction(expression, negations); if (head != null) myHead = head; //addNode(new NegatingGotoInstruction(expression, myInstructionNumber++, condition)); } myConditions = conditionsBefore; right.accept(this); } | visitBinaryExpression |
33,841 | void (GrExpression expression, boolean negated) { FList<ConditionInstruction> conditionsBefore = myConditions; ConditionInstruction cond = registerCondition(expression, negated); addNodeAndCheckPending(cond); addNode(new InstanceOfInstruction(expression, cond, myVariableMapping)); NegatingGotoInstruction negation = new NegatingGotoInstruction(expression, cond); addNode(negation); InstructionImpl possibleReturn = handlePossibleReturn(expression); addPendingEdge(expression, possibleReturn != null ? possibleReturn : negation); myHead = cond; addNode(new InstanceOfInstruction(expression, cond, myVariableMapping)); myConditions = conditionsBefore; } | processInstanceOf |
33,842 | void (GroovyPsiElement call) { //optimization: don't add call instruction if there is no catch or finally block in the context if (myCaughtExceptionInfos.size() <= 0 && myFinallyCount <= 0) { return; } final InstructionImpl instruction = new ThrowingInstruction(call); addNodeAndCheckPending(instruction); for (ExceptionInfo info : myCaughtExceptionInfos) { info.myThrowers.add(instruction); } if (myFinallyCount > 0) { addPendingEdge(null, instruction); } } | visitCall |
33,843 | void (@NotNull GrIfStatement ifStatement) { InstructionImpl ifInstruction = startNode(ifStatement); FList<ConditionInstruction> conditionsBefore = myConditions; final GrCondition condition = ifStatement.getCondition(); final GrStatement thenBranch = ifStatement.getThenBranch(); final GrStatement elseBranch = ifStatement.getElseBranch(); InstructionImpl conditionEnd = null; InstructionImpl thenEnd = null; InstructionImpl elseEnd = null; if (condition != null) { condition.accept(this); conditionEnd = myHead; } List<GotoInstruction> negations = collectAndRemoveAllPendingNegations(ifStatement); if (thenBranch != null) { thenBranch.accept(this); handlePossibleReturn(thenBranch); thenEnd = myHead; interruptFlow(); readdPendingEdge(ifStatement); } myHead = reduceAllNegationsIntoInstruction(ifStatement, negations); if (myHead == null && conditionEnd != null) { myHead = conditionEnd; } if (elseBranch != null) { elseBranch.accept(this); handlePossibleReturn(elseBranch); elseEnd = myHead; interruptFlow(); } if (thenBranch != null || elseBranch != null) { if (thenEnd != null || elseEnd != null || elseBranch == null) { final InstructionImpl end = new IfEndInstruction(ifStatement); addNode(end); if (thenEnd != null) { addEdge(thenEnd, end); } if (elseEnd != null) { addEdge(elseEnd, end); } else if (elseBranch == null) { // addEdge(conditionEnd != null ? conditionEnd : ifInstruction, end); } } } myConditions = conditionsBefore; finishNode(ifInstruction); } | visitIfStatement |
33,844 | ConditionInstruction (@NotNull PsiElement element, boolean negated) { ConditionInstruction condition = new ConditionInstruction(element, negated, myConditions); myConditions = myConditions.prepend(condition); return condition; } | registerCondition |
33,845 | void (@Nullable GroovyPsiElement element) { if (element != null) { element.accept(this); } } | acceptNullable |
33,846 | void (@NotNull GrForStatement forStatement) { final GrForClause clause = forStatement.getClause(); processForLoopInitializer(clause); InstructionImpl start = startNode(forStatement); addForLoopBreakingEdge(forStatement, clause); flushForeachLoopVariable(clause); final GrStatement body = forStatement.getBody(); if (body != null) { InstructionImpl bodyInstruction = startNode(body); body.accept(this); finishNode(bodyInstruction); } checkPending(start); //check for breaks targeted here if (clause instanceof GrTraditionalForClause) { acceptNullable(((GrTraditionalForClause)clause).getUpdate()); } if (myHead != null) addEdge(myHead, start); //loop interruptFlow(); finishNode(start); } | visitForStatement |
33,847 | void (@Nullable GrForClause clause) { if (clause instanceof GrTraditionalForClause) { acceptNullable(((GrTraditionalForClause)clause).getInitialization()); } else if (clause instanceof GrForInClause forInClause) { acceptNullable(forInClause.getIteratedExpression()); addNodeAndCheckPending(new ReadWriteVariableInstruction( getDescriptorId(new LoopIteratorVariableDescriptor(forInClause)), forInClause, ReadWriteVariableInstruction.WRITE )); } } | processForLoopInitializer |
33,848 | void (GrForStatement forStatement, @Nullable GrForClause clause) { final GroovyPsiElement target = forStatement.getParent() instanceof GrLabeledStatement ? (GroovyPsiElement)forStatement.getParent() : forStatement; if (clause instanceof GrTraditionalForClause) { final GrExpression condition = ((GrTraditionalForClause)clause).getCondition(); if (condition != null) { condition.accept(this); if (!alwaysTrue(condition)) { addPendingEdge(target, myHead); //break cycle } } } else { addPendingEdge(target, myHead); //break cycle } } | addForLoopBreakingEdge |
33,849 | void (@Nullable GrForClause clause) { if (clause instanceof GrForInClause) { GrVariable variable = ((GrForInClause)clause).getDeclaredVariable(); if (variable != null && myPolicy.isVariableInitialized(variable)) { addNodeAndCheckPending(new ReadWriteVariableInstruction(getDescriptorId(new LoopIteratorVariableDescriptor((GrForInClause)clause)), variable, ReadWriteVariableInstruction.READ)); addNodeAndCheckPending(new ReadWriteVariableInstruction(getDescriptorId(createDescriptor(variable)), variable, ReadWriteVariableInstruction.WRITE)); } } } | flushForeachLoopVariable |
33,850 | void (@NotNull InstructionImpl instruction) { final PsiElement element = instruction.getElement(); checkPending(element, instruction); } | checkPending |
33,851 | void (@Nullable PsiElement currentScope, @NotNull InstructionImpl targetInstruction) { final List<Pair<InstructionImpl, GroovyPsiElement>> pendingEdges = collectCorrespondingPendingEdges(currentScope); for (Pair<InstructionImpl, GroovyPsiElement> pair : pendingEdges) { addEdge(pair.getFirst(), targetInstruction); } } | checkPending |
33,852 | void (@Nullable GroovyPsiElement newScope) { final List<Pair<InstructionImpl, GroovyPsiElement>> targets = collectCorrespondingPendingEdges(newScope); for (Pair<InstructionImpl, GroovyPsiElement> target : targets) { addPendingEdge(newScope, target.getFirst()); } } | readdPendingEdge |
33,853 | void (@Nullable GroovyPsiElement scopeWhenAdded, InstructionImpl instruction) { if (instruction == null) return; int i = 0; if (scopeWhenAdded != null) { for (; i < myPending.size(); i++) { Pair<InstructionImpl, GroovyPsiElement> pair = myPending.get(i); final GroovyPsiElement currScope = pair.getSecond(); if (currScope == null) continue; if (!PsiTreeUtil.isAncestor(currScope, scopeWhenAdded, true)) break; } } myPending.add(i, Pair.create(instruction, scopeWhenAdded)); } | addPendingEdge |
33,854 | void (@NotNull GrWhileStatement whileStatement) { final InstructionImpl instruction = startNode(whileStatement); final GrCondition condition = whileStatement.getCondition(); if (condition != null) { condition.accept(this); } if (!alwaysTrue(condition)) { addPendingEdge(whileStatement, myHead); //break } final GrCondition body = whileStatement.getBody(); if (body != null) { body.accept(this); } checkPending(instruction); //check for breaks targeted here if (myHead != null) addEdge(myHead, instruction); //loop interruptFlow(); finishNode(instruction); } | visitWhileStatement |
33,855 | boolean (GroovyPsiElement condition) { if (condition instanceof GrExpression) { return Boolean.TRUE.equals(GroovyConstantExpressionEvaluator.evaluateNoResolve((GrExpression)condition)); } else { return false; } } | alwaysTrue |
33,856 | void (@NotNull GrSwitchElement switchElement) { final GrCondition condition = switchElement.getCondition(); if (condition != null) { condition.accept(this); } final InstructionImpl instruction = startNode(switchElement); final GrCaseSection[] sections = switchElement.getCaseSections(); if (!containsAllCases(switchElement)) { addPendingEdge(switchElement, instruction); } FList<ConditionInstruction> conditionsBefore = myConditions; for (GrCaseSection section : sections) { myConditions = conditionsBefore; myHead = instruction; GrExpression[] expressionPatterns = section.getExpressions(); if (!section.isDefault() && expressionPatterns.length > 0 && ContainerUtil.and(expressionPatterns, expr -> expr instanceof GrReferenceExpression && ((GrReferenceExpression)expr).getStaticReference().resolve() instanceof PsiClass)) { GrExpression expressionPattern = expressionPatterns[0]; if (expressionPattern != null && expressionPattern.getParent() instanceof GrExpressionList) { ConditionInstruction cond = registerCondition(section, false); addNodeAndCheckPending(cond); addNode(new InstanceOfInstruction((GroovyPsiElement)expressionPattern.getParent(), cond, myVariableMapping)); } } section.accept(this); } myConditions = conditionsBefore; finishNode(instruction); } | visitSwitchElement |
33,857 | void (@NotNull GrSwitchStatement switchStatement) { visitSwitchElement(switchStatement); } | visitSwitchStatement |
33,858 | void (@NotNull GrSwitchExpression switchExpression) { visitSwitchElement(switchExpression); } | visitSwitchExpression |
33,859 | void (@NotNull GrConditionalExpression expression) { GrExpression condition = expression.getCondition(); GrExpression thenBranch = expression.getThenBranch(); GrExpression elseBranch = expression.getElseBranch(); condition.accept(this); InstructionImpl conditionEnd = myHead; List<GotoInstruction> negations = collectAndRemoveAllPendingNegations(expression); if (thenBranch != null) { thenBranch.accept(this); handlePossibleReturn(thenBranch); addPendingEdge(expression, myHead); } if (elseBranch != null) { InstructionImpl head = reduceAllNegationsIntoInstruction(expression, negations); myHead = head != null ? head : conditionEnd; elseBranch.accept(this); handlePossibleReturn(elseBranch); } } | visitConditionalExpression |
33,860 | void (@NotNull GrElvisExpression expression) { GrExpression condition = expression.getCondition(); GrExpression elseBranch = expression.getElseBranch(); condition.accept(this); List<GotoInstruction> negations = collectAndRemoveAllPendingNegations(expression); InstructionImpl head = myHead; handlePossibleReturn(condition); addPendingEdge(expression, myHead); myHead = head; if (elseBranch != null) { head = reduceAllNegationsIntoInstruction(expression, negations); if (head != null) myHead = head; elseBranch.accept(this); handlePossibleReturn(elseBranch); } } | visitElvisExpression |
33,861 | boolean (GrSwitchElement statement) { final GrCaseSection[] sections = statement.getCaseSections(); for (GrCaseSection section : sections) { if (section.isDefault()) return true; } final GrExpression condition = statement.getCondition(); if (!(condition instanceof GrReferenceExpression)) return false; PsiType type = TypesUtil.unboxPrimitiveTypeWrapper(getNominalTypeNoRecursion(condition)); if (type == null) return false; if (type instanceof PsiPrimitiveType) { if (PsiTypes.booleanType().equals(type)) return sections.length == 2; if (PsiTypes.byteType().equals(type) || PsiTypes.charType().equals(type)) return sections.length == 128; return false; } if (type instanceof PsiClassType) { final PsiClass resolved = ((PsiClassType)type).resolve(); if (resolved != null && resolved.isEnum()) { int enumConstantCount = 0; final PsiField[] fields = resolved.getFields(); for (PsiField field : fields) { if (field instanceof PsiEnumConstant) enumConstantCount++; } if (sections.length == enumConstantCount) return true; } } // todo: sealed classes return false; } | containsAllCases |
33,862 | void (@NotNull GrCaseSection caseSection) { for (GrExpression value : caseSection.getExpressions()) { if (value != null) { value.accept(this); } } final GrStatement[] statements = caseSection.getStatements(); //infer 'may be return' position int i; //noinspection StatementWithEmptyBody for (i = statements.length - 1; i >= 0 && statements[i] instanceof GrBreakStatement; i--) { } for (int j = 0; j < statements.length; j++) { GrStatement statement = statements[j]; statement.accept(this); if (j == i) handlePossibleReturn(statement); } if (statements.length > 0) { handlePossibleYield(statements[statements.length - 1]); } if (myHead != null) { addPendingEdge(caseSection, myHead); } if (caseSection.getArrow() != null) { // arrow-style switch expressions are not fall-through var parent = caseSection.getParent(); if (parent instanceof GrSwitchElement) { readdPendingEdge((GroovyPsiElement)parent); } interruptFlow(); } } | visitCaseSection |
33,863 | void (GrStatement statement) { if (statement instanceof GrExpression && ControlFlowBuilderUtil.isCertainlyYieldStatement(statement)) { addNodeAndCheckPending(new MaybeYieldInstruction((GrExpression)statement)); } } | handlePossibleYield |
33,864 | void (@NotNull GrYieldStatement yieldStatement) { GrExpression value = yieldStatement.getYieldedValue(); if (value != null) { value.accept(this); } if (myHead != null) { GrSwitchElement correspondingSwitch = PsiTreeUtil.getParentOfType(yieldStatement, GrSwitchElement.class); addNode(new InstructionImpl(yieldStatement)); addPendingEdge(correspondingSwitch, myHead); } interruptFlow(); } | visitYieldStatement |
33,865 | void (@NotNull GrTryCatchStatement tryCatchStatement) { final GrOpenBlock tryBlock = tryCatchStatement.getTryBlock(); final GrCatchClause[] catchClauses = tryCatchStatement.getCatchClauses(); final GrFinallyClause finallyClause = tryCatchStatement.getFinallyClause(); for (int i = catchClauses.length - 1; i >= 0; i--) { myCaughtExceptionInfos.push(new ExceptionInfo(catchClauses[i])); } if (finallyClause != null) myFinallyCount++; List<Pair<InstructionImpl, GroovyPsiElement>> oldPending = null; if (finallyClause != null) { oldPending = myPending; myPending = new ArrayList<>(); } GrTryResourceList resourceList = tryCatchStatement.getResourceList(); if (resourceList != null) { resourceList.accept(this); } InstructionImpl tryBegin = startNode(tryBlock); if (tryBlock != null) { tryBlock.accept(this); } InstructionImpl tryEnd = myHead; finishNode(tryBegin); Set<Pair<InstructionImpl, GroovyPsiElement>> pendingAfterTry = new LinkedHashSet<>(myPending); @SuppressWarnings("unchecked") List<InstructionImpl>[] throwers = new List[catchClauses.length]; for (int i = 0; i < catchClauses.length; i++) { throwers[i] = myCaughtExceptionInfos.pop().myThrowers; } InstructionImpl[] catches = new InstructionImpl[catchClauses.length]; for (int i = 0; i < catchClauses.length; i++) { interruptFlow(); final InstructionImpl catchBeg = startNode(catchClauses[i]); for (InstructionImpl thrower : throwers[i]) { addEdge(thrower, catchBeg); } final GrParameter parameter = catchClauses[i].getParameter(); if (parameter != null && myPolicy.isVariableInitialized(parameter)) { addNode(new ReadWriteVariableInstruction(getDescriptorId(createDescriptor(parameter)), parameter, ReadWriteVariableInstruction.WRITE)); } catchClauses[i].accept(this); catches[i] = myHead; finishNode(catchBeg); } pendingAfterTry.addAll(myPending); myPending = new ArrayList<>(pendingAfterTry); if (finallyClause != null) { myFinallyCount--; interruptFlow(); final InstructionImpl finallyInstruction = startNode(finallyClause, false); Set<AfterCallInstruction> postCalls = new LinkedHashSet<>(); final List<Pair<InstructionImpl, GroovyPsiElement>> copy = myPending; myPending = new ArrayList<>(); for (Pair<InstructionImpl, GroovyPsiElement> pair : copy) { postCalls.add(addCallNode(finallyInstruction, pair.getSecond(), pair.getFirst())); } if (tryEnd != null) { postCalls.add(addCallNode(finallyInstruction, tryCatchStatement, tryEnd)); } for (InstructionImpl catchEnd : catches) { if (catchEnd != null) { postCalls.add(addCallNode(finallyInstruction, tryCatchStatement, catchEnd)); } } //save added postcalls into separate list because we don't want returnInstruction grabbed their pending edges List<Pair<InstructionImpl, GroovyPsiElement>> pendingPostCalls = myPending; myPending = new ArrayList<>(); myHead = finallyInstruction; finallyClause.accept(this); final ReturnInstruction returnInstruction = new ReturnInstruction(finallyClause); for (AfterCallInstruction postCall : postCalls) { postCall.setReturnInstruction(returnInstruction); addEdge(returnInstruction, postCall); } addNodeAndCheckPending(returnInstruction); interruptFlow(); finishNode(finallyInstruction); if (oldPending == null) { error(); } oldPending.addAll(pendingPostCalls); myPending = oldPending; } else { if (tryEnd != null) { addPendingEdge(tryCatchStatement, tryEnd); } for (InstructionImpl catchEnd : catches) { addPendingEdge(tryBlock, catchEnd); } } } | visitTryStatement |
33,866 | void () { error("broken control flow for a scope"); } | error |
33,867 | void (@NonNls @NotNull String descr) { PsiFile file = myScope.getContainingFile(); String fileText = file != null ? file.getText() : null; VirtualFile virtualFile = PsiUtilCore.getVirtualFile(file); String path = virtualFile == null ? null : virtualFile.getPresentableUrl(); LOG.error(descr + myScope.getText(), new Attachment(String.valueOf(path), String.valueOf(fileText))); } | error |
33,868 | AfterCallInstruction (InstructionImpl finallyInstruction, GroovyPsiElement scopeWhenAdded, InstructionImpl src) { interruptFlow(); final CallInstruction call = new CallInstruction(finallyInstruction); addNode(call); addEdge(src, call); addEdge(call, finallyInstruction); AfterCallInstruction afterCall = new AfterCallInstruction(call); addNode(afterCall); addPendingEdge(scopeWhenAdded, afterCall); return afterCall; } | addCallNode |
33,869 | InstructionImpl (@Nullable GroovyPsiElement element) { return startNode(element, true); } | startNode |
33,870 | InstructionImpl (@Nullable GroovyPsiElement element, boolean checkPending) { final InstructionImpl instruction = new InstructionImpl(element); addNode(instruction); if (checkPending) checkPending(instruction); myProcessingStack.push(instruction); return instruction; } | startNode |
33,871 | void (InstructionImpl instruction) { final InstructionImpl popped = myProcessingStack.pop(); if (!instruction.equals(popped)) { String description = "popped : " + popped.toString() + " : " + popped.hashCode() + ", " + popped.getClass() + "\n" + "expected: " + instruction.toString() + " : " + instruction.hashCode() + ", " + instruction.getClass() + "\n" + "same objects: " + (popped == instruction) + "\n"; error(description); } } | finishNode |
33,872 | void (@NotNull GrField field) { } | visitField |
33,873 | void (@NotNull GrParameter parameter) { if (parameter.getParent() instanceof GrForClause) { visitVariable(parameter); } } | visitParameter |
33,874 | void (@NotNull GrMethod method) { } | visitMethod |
33,875 | void (@NotNull GrClassInitializer initializer) { } | visitClassInitializer |
33,876 | void (@NotNull final GrTypeDefinition typeDefinition) { if (!(typeDefinition instanceof GrAnonymousClassDefinition)) return; var argumentList = ((GrAnonymousClassDefinition)typeDefinition).getArgumentListGroovy(); if (argumentList != null) { argumentList.accept(this); } final List<kotlin.Pair<ReadWriteVariableInstruction, VariableDescriptor>> vars = collectUsedVariableWithoutInitialization(typeDefinition); addReadFromNestedControlFlow(typeDefinition, vars); } | visitTypeDefinition |
33,877 | void (GroovyControlFlow flow) { List<kotlin.Pair<ReadWriteVariableInstruction, VariableDescriptor>> reads = ControlFlowBuilderUtil.getReadsWithoutPriorWrites(flow, false); vars.addAll(reads); } | collectVars |
33,878 | void (@NotNull GrField field) { GrExpression initializer = field.getInitializerGroovy(); if (initializer != null) { GroovyControlFlow flow = buildControlFlow(initializer); collectVars(flow); } } | visitField |
33,879 | void (@NotNull GrMethod method) { GrOpenBlock block = method.getBlock(); if (block != null) { collectVars(ControlFlowUtils.getGroovyControlFlow(block)); } } | visitMethod |
33,880 | void (@NotNull GrClassInitializer initializer) { collectVars(ControlFlowUtils.getGroovyControlFlow(initializer.getBlock())); } | visitClassInitializer |
33,881 | void (@NotNull GrVariable variable) { super.visitVariable(variable); if (myPolicy.isVariableInitialized(variable)) { ReadWriteVariableInstruction writeInst = new ReadWriteVariableInstruction(getDescriptorId(createDescriptor(variable)), variable, ReadWriteVariableInstruction.WRITE); addNodeAndCheckPending(writeInst); } } | visitVariable |
33,882 | InstructionImpl (PsiElement element) { for (final InstructionImpl instruction : myInstructions) { if (element.equals(instruction.getElement())) return instruction; } return null; } | findInstruction |
33,883 | void (@NotNull GroovyPsiElement element) { ProgressManager.checkCanceled(); super.visitElement(element); } | visitElement |
33,884 | GrIfStatement () { return (GrIfStatement)super.getElement(); } | getElement |
33,885 | String () { return "End element: " + myPsiElement; } | getElementPresentation |
33,886 | PsiElement () { return myPsiElement; } | getElement |
33,887 | Iterable<Instruction> (@NotNull CallEnvironment environment) { final Deque<CallInstruction> stack = environment.callStack(this); for (Instruction instruction : mySuccessors) { environment.update(stack, instruction); } return mySuccessors; } | successors |
33,888 | Iterable<Instruction> (@NotNull CallEnvironment environment) { final Deque<CallInstruction> stack = environment.callStack(this); for (Instruction instruction : myPredecessors) { environment.update(stack, instruction); } return myPredecessors; } | predecessors |
33,889 | Iterable<Instruction> () { return mySuccessors; } | allSuccessors |
33,890 | Iterable<Instruction> () { return myPredecessors; } | allPredecessors |
33,891 | String () { final StringBuilder builder = new StringBuilder(); builder.append(myNumber); builder.append("("); for (Instruction successor : mySuccessors) { builder.append(successor.num()); builder.append(','); } if (!mySuccessors.isEmpty()) builder.delete(builder.length() - 1, builder.length()); builder.append(") ").append(getElementPresentation()); return builder.toString(); } | toString |
33,892 | String () { //return "element: " + (myPsiElement != null ? myPsiElement.getText() : null); return "element: " + myPsiElement; } | getElementPresentation |
33,893 | int () { assert myNumber != -1; return myNumber; } | num |
33,894 | void (InstructionImpl instruction) { mySuccessors.add(instruction); } | addSuccessor |
33,895 | void (InstructionImpl instruction) { myPredecessors.add(instruction); } | addPredecessor |
33,896 | void (int num) { assert myNumber == -1; myNumber = num; } | setNumber |
33,897 | boolean (@NotNull GrReferenceExpression ref) { final GrExpression qualifier = ref.getQualifier(); return (qualifier == null || isThisRef(qualifier)) && ref.resolve() instanceof GrField; } | isReferenceAccepted |
33,898 | boolean (@NotNull GrVariable variable) { return false; } | isVariableInitialized |
33,899 | GrFieldControlFlowPolicy () { return INSTANCE; } | getInstance |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.