Skip to content

Commit

Permalink
PHP: Fixing cancelability bugs by reverting from a for each loop to a…
Browse files Browse the repository at this point in the history
… normal loop
  • Loading branch information
troizet committed Dec 15, 2023
1 parent c9ae5f8 commit 01ae879
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ public void invoke(PHPRuleContext context, List<Hint> hints) {
"IncorrectNonAbstractMethodHintErrorHintDesc=Non-abstract method \"{0}\" must contain body"
})
private void addIcorrectNonAbstractMethodHints(Set<MethodDeclaration> methodDeclarations, List<Hint> hints, BaseDocument doc) {
methodDeclarations.forEach((methodDeclaration) -> {
for (MethodDeclaration methodDeclaration: methodDeclarations) {
if (CancelSupport.getDefault().isCancelled()) {
return;
}
List<HintFix> fixes = Collections.singletonList(new AddBodyFix(doc, methodDeclaration));
addHint(methodDeclaration, Bundle.IncorrectNonAbstractMethodHintErrorHintDesc(CodeUtils.extractMethodName(methodDeclaration)), hints, fixes);
});
}
}

private void addHint(ASTNode node, String description, List<Hint> hints, List<HintFix> fixes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ private void checkGroupUseTrailingCommas() {
if (ts == null) {
return;
}
lastUseStatementParts.forEach((lastUseStatementPart) -> {
for (SingleUseStatementPart lastUseStatementPart: lastUseStatementParts) {
if (CancelSupport.getDefault().isCancelled()) {
return;
}
Expand All @@ -129,7 +129,7 @@ private void checkGroupUseTrailingCommas() {
createError(lastUseStatementPart);
}
}
});
}
} finally {
document.readUnlock();
lastUseStatementParts.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ private void checkFunctionCallTrailingCommas() {
}

private void checkFunctionCallTrailingCommas(TokenSequence<PHPTokenId> ts) {
nodes.forEach((node) -> {
for (ASTNode node: nodes) {
if (CancelSupport.getDefault().isCancelled()) {
return;
}
Expand All @@ -183,7 +183,7 @@ private void checkFunctionCallTrailingCommas(TokenSequence<PHPTokenId> ts) {
if (!parameters.isEmpty()) {
createError(parameters.get(parameters.size() - 1));
}
});
}
}

@CheckForNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ private void checkNonCapturingCatches(CatchClause node) {
private void checkTrailingCommas(TokenSequence<PHPTokenId> ts, List<ASTNode> nodes) {
if (!nodes.isEmpty()) {
try {
nodes.forEach((node) -> {
for (ASTNode node: nodes) {
if (CancelSupport.getDefault().isCancelled()) {
return;
}
Expand All @@ -292,7 +292,7 @@ private void checkTrailingCommas(TokenSequence<PHPTokenId> ts, List<ASTNode> nod
&& TokenUtilities.textEquals(token.text(), ",")) { // NOI18N
createError(node);
}
});
}
} finally {
nodes.clear();
}
Expand Down

0 comments on commit 01ae879

Please sign in to comment.