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

Improve location reporting for ControlFlowParentheses #25927

Merged
merged 3 commits into from
Sep 24, 2024
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
2 changes: 1 addition & 1 deletion tools/chplcheck/src/rule_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def _check_single(
# addition to the fixits in the result itself)
# add the fixits from the hooks to the fixits from the rule
fixits = self.run_fixit_hooks(context, result) + fixits
return (node, self.name, fixits)
return (result.node, self.name, fixits)

def check(
self, context: chapel.Context, root: chapel.AstNode
Expand Down
4 changes: 2 additions & 2 deletions tools/chplcheck/src/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def ControlFlowParentheses(

# Now, we should warn: there's a node in a conditional or
# if/else, it has parentheses at the top level, but it doesn't need them.
return BasicRuleResult(node, data=subject)
return BasicRuleResult(subject, data=subject)

@driver.fixit(ControlFlowParentheses)
def RemoveControlFlowParentheses(context: Context, result: BasicRuleResult):
Expand All @@ -289,7 +289,7 @@ def RemoveControlFlowParentheses(context: Context, result: BasicRuleResult):
paren_loc = subject.parenth_location()
assert paren_loc

# If parentheeses span multiple lines, don't provide a fixit,
# If parentheses span multiple lines, don't provide a fixit,
# since the indentation would need more thought.
start_line, start_col = paren_loc.start()
end_line, end_col = paren_loc.end()
Expand Down