From 01ae879656b3b07a33ad00e68066faaf67fdb29b Mon Sep 17 00:00:00 2001 From: Alexey Borokhvostov Date: Fri, 15 Dec 2023 23:48:27 +0700 Subject: [PATCH] PHP: Fixing cancelability bugs by reverting from a for each loop to a normal loop --- .../verification/IncorrectNonAbstractMethodHintError.java | 4 ++-- .../modules/php/editor/verification/PHP72UnhandledError.java | 4 ++-- .../modules/php/editor/verification/PHP73UnhandledError.java | 4 ++-- .../modules/php/editor/verification/PHP80UnhandledError.java | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/verification/IncorrectNonAbstractMethodHintError.java b/php/php.editor/src/org/netbeans/modules/php/editor/verification/IncorrectNonAbstractMethodHintError.java index a0441a979a12..33dd250aa60c 100644 --- a/php/php.editor/src/org/netbeans/modules/php/editor/verification/IncorrectNonAbstractMethodHintError.java +++ b/php/php.editor/src/org/netbeans/modules/php/editor/verification/IncorrectNonAbstractMethodHintError.java @@ -85,13 +85,13 @@ public void invoke(PHPRuleContext context, List hints) { "IncorrectNonAbstractMethodHintErrorHintDesc=Non-abstract method \"{0}\" must contain body" }) private void addIcorrectNonAbstractMethodHints(Set methodDeclarations, List hints, BaseDocument doc) { - methodDeclarations.forEach((methodDeclaration) -> { + for (MethodDeclaration methodDeclaration: methodDeclarations) { if (CancelSupport.getDefault().isCancelled()) { return; } List fixes = Collections.singletonList(new AddBodyFix(doc, methodDeclaration)); addHint(methodDeclaration, Bundle.IncorrectNonAbstractMethodHintErrorHintDesc(CodeUtils.extractMethodName(methodDeclaration)), hints, fixes); - }); + } } private void addHint(ASTNode node, String description, List hints, List fixes) { diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/verification/PHP72UnhandledError.java b/php/php.editor/src/org/netbeans/modules/php/editor/verification/PHP72UnhandledError.java index ef7ee8936a63..4187ed0e0990 100644 --- a/php/php.editor/src/org/netbeans/modules/php/editor/verification/PHP72UnhandledError.java +++ b/php/php.editor/src/org/netbeans/modules/php/editor/verification/PHP72UnhandledError.java @@ -115,7 +115,7 @@ private void checkGroupUseTrailingCommas() { if (ts == null) { return; } - lastUseStatementParts.forEach((lastUseStatementPart) -> { + for (SingleUseStatementPart lastUseStatementPart: lastUseStatementParts) { if (CancelSupport.getDefault().isCancelled()) { return; } @@ -129,7 +129,7 @@ private void checkGroupUseTrailingCommas() { createError(lastUseStatementPart); } } - }); + } } finally { document.readUnlock(); lastUseStatementParts.clear(); diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/verification/PHP73UnhandledError.java b/php/php.editor/src/org/netbeans/modules/php/editor/verification/PHP73UnhandledError.java index 08129321062a..74a2fcb2bdb9 100644 --- a/php/php.editor/src/org/netbeans/modules/php/editor/verification/PHP73UnhandledError.java +++ b/php/php.editor/src/org/netbeans/modules/php/editor/verification/PHP73UnhandledError.java @@ -161,7 +161,7 @@ private void checkFunctionCallTrailingCommas() { } private void checkFunctionCallTrailingCommas(TokenSequence ts) { - nodes.forEach((node) -> { + for (ASTNode node: nodes) { if (CancelSupport.getDefault().isCancelled()) { return; } @@ -183,7 +183,7 @@ private void checkFunctionCallTrailingCommas(TokenSequence ts) { if (!parameters.isEmpty()) { createError(parameters.get(parameters.size() - 1)); } - }); + } } @CheckForNull diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/verification/PHP80UnhandledError.java b/php/php.editor/src/org/netbeans/modules/php/editor/verification/PHP80UnhandledError.java index b322a87a40b6..8ff179a96ecb 100644 --- a/php/php.editor/src/org/netbeans/modules/php/editor/verification/PHP80UnhandledError.java +++ b/php/php.editor/src/org/netbeans/modules/php/editor/verification/PHP80UnhandledError.java @@ -280,7 +280,7 @@ private void checkNonCapturingCatches(CatchClause node) { private void checkTrailingCommas(TokenSequence ts, List nodes) { if (!nodes.isEmpty()) { try { - nodes.forEach((node) -> { + for (ASTNode node: nodes) { if (CancelSupport.getDefault().isCancelled()) { return; } @@ -292,7 +292,7 @@ private void checkTrailingCommas(TokenSequence ts, List nod && TokenUtilities.textEquals(token.text(), ",")) { // NOI18N createError(node); } - }); + } } finally { nodes.clear(); }