Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP: Fixing cancelability bugs by reverting from a for each loop to a normal loop #6853

Merged
merged 1 commit into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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