From 2c605ea01d632948302e23b68af834e9de2789fe Mon Sep 17 00:00:00 2001 From: Tagir Valeev Date: Mon, 15 Sep 2025 14:34:29 +0200 Subject: [PATCH] [multiple] Cleanup: use LinkedHashSet.getFirst() GitOrigin-RevId: ac2d373834829e3a33528afbeacee8037a935ead --- .../daemon/impl/quickfix/PullAsAbstractUpFix.java | 2 +- .../intellij/codeInsight/intention/impl/TypeExpression.java | 2 +- .../dvcs-impl/src/com/intellij/dvcs/push/ui/PushLog.java | 2 +- .../codeInspection/actions/RunInspectionIntention.java | 2 +- .../xdebugger/impl/actions/AttachToProcessActionBase.java | 2 +- .../idea/copyright/psi/UpdatePsiFileCopyright.java | 6 +++--- .../com/intellij/execution/junit/JUnitConfiguration.java | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/PullAsAbstractUpFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/PullAsAbstractUpFix.java index 9e236f509cfa..a593d16586d5 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/PullAsAbstractUpFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/PullAsAbstractUpFix.java @@ -157,7 +157,7 @@ public class PullAsAbstractUpFix extends LocalQuickFixAndIntentionActionOnPsiEle name = JavaBundle.message("intention.name.extract.method.to.new.interface", methodWithOverrides.getName()); canBePulledUp = false; } else if (classesToPullUp.size() == 1) { - final PsiClass baseClass = classesToPullUp.iterator().next(); + final PsiClass baseClass = classesToPullUp.getFirst(); name = JavaBundle.message("intention.name.pull.method.up.and.make.it.abstract.conditionally", methodWithOverrides.getName(), baseClass.getName(), !baseClass.hasModifierProperty(PsiModifier.ABSTRACT) ? 0 : 1); } } diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/TypeExpression.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/TypeExpression.java index f5117af9aadd..8219a88b1d9e 100644 --- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/TypeExpression.java +++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/TypeExpression.java @@ -45,7 +45,7 @@ public class TypeExpression extends Expression { } if (myItems.isEmpty()) return null; - final PsiType type = myItems.iterator().next().getType(); + final PsiType type = myItems.getFirst().getType(); return type == null ? null : new PsiTypeResult(type, project) { @Override public void handleRecalc(PsiFile psiFile, Document document, int segmentStart, int segmentEnd) { diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/PushLog.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/PushLog.java index 76c995676c71..01d4d9200a03 100644 --- a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/PushLog.java +++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/PushLog.java @@ -497,7 +497,7 @@ public final class PushLog extends JPanel implements Disposable, UiDataProvider .toCollection(LinkedHashSet::new); if (checkedNodes.isEmpty()) return; // use new state from first lead node; - boolean newState = !checkedNodes.iterator().next().isChecked(); + boolean newState = !checkedNodes.getFirst().isChecked(); checkedNodes.forEach(n -> myTree.setNodeState(n, newState)); } diff --git a/platform/lang-impl/src/com/intellij/codeInspection/actions/RunInspectionIntention.java b/platform/lang-impl/src/com/intellij/codeInspection/actions/RunInspectionIntention.java index e85557a8f084..0e39b7597467 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/actions/RunInspectionIntention.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/actions/RunInspectionIntention.java @@ -117,7 +117,7 @@ public final class RunInspectionIntention implements IntentionAction, HighPriori LinkedHashSet> allWrappers = new LinkedHashSet<>(); allWrappers.add(toolWrapper); rootProfile.collectDependentInspections(toolWrapper, allWrappers, project); - List> toolWrappers = allWrappers.size() == 1 ? Collections.singletonList(allWrappers.iterator().next()) : new ArrayList<>(allWrappers); + List> toolWrappers = allWrappers.size() == 1 ? Collections.singletonList(allWrappers.getFirst()) : new ArrayList<>(allWrappers); InspectionProfileImpl model = new InspectionProfileImpl(toolWrapper.getDisplayName(), new InspectionToolsSupplier.Simple(toolWrappers), rootProfile); for (InspectionToolWrapper wrapper : toolWrappers) { model.enableTool(wrapper.getShortName(), project); diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/AttachToProcessActionBase.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/AttachToProcessActionBase.java index 4795ad6d6d4d..ad78b635ef2f 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/AttachToProcessActionBase.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/AttachToProcessActionBase.java @@ -300,7 +300,7 @@ public abstract class AttachToProcessActionBase extends AnAction implements Dumb hostRecentItems.add(newRecentItem); while (hostRecentItems.size() > 4) { - hostRecentItems.remove(hostRecentItems.iterator().next()); + hostRecentItems.remove(hostRecentItems.getFirst()); } } diff --git a/plugins/copyright/src/com/maddyhome/idea/copyright/psi/UpdatePsiFileCopyright.java b/plugins/copyright/src/com/maddyhome/idea/copyright/psi/UpdatePsiFileCopyright.java index 7a942e6ea7d3..f049a91d2783 100644 --- a/plugins/copyright/src/com/maddyhome/idea/copyright/psi/UpdatePsiFileCopyright.java +++ b/plugins/copyright/src/com/maddyhome/idea/copyright/psi/UpdatePsiFileCopyright.java @@ -137,10 +137,10 @@ public abstract class UpdatePsiFileCopyright extends AbstractUpdateCopyright { } if (commentHere && found.size() == 1) { - CommentRange range = found.iterator().next(); + CommentRange range = found.getFirst(); // Is the comment in the right place? - if (langOpts.isRelativeBefore() && range.getFirst() == comments.get(0) || - !langOpts.isRelativeBefore() && range.getLast() == comments.get(comments.size() - 1)) { + if (langOpts.isRelativeBefore() && range.getFirst() == comments.getFirst() || + !langOpts.isRelativeBefore() && range.getLast() == comments.getLast()) { // Check to see if current copyright comment matches new one. String newComment = getCommentText("", ""); resetCommentText(); diff --git a/plugins/junit/src/com/intellij/execution/junit/JUnitConfiguration.java b/plugins/junit/src/com/intellij/execution/junit/JUnitConfiguration.java index 28cb1a987b15..088c3042e97e 100644 --- a/plugins/junit/src/com/intellij/execution/junit/JUnitConfiguration.java +++ b/plugins/junit/src/com/intellij/execution/junit/JUnitConfiguration.java @@ -838,7 +838,7 @@ public class JUnitConfiguration extends JavaTestConfigurationWithDiscoverySuppor if (TEST_PATTERN.equals(TEST_OBJECT)) { final int size = myPattern.size(); if (size == 0) return JUnitBundle.message("default.junit.config.name.temp.suite"); - String fqName = myPattern.iterator().next(); + String fqName = myPattern.getFirst(); String firstName = fqName.contains("*") ? fqName : StringUtil.getShortName(fqName.contains("(") ? StringUtil.getPackageName(fqName, '(') : fqName);