Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
70,900
String (PsiNewExpression element) { final PsiType newExprType = element.getType(); if (newExprType == null) { return null; } PsiClass containingClass = null; final PsiJavaCodeReferenceElement classReference = element.getClassOrAnonymousClassReference(); if (classReference != null) { final JavaResolveResult resolve = cl...
getQualifierTextByNewExpression
70,901
String (PsiVariable[] parameters, PsiMethod psiMethod, PsiClass containingClass, @NotNull PsiExpression qualifierExpression) { if (psiMethod.hasModifierProperty(PsiModifier.STATIC)) { return null; } final PsiMethod nonAmbiguousMethod = getNonAmbiguousReceiver(parameters, psiMethod); if (nonAmbiguousMethod == null) { re...
composeReceiverQualifierText
70,902
String (PsiClass containingClass) { final String qualifiedName = containingClass.getQualifiedName(); if (qualifiedName != null) { return qualifiedName; } else { return containingClass.getName(); } }
getClassReferenceName
70,903
boolean (PsiVariable p) { if (p.getAnnotations().length > 0) return true; PsiTypeElement typeElement = p.getTypeElement(); return typeElement != null && !typeElement.isInferredType() && PsiTypesUtil.hasTypeAnnotation(typeElement.getType()); }
hasAnnotation
70,904
String () { return mySafeQualifier ? getFamilyName() : InspectionGadgetsBundle.message("replace.with.method.ref.fix.name.may.change.semantics"); }
getName
70,905
String () { return InspectionGadgetsBundle.message("replace.with.method.ref.fix.family.name"); }
getFamilyName
70,906
void (@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater) { if (element instanceof PsiLambdaExpression lambda) { MethodReferenceCandidate methodReferenceCandidate = extractMethodReferenceCandidateExpression(lambda.getBody()); if (methodReferenceCandidate == null) return; element = met...
applyFix
70,907
PsiExpression (@NotNull PsiLambdaExpression lambda, PsiElement body) { Project project = lambda.getProject(); PsiType functionalInterfaceType = lambda.getFunctionalInterfaceType(); if (functionalInterfaceType == null || !functionalInterfaceType.isValid()) return lambda; final PsiType denotableFunctionalInterfaceType = ...
tryConvertToMethodReference
70,908
PsiElementVisitor (@NotNull ProblemsHolder holder, boolean isOnTheFly) { if (!PsiUtil.isLanguageLevel8OrHigher(holder.getFile())) { return PsiElementVisitor.EMPTY_VISITOR; } boolean java11 = PsiUtil.isLanguageLevel11OrHigher(holder.getFile()); return new JavaElementVisitor() { @Override public void visitLambdaExpressio...
buildVisitor
70,909
void (@NotNull PsiLambdaExpression lambda) { super.visitLambdaExpression(lambda); PsiElement body = lambda.getBody(); if (body == null) return; PsiType type = lambda.getFunctionalInterfaceType(); if (!(type instanceof PsiClassType)) return; PsiElement parent = PsiUtil.skipParenthesizedExprUp(lambda.getParent()); if(par...
visitLambdaExpression
70,910
void (PsiLambdaExpression lambda, PsiParameter parameter, PsiExpression expression) { if (!BoolUtils.isNegation(expression)) return; PsiMethodCallExpression negated = ObjectUtils.tryCast(BoolUtils.getNegated(expression), PsiMethodCallExpression.class); if (!PREDICATE_TEST.test(negated)) return; if (!ExpressionUtils.isR...
handlePatternNegate
70,911
void (PsiLambdaExpression lambda, PsiClassType type) { PsiClass aClass = type.resolve(); if (aClass == null || !CommonClassNames.JAVA_UTIL_FUNCTION_FUNCTION.equals(aClass.getQualifiedName())) return; PsiType[] typeParameters = type.getParameters(); if (typeParameters.length != 2 || !typeParameters[1].isAssignableFrom(t...
handleFunctionIdentity
70,912
void (PsiLambdaExpression lambda, PsiParameter parameter, PsiMethodCallExpression call) { if (!MATCHER_FIND.test(call) && (!java11 || !MATCHER_MATCHES.test(call))) return; PsiMethodCallExpression matcherCall = MethodCallUtils.getQualifierMethodCall(call); if (!PATTERN_MATCHER.test(matcherCall)) return; PsiExpression ma...
handlePatternAsPredicate
70,913
void (PsiLambdaExpression lambda, PsiParameter parameter, PsiMethodCallExpression call) { if (MethodCallUtils.isCallToStaticMethod(call, "java.util.Objects", "equals", 2)) { PsiExpression[] args = call.getArgumentList().getExpressions(); if (args.length == 2) { PsiExpression comparedWith; if (ExpressionUtils.isReferenc...
handlePredicateIsEqual
70,914
void (PsiLambdaExpression lambda, @NlsSafe String displayReplacement, @NlsSafe String replacement) { holder.registerProblem(lambda, JavaAnalysisBundle.message("inspection.can.be.replaced.with.message", displayReplacement), new ReplaceWithFunctionCallFix(replacement, displayReplacement)); }
registerProblem
70,915
String () { return JavaBundle.message("inspection.lambda.to.method.call.fix.name", myDisplayReplacement); }
getName
70,916
String () { return JavaBundle.message("inspection.lambda.to.method.call.fix.family.name"); }
getFamilyName
70,917
void (@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater) { if (!(element instanceof PsiLambdaExpression)) return; PsiElement result = new CommentTracker().replaceAndRestoreComments(element, myReplacement); CodeStyleManager.getInstance(project).reformat(JavaCodeStyleManager.getInstanc...
applyFix
70,918
String () { return InspectionGadgetsBundle.message("cast.conflicts.with.instanceof.quickfix1", myExistingTypeText, myWantedTypeText); }
getName
70,919
String () { return JavaBundle.message("quickfix.family.replace.cast.type"); }
getFamilyName
70,920
void (@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater) { PsiTypeElement typeElement = ObjectUtils.tryCast(element, PsiTypeElement.class); if (typeElement == null) return; PsiElementFactory factory = JavaPsiFacade.getElementFactory(project); PsiTypeElement replacement = factory.crea...
applyFix
70,921
PsiElementVisitor (@NotNull ProblemsHolder holder, boolean isOnTheFly) { return new JavaElementVisitor() { @Override public void visitMethodCallExpression(@NotNull PsiMethodCallExpression call) { if (!COMPARE_TO_METHODS.test(call)) return; PsiElement nameElement = call.getMethodExpression().getReferenceNameElement(); i...
buildVisitor
70,922
void (@NotNull PsiMethodCallExpression call) { if (!COMPARE_TO_METHODS.test(call)) return; PsiElement nameElement = call.getMethodExpression().getReferenceNameElement(); if (nameElement == null) return; final PsiExpression qualifierExpression = call.getMethodExpression().getQualifierExpression(); if (qualifierExpressio...
visitMethodCallExpression
70,923
String () { String method = getMethodName(); return CommonQuickFixBundle.message("fix.replace.with.x.call", method); }
getName
70,924
String () { return InspectionGadgetsBundle.message("inspection.simplifiable.compare.java.time.family.name"); }
getFamilyName
70,925
String () { return switch (myRelationType) { case EQ, NE -> myArgumentType.equals(JAVA_TIME_LOCAL_TIME) ? "equals" : "isEqual"; case GT, LE -> "isAfter"; case LT, GE -> "isBefore"; default -> throw new UnsupportedOperationException(myRelationType.toString()); }; }
getMethodName
70,926
void (@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater) { PsiMethodCallExpression call = PsiTreeUtil.getParentOfType(element, PsiMethodCallExpression.class); if (call == null) return; PsiExpression first = call.getMethodExpression().getQualifierExpression(); if (first == null) { ret...
applyFix
70,927
PsiElementVisitor (@NotNull ProblemsHolder holder, boolean isOnTheFly) { return new JavaElementVisitor() { @Override public void visitMethodCallExpression(@NotNull PsiMethodCallExpression call) { if (!COMPARE_METHODS.test(call)) return; PsiBinaryExpression binOp = ObjectUtils.tryCast(PsiUtil.skipParenthesizedExprUp(cal...
buildVisitor
70,928
void (@NotNull PsiMethodCallExpression call) { if (!COMPARE_METHODS.test(call)) return; PsiBinaryExpression binOp = ObjectUtils.tryCast(PsiUtil.skipParenthesizedExprUp(call.getParent()), PsiBinaryExpression.class); if (binOp == null) return; RelationType type = DfaPsiUtil.getRelationByToken(binOp.getOperationTokenType(...
visitMethodCallExpression
70,929
String () { return InspectionGadgetsBundle.message("inspection.redundant.compare.call.fix.name"); }
getFamilyName
70,930
void (@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater) { PsiMethodCallExpression call = ObjectUtils.tryCast(element, PsiMethodCallExpression.class); if (call == null) return; PsiExpression[] args = call.getArgumentList().getExpressions(); if(args.length != 2) return; String maybeCa...
applyFix
70,931
PsiElementVisitor (@NotNull final ProblemsHolder holder, boolean isOnTheFly) { return new JavaElementVisitor() { @Override public void visitMethodReferenceExpression(final @NotNull PsiMethodReferenceExpression expression) { Problem problem = doCheckMethodCallOnFunctionalExpression(expression, call -> expression.resolve...
buildVisitor
70,932
void (final @NotNull PsiMethodReferenceExpression expression) { Problem problem = doCheckMethodCallOnFunctionalExpression(expression, call -> expression.resolve() != null); if (problem != null) { problem.register(holder); } }
visitMethodReferenceExpression
70,933
void (final @NotNull PsiLambdaExpression expression) { Problem problem = doCheckLambda(expression); if (problem != null) { problem.register(holder); } }
visitLambdaExpression
70,934
void (final @NotNull PsiAnonymousClass aClass) { if (AnonymousCanBeLambdaInspection.canBeConvertedToLambda(aClass, false, Collections.emptySet())) { final PsiNewExpression newExpression = ObjectUtils.tryCast(aClass.getParent(), PsiNewExpression.class); Problem problem = doCheckMethodCallOnFunctionalExpression(call -> {...
visitAnonymousClass
70,935
void (@NotNull PsiElement context) { List<@NotNull Problem> problems = SyntaxTraverser.psiTraverser(context) .filter(PsiLambdaExpression.class) .filterMap(TrivialFunctionalExpressionUsageInspection::doCheckLambda) .toList(); for (Problem problem : problems) { if (!problem.place().isValid()) continue; problem.fix().appl...
simplifyAllLambdas
70,936
Problem (@NotNull PsiLambdaExpression expression) { final PsiElement body = expression.getBody(); if (body == null) return null; Predicate<PsiMethodCallExpression> checkBody = call -> { final PsiElement callParent = call.getParent(); if (!(body instanceof PsiCodeBlock)) { return callParent instanceof PsiStatement || ca...
doCheckLambda
70,937
record (@NotNull PsiElement place, @NotNull ReplaceFix fix) { void register(@NotNull ProblemsHolder holder) { holder.registerProblem(place, InspectionGadgetsBundle.message("inspection.trivial.functional.expression.usage.description"), fix); } }
Problem
70,938
void (PsiLambdaExpression lambda) { lambda = extractSideEffects(lambda); if (lambda == null) return; PsiMethodCallExpression callExpression = PsiTreeUtil.getParentOfType(lambda, PsiMethodCallExpression.class); if (callExpression == null) return; PsiElement body = lambda.getBody(); PsiExpression expression = LambdaUtil....
replaceWithLambdaBody
70,939
PsiLambdaExpression (PsiLambdaExpression lambda) { PsiMethodCallExpression callExpression = PsiTreeUtil.getParentOfType(lambda, PsiMethodCallExpression.class); if (callExpression == null) return lambda; PsiExpression[] arguments = callExpression.getArgumentList().getExpressions(); if (!ContainerUtil.exists(arguments, S...
extractSideEffects
70,940
void (PsiMethodCallExpression callExpression, PsiLambdaExpression element) { PsiExpression expression; final CommentTracker ct = new CommentTracker(); inlineCallArguments(callExpression, element, ct); // body could be invalidated after inlining expression = LambdaUtil.extractSingleExpressionFromBody(element.getBody());...
replaceExpression
70,941
void (PsiLambdaExpression element) { CodeBlockSurrounder surrounder = CodeBlockSurrounder.forExpression(element); if (surrounder == null) return; CodeBlockSurrounder.SurroundResult result = surrounder.surround(); element = (PsiLambdaExpression)result.getExpression(); PsiElement body = element.getBody(); if (!(body inst...
replaceCodeBlock
70,942
void (PsiStatement[] statements, @NotNull PsiElement anchor, @NotNull PsiLambdaExpression lambda) { Predicate<PsiVariable> allowedVar = variable -> PsiTreeUtil.isAncestor(lambda, variable, true); Project project = anchor.getProject(); JavaCodeStyleManager manager = JavaCodeStyleManager.getInstance(project); StreamEx.of...
solveNameConflicts
70,943
void (PsiMethodCallExpression callExpression, PsiLambdaExpression element, CommentTracker ct) { final PsiExpression[] args = callExpression.getArgumentList().getExpressions(); final PsiParameter[] parameters = element.getParameterList().getParameters(); for (int i = 0; i < parameters.length; i++) { final PsiParameter p...
inlineCallArguments
70,944
String () { return InspectionGadgetsBundle.message("replace.with.lambda.body.fix.family.name"); }
getFamilyName
70,945
void (PsiMethodCallExpression callExpression, PsiExpression qualifierExpression) { if (qualifierExpression instanceof PsiTypeCastExpression) { final PsiExpression element = PsiUtil.skipParenthesizedExprDown(((PsiTypeCastExpression)qualifierExpression).getOperand()); if (element instanceof PsiLambdaExpression) { replace...
fixExpression
70,946
String () { return InspectionGadgetsBundle.message("replace.with.method.reference.fix.family.name"); }
getFamilyName
70,947
void (PsiMethodCallExpression callExpression, PsiExpression qualifierExpression) { if (qualifierExpression instanceof PsiTypeCastExpression) { final PsiExpression element = ((PsiTypeCastExpression)qualifierExpression).getOperand(); if (element instanceof PsiMethodReferenceExpression) { final PsiLambdaExpression lambdaE...
fixExpression
70,948
String () { return InspectionGadgetsBundle.message("replace.anonymous.with.lambda.body.fix.family.name"); }
getFamilyName
70,949
void (PsiMethodCallExpression callExpression, PsiExpression qualifierExpression) { final PsiExpression cast = AnonymousCanBeLambdaInspection.replacePsiElementWithLambda(qualifierExpression, true, false); if (cast instanceof PsiTypeCastExpression) { final PsiExpression lambdaExpression = ((PsiTypeCastExpression)cast).ge...
fixExpression
70,950
String () { return getFamilyName(); }
getName
70,951
void (@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater) { apply(element); }
applyFix
70,952
OptPane () { return pane( checkbox("myWarnOnlyOnExpressionConversion", JavaBundle.message("inspection.switch.expression.migration.warn.only.on.expression")), number("myMaxNumberStatementsForBranch", JavaBundle.message("inspection.switch.expression.migration.expression.max.statements"), 1, 200)); }
getOptionsPane
70,953
PsiElementVisitor (@NotNull ProblemsHolder holder, boolean isOnTheFly) { if (!HighlightingFeature.ENHANCED_SWITCH.isAvailable(holder.getFile())) return PsiElementVisitor.EMPTY_VISITOR; return new JavaElementVisitor() { @Override public void visitSwitchStatement(@NotNull PsiSwitchStatement statement) { PsiElement switch...
buildVisitor
70,954
void (@NotNull PsiSwitchStatement statement) { PsiElement switchKeyword = statement.getFirstChild(); if (switchKeyword == null) { return; } List<SwitchReplacer> replacers = findSwitchReplacers(statement, myMaxNumberStatementsForBranch); if (replacers.isEmpty()) return; Optional<SwitchReplacer> replacerWithWarningLevel ...
visitSwitchStatement
70,955
boolean (@NotNull SwitchReplacer replacer) { if (replacer.isInformLevel()) { return false; } return !(myWarnOnlyOnExpressionConversion && replacer.getType() == ReplacementType.Statement); }
isWarningLevel
70,956
List<SwitchReplacer> (@NotNull PsiStatement statement, boolean isExhaustive, @NotNull List<OldSwitchStatementBranch> branches, int maxNumberStatementsForExpression) { List<SwitchReplacer> replacers = new ArrayList<>(); for (SwitchConversion inspection : ourInspections) { SwitchReplacer replacer = inspection.suggestRepl...
runInspections
70,957
OldSwitchStatementBranch (List<? super OldSwitchStatementBranch> branches, PsiStatement[] statements, int unmatchedCaseIndex, int endIndexExcl, boolean isFallthrough, PsiBreakStatement current) { PsiSwitchLabelStatement labelStatement = (PsiSwitchLabelStatement)statements[unmatchedCaseIndex]; PsiStatement[] branchState...
addBranch
70,958
List<OldSwitchStatementBranch> (@NotNull PsiCodeBlock body, PsiSwitchStatement switchStatement) { List<OldSwitchStatementBranch> branches = new ArrayList<>(); PsiStatement[] statements = body.getStatements(); int unmatchedCaseIndex = -1; OldSwitchStatementBranch previousBranch = null; for (int i = 0, length = statement...
extractBranches
70,959
SwitchReplacer (@NotNull PsiSwitchStatement switchStatement) { List<SwitchReplacer> replacers = findSwitchReplacers(switchStatement, 1); for (SwitchReplacer replacer : replacers) { if (!replacer.isInformLevel()) { return replacer; } } return null; }
findSwitchReplacer
70,960
List<SwitchReplacer> (@NotNull PsiSwitchStatement switchStatement, int maxNumberStatementsForExpression) { PsiExpression expression = switchStatement.getExpression(); if (expression == null) return List.of(); PsiCodeBlock body = switchStatement.getBody(); if (body == null) return List.of(); List<OldSwitchStatementBranc...
findSwitchReplacers
70,961
PsiSwitchBlock (@NotNull PsiStatement statementToReplace, List<SwitchBranch> newBranches, CommentTracker ct, boolean isExpr) { PsiElementFactory factory = JavaPsiFacade.getElementFactory(statementToReplace.getProject()); if (!(statementToReplace instanceof PsiSwitchStatement)) return null; PsiCodeBlock body = ((PsiSwit...
generateEnhancedSwitch
70,962
boolean (List<OldSwitchStatementBranch> branches, PsiSwitchStatement switchStatement) { for (OldSwitchStatementBranch branch : branches) { if (branch.isDefault()) return true; if (existsDefaultLabelElement(branch.myLabelStatement)) return true; } CompletenessResult completenessResult = PatternsInSwitchBlockHighlighting...
isExhaustiveSwitch
70,963
boolean (@NotNull OldSwitchStatementBranch branch, boolean hasNext) { int length = branch.getStatements().length; if (length == 0) return (branch.isFallthrough() && hasNext) || (!branch.isFallthrough() && branch.isDefault()); return !branch.isFallthrough(); }
isConvertibleBranch
70,964
String () { return JavaBundle.message("inspection.replace.with.switch.expression.fix.family.name"); }
getFamilyName
70,965
String () { return myReplacementType.getFixName(); }
getName
70,966
void (@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater) { PsiSwitchStatement statement = PsiTreeUtil.getParentOfType(element, PsiSwitchStatement.class); if (statement == null) return; SwitchReplacer replacer = ContainerUtil.find(findSwitchReplacers(statement, Integer.MAX_VALUE), t -...
applyFix
70,967
List<SwitchBranch> (@NotNull List<SwitchBranch> branches, @NotNull PsiElement context) { if (branches.isEmpty()) { return branches; } boolean java20plus = PsiUtil.getLanguageLevel(context).isAtLeast(LanguageLevel.JDK_20_PREVIEW); if (!java20plus) { return branches; } List<SwitchBranch> result = new ArrayList<>(); for (...
rearrangeBranches
70,968
void (@NotNull SwitchBranch branch, @NotNull List<? extends PsiCaseLabelElement> caseExpressions, @NotNull List<SwitchBranch> result) { List<PsiCaseLabelElement> previousExpressions = new ArrayList<>(); for (PsiCaseLabelElement expression : caseExpressions) { PsiCaseLabelElement external = findNullLabel(List.of(express...
rearrangeCases
70,969
PsiCaseLabelElement (@NotNull List<? extends PsiCaseLabelElement> expressions) { return ContainerUtil.find(expressions, label -> label instanceof PsiExpression literal && TypeConversionUtil.isNullType(literal.getType())); }
findNullLabel
70,970
Integer () { return myMaxNumberStatementsInBranch; }
getMaxNumberStatementsInBranch
70,971
boolean () { return myIsInfo; }
isInformLevel
70,972
void (@NotNull PsiStatement statement) { CommentTracker commentTracker = new CommentTracker(); PsiSwitchBlock switchBlock = generateEnhancedSwitch(statement, myNewBranches, commentTracker, true); if (switchBlock == null) return; if (myReturnToDelete != null) { CommentTracker ct = new CommentTracker(); commentTracker.ma...
replace
70,973
ReplacementType () { return ReplacementType.Expression; }
getType
70,974
SwitchReplacer (@NotNull PsiStatement statement, @NotNull List<OldSwitchStatementBranch> branches, boolean isExhaustive, int maxNumberStatementsForExpression) { PsiReturnStatement returnAfterSwitch = tryCast(PsiTreeUtil.getNextSiblingOfType(statement, PsiStatement.class), PsiReturnStatement.class); PsiThrowStatement th...
inspectReturningSwitch
70,975
PsiStatement[] (PsiStatement[] statements, @NotNull PsiExpression expr) { PsiStatement[] result = ArrayUtil.copyOf(statements); PsiStatement yieldStatement = createYieldStatement(expr); result[result.length - 1] = yieldStatement; return result; }
withLastStatementReplacedWithYield
70,976
PsiStatement (@NotNull PsiExpression expr) { Project project = expr.getProject(); PsiElementFactory factory = JavaPsiFacade.getElementFactory(project); return factory.createStatementFromText("yield " + StringUtil.trim(expr.getText()) + ";", expr); }
createYieldStatement
70,977
Integer () { return myMaxNumberStatementsInBranch; }
getMaxNumberStatementsInBranch
70,978
boolean () { return myIsInfo; }
isInformLevel
70,979
void (@NotNull PsiStatement switchStatement) { PsiLabeledStatement labeledStatement = tryCast(switchStatement.getParent(), PsiLabeledStatement.class); CommentTracker commentTracker = new CommentTracker(); PsiSwitchBlock replacement = generateEnhancedSwitch(switchStatement, myNewBranches, commentTracker, true); if (repl...
replace
70,980
boolean (@NotNull PsiVariable variable, @NotNull PsiStatement switchStatement) { try { ControlFlow controlFlow = ControlFlowFactory .getControlFlow(switchStatement, AllVariablesControlFlowPolicy.getInstance(), ControlFlowOptions.NO_CONST_EVALUATE); List<PsiReferenceExpression> references = ControlFlowUtil.getReadBefore...
isNotUsed
70,981
ReplacementType () { return ReplacementType.Expression; }
getType
70,982
SwitchReplacer (@NotNull PsiStatement statement, @NotNull List<OldSwitchStatementBranch> branches, boolean isExhaustive, int maxNumberStatementsForExpression) { PsiElement parent = statement.getParent(); PsiElement anchor = parent instanceof PsiLabeledStatement ? parent : statement; PsiLocalVariable assignedVariable = ...
inspectVariableAssigningSwitch
70,983
boolean (@NotNull PsiSwitchLabelStatement statement) { PsiCaseLabelElementList labelElementList = statement.getCaseLabelElementList(); if (labelElementList == null) return false; return ContainerUtil.exists(labelElementList.getElements(), el -> el instanceof PsiDefaultCaseLabelElement); }
existsDefaultLabelElement
70,984
boolean (PsiElement anchor, PsiVariable assignedVariable) { PsiDeclarationStatement declaration = tryCast(PsiTreeUtil.getPrevSiblingOfType(anchor, PsiStatement.class), PsiDeclarationStatement.class); if (declaration != null) { PsiElement[] elements = declaration.getDeclaredElements(); if (elements.length == 1) { PsiLoc...
isRightAfterDeclaration
70,985
boolean () { return false; }
isInformLevel
70,986
Integer () { return null; }
getMaxNumberStatementsInBranch
70,987
void (@NotNull PsiStatement switchStatement) { CommentTracker commentTracker = new CommentTracker(); PsiSwitchBlock switchBlock = generateEnhancedSwitch(switchStatement, myExpressionBranches, commentTracker, false); if (switchBlock == null) return; commentTracker.replaceAndRestoreComments(switchStatement, switchBlock);...
replace
70,988
ReplacementType () { return ReplacementType.Statement; }
getType
70,989
SwitchReplacer (@NotNull PsiStatement statement, @NotNull List<OldSwitchStatementBranch> branches) { for (int i = 0, size = branches.size(); i < size; i++) { OldSwitchStatementBranch branch = branches.get(i); if (!isConvertibleBranch(branch, i != size - 1) && //example: //case 0: break !(!branch.isFallthrough() && bran...
inspectReplacementWithStatement
70,990
boolean (@NotNull PsiStatement switchStmt, OldSwitchStatementBranch branch, PsiLocalVariable variable) { return !PsiTreeUtil.isAncestor(switchStmt, variable, false) || ContainerUtil.or(branch.getStatements(), stmt -> PsiTreeUtil.isAncestor(stmt, variable, false)); }
isInBranchOrOutside
70,991
String (CommentTracker ct, SwitchBranch branch) { if (myResultStatements.length == 1) { PsiStatement first = myResultStatements[0]; if (first instanceof PsiExpressionStatement || first instanceof PsiBlockStatement || first instanceof PsiThrowStatement) return ct.textWithComments(myResultStatements[0]) + "\n"; } StringB...
generate
70,992
void (@Nullable PsiElement element, @NotNull StringBuilder sb, CommentTracker ct) { if (element == null) { return; } PsiElement current = element.getNextSibling(); while (current instanceof PsiComment || current instanceof PsiWhiteSpace) { sb.append(ct.text(current)); current = current.getNextSibling(); } }
addWhiteSpaceAndComments
70,993
String (CommentTracker ct, SwitchBranch branch) { return ct.textWithComments(myExpression) + ";"; }
generate
70,994
void (CommentTracker ct, SwitchBranch branch, StringBuilder builder) { PsiElement label = ContainerUtil.find(branch.myUsedElements, e -> e instanceof PsiSwitchLabelStatement); if (!(label instanceof PsiSwitchLabelStatement labelStatement)) { return; } PsiSwitchLabelStatement nextLabelStatement = PsiTreeUtil.getNextSibl...
addCommentsUntilNextLabel
70,995
String (CommentTracker ct) { StringBuilder sb = new StringBuilder(); PsiElement label = ContainerUtil.find(myUsedElements, e -> e instanceof PsiSwitchLabelStatement); if (label != null) { sb.append(ct.commentsBefore(label.getFirstChild())); } if (!myCaseExpressions.isEmpty()) { String labels = StreamEx.of(myCaseExpress...
generate
70,996
void (PsiElement label, CommentTracker ct, StringBuilder sb) { if (label != null) { PsiElement child = label.getLastChild(); while (child != null && !child.textMatches(":")) { child = child.getPrevSibling(); } if (child != null) { sb.append(ct.commentsBefore(child)); } } }
grabCommentsBeforeColon
70,997
SwitchBranch (@NotNull List<PsiCaseLabelElement> caseElements) { return new SwitchBranch(myIsDefault, caseElements, myGuard, myRuleResult, myUsedElements); }
withLabels
70,998
SwitchBranch (@NotNull SwitchRuleResult ruleResult) { return new SwitchBranch(true, Collections.emptyList(), null, ruleResult, Collections.emptyList()); }
createDefault
70,999
SwitchBranch (@NotNull OldSwitchStatementBranch branch, @NotNull SwitchRuleResult result, @NotNull List<? extends PsiElement> usedElements) { return new SwitchBranch(branch.isDefault(), branch.getCaseLabelElements(), branch.getGuardExpression(), result, usedElements); }
fromOldBranch