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

Rename some uses of "parenth" to "paren" in language server and compiler #26256

Merged
merged 4 commits into from
Nov 21, 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 frontend/include/chpl/uast/all-location-maps.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ LOCATION_MAP(NamedDecl, DeclName)
LOCATION_MAP(Loop, LoopHeader)
LOCATION_MAP(AstNode, BlockHeader)
LOCATION_MAP(NamedDecl, DeclHeader)
LOCATION_MAP(AstNode, ExprParenth)
LOCATION_MAP(AstNode, ExprParen)
LOCATION_MAP(AstNode, CurlyBraces)
// LOCATION_MAP(AstNode, NamedActual)
// LOCATION_MAP(AstNode, AttributeNamedActual)
Expand Down
10 changes: 5 additions & 5 deletions frontend/lib/parsing/ParserContextImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1865,7 +1865,7 @@ owned<Decl> ParserContext::buildLoopIndexDecl(YYLTYPE location,
/*typeExpression*/ nullptr,
/*initExpression*/ nullptr);
builder->noteDeclNameLocation(var.get(), convLoc);
builder->copyExprParenthLocation(e, var.get());
builder->copyExprParenLocation(e, var.get());
builder->deleteAllLocations(e);
// Delete the location of 'e' because it's about to be deallocated;
// we don't want a new allocation of an AST node to have the same pointer
Expand Down Expand Up @@ -1895,8 +1895,8 @@ owned<Decl> ParserContext::buildLoopIndexDecl(YYLTYPE location,
std::move(elements),
/*typeExpression*/ nullptr,
/*initExpression*/ nullptr);
builder->copyExprParenthLocation(e, td.get());
builder->deleteExprParenthLocation(e);
builder->copyExprParenLocation(e, td.get());
builder->deleteExprParenLocation(e);
// See the comment above for why we delete the location of 'e'.
return td;
} else {
Expand Down Expand Up @@ -1988,8 +1988,8 @@ FnCall* ParserContext::wrapCalledExpressionInNew(YYLTYPE location,
auto newExpr = New::build(builder, convertLocation(location),
toOwned(calledExpr),
management);
builder->copyExprParenthLocation(fnCall, newExpr.get());
builder->deleteExprParenthLocation(fnCall);
builder->copyExprParenLocation(fnCall, newExpr.get());
builder->deleteExprParenLocation(fnCall);
child = std::move(newExpr);

// Extend the location of the call to the left and patch the location.
Expand Down
12 changes: 6 additions & 6 deletions frontend/lib/parsing/bison-chpl-lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8524,7 +8524,7 @@ YYLTYPE yylloc = yyloc_default;
case 363: /* fn_decl_receiver_expr: TLP expr TRP */
#line 2561 "chpl.ypp"
{
BUILDER->tryNoteExprParenthLocation((yyvsp[-1].expr), LOC((yyloc)));
BUILDER->tryNoteExprParenLocation((yyvsp[-1].expr), LOC((yyloc)));
(yyval.expr) = (yyvsp[-1].expr);
}
#line 8531 "bison-chpl-lib.cpp"
Expand Down Expand Up @@ -9940,7 +9940,7 @@ YYLTYPE yylloc = yyloc_default;
case 619: /* new_expr: TNEW TOWNED TLP expr TRP TLP opt_actual_ls TRP */
#line 3348 "chpl.ypp"
{
BUILDER->tryNoteExprParenthLocation((yyvsp[-4].expr), LOC2((yylsp[-5]), (yylsp[-3])));
BUILDER->tryNoteExprParenLocation((yyvsp[-4].expr), LOC2((yylsp[-5]), (yylsp[-3])));
AstList actuals;
std::vector<UniqueString> actualNames;
context->consumeNamedActuals((yyvsp[-1].maybeNamedActualList), actuals, actualNames);
Expand All @@ -9957,7 +9957,7 @@ YYLTYPE yylloc = yyloc_default;
case 620: /* new_expr: TNEW TSHARED TLP expr TRP TLP opt_actual_ls TRP */
#line 3361 "chpl.ypp"
{
BUILDER->tryNoteExprParenthLocation((yyvsp[-4].expr), LOC2((yylsp[-5]), (yylsp[-3])));
BUILDER->tryNoteExprParenLocation((yyvsp[-4].expr), LOC2((yylsp[-5]), (yylsp[-3])));
AstList actuals;
std::vector<UniqueString> actualNames;
context->consumeNamedActuals((yyvsp[-1].maybeNamedActualList), actuals, actualNames);
Expand All @@ -9974,7 +9974,7 @@ YYLTYPE yylloc = yyloc_default;
case 621: /* new_expr: TNEW TOWNED TLP expr TRP TLP opt_actual_ls TRP TQUESTION */
#line 3374 "chpl.ypp"
{
BUILDER->tryNoteExprParenthLocation((yyvsp[-5].expr), LOC2((yylsp[-6]), (yylsp[-4])));
BUILDER->tryNoteExprParenLocation((yyvsp[-5].expr), LOC2((yylsp[-6]), (yylsp[-4])));
AstList actuals;
std::vector<UniqueString> actualNames;
context->consumeNamedActuals((yyvsp[-2].maybeNamedActualList), actuals, actualNames);
Expand All @@ -9992,7 +9992,7 @@ YYLTYPE yylloc = yyloc_default;
case 622: /* new_expr: TNEW TSHARED TLP expr TRP TLP opt_actual_ls TRP TQUESTION */
#line 3388 "chpl.ypp"
{
BUILDER->tryNoteExprParenthLocation((yyvsp[-5].expr), LOC2((yylsp[-6]), (yylsp[-4])));
BUILDER->tryNoteExprParenLocation((yyvsp[-5].expr), LOC2((yylsp[-6]), (yylsp[-4])));
AstList actuals;
std::vector<UniqueString> actualNames;
context->consumeNamedActuals((yyvsp[-2].maybeNamedActualList), actuals, actualNames);
Expand Down Expand Up @@ -10237,7 +10237,7 @@ YYLTYPE yylloc = yyloc_default;
#line 3597 "chpl.ypp"
{
// Use 'tryNote' here in case an expression like ((x)) comes along.
BUILDER->tryNoteExprParenthLocation((yyvsp[-1].expr), LOC((yyloc)));
BUILDER->tryNoteExprParenLocation((yyvsp[-1].expr), LOC((yyloc)));
(yyval.expr) = (yyvsp[-1].expr);
}
#line 10244 "bison-chpl-lib.cpp"
Expand Down
12 changes: 6 additions & 6 deletions frontend/lib/parsing/chpl.ypp
Original file line number Diff line number Diff line change
Expand Up @@ -2559,7 +2559,7 @@ fn_decl_receiver_expr:
ident_expr
| TLP expr TRP
{
BUILDER->tryNoteExprParenthLocation($2, LOC(@$));
BUILDER->tryNoteExprParenLocation($2, LOC(@$));
$$ = $2;
}
;
Expand Down Expand Up @@ -3346,7 +3346,7 @@ new_expr:
see if we can remove them. */
| TNEW TOWNED TLP expr TRP TLP opt_actual_ls TRP %prec TNOELSE
{
BUILDER->tryNoteExprParenthLocation($4, LOC2(@3, @5));
BUILDER->tryNoteExprParenLocation($4, LOC2(@3, @5));
AstList actuals;
std::vector<UniqueString> actualNames;
context->consumeNamedActuals($7, actuals, actualNames);
Expand All @@ -3359,7 +3359,7 @@ new_expr:
}
| TNEW TSHARED TLP expr TRP TLP opt_actual_ls TRP %prec TNOELSE
{
BUILDER->tryNoteExprParenthLocation($4, LOC2(@3, @5));
BUILDER->tryNoteExprParenLocation($4, LOC2(@3, @5));
AstList actuals;
std::vector<UniqueString> actualNames;
context->consumeNamedActuals($7, actuals, actualNames);
Expand All @@ -3372,7 +3372,7 @@ new_expr:
}
| TNEW TOWNED TLP expr TRP TLP opt_actual_ls TRP TQUESTION
{
BUILDER->tryNoteExprParenthLocation($4, LOC2(@3, @5));
BUILDER->tryNoteExprParenLocation($4, LOC2(@3, @5));
AstList actuals;
std::vector<UniqueString> actualNames;
context->consumeNamedActuals($7, actuals, actualNames);
Expand All @@ -3386,7 +3386,7 @@ new_expr:
}
| TNEW TSHARED TLP expr TRP TLP opt_actual_ls TRP TQUESTION
{
BUILDER->tryNoteExprParenthLocation($4, LOC2(@3, @5));
BUILDER->tryNoteExprParenLocation($4, LOC2(@3, @5));
AstList actuals;
std::vector<UniqueString> actualNames;
context->consumeNamedActuals($7, actuals, actualNames);
Expand Down Expand Up @@ -3596,7 +3596,7 @@ parenthesized_expr:
TLP opt_try_expr TRP
{
// Use 'tryNote' here in case an expression like ((x)) comes along.
BUILDER->tryNoteExprParenthLocation($2, LOC(@$));
BUILDER->tryNoteExprParenLocation($2, LOC(@$));
$$ = $2;
}
| TLP tuple_component TCOMMA TRP
Expand Down
2 changes: 1 addition & 1 deletion frontend/lib/uast/post-parse-checks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ static void collectEqualPrecedenceOpsWithoutParens(Context* context,
if (auto childOp = child->toOpCall()) {
if (childOp->numActuals() == 2 && binOpPrecedence(childOp->op()) == prec) {
// The child only counts as a 'problem' if it's not parenthesized.
if (parsing::locateExprParenthWithAst(context, childOp).line() == -1) {
if (parsing::locateExprParenWithAst(context, childOp).line() == -1) {
collectEqualPrecedenceOpsWithoutParens(context, childOp, prec, ops, operands);
return;
}
Expand Down
4 changes: 2 additions & 2 deletions tools/chapel-py/src/method-tables/uast-methods.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ CLASS_BEGIN(AstNode)
std::optional<chpl::Location>,
auto loc = chpl::parsing::locateCurlyBracesWithAst(context, node);
return getValidLocation(loc))
PLAIN_GETTER(AstNode, parenth_location, "Get the Location of the parentheses of this AstNode node",
PLAIN_GETTER(AstNode, paren_location, "Get the Location of the parentheses of this AstNode node",
std::optional<chpl::Location>,
auto loc = chpl::parsing::locateExprParenthWithAst(context, node);
auto loc = chpl::parsing::locateExprParenWithAst(context, node);
return getValidLocation(loc))
CLASS_END(AstNode)

Expand Down
4 changes: 2 additions & 2 deletions tools/chpl-language-server/src/symbol_signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ def _fncall_to_string(call: chapel.FnCall) -> List[Component]:

comps.extend(_wrap_in(call_args, (openbr, closebr)))

comps = _wrap_in(comps, ("(", ")")) if call.parenth_location() else comps
comps = _wrap_in(comps, ("(", ")")) if call.paren_location() else comps
return comps


Expand Down Expand Up @@ -418,7 +418,7 @@ def is_postfix(op: str) -> bool:
comps.extend(_node_to_string(call.actual(0)))
comps.append(_wrap_str(bop_to_string(call.op())))
comps.extend(_node_to_string(call.actual(1)))
comps = _wrap_in(comps, ("(", ")")) if call.parenth_location() else comps
comps = _wrap_in(comps, ("(", ")")) if call.paren_location() else comps
return comps


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 @@ -292,7 +292,7 @@ def ControlFlowParentheses(
return True

# No parentheses to speak of
paren_loc = subject.parenth_location()
paren_loc = subject.paren_location()
if paren_loc is None:
return True

Expand All @@ -305,7 +305,7 @@ def RemoveControlFlowParentheses(context: Context, result: BasicRuleResult):
# Since we're here, these should already be non-None.
subject = result.data
assert subject
paren_loc = subject.parenth_location()
paren_loc = subject.paren_location()
assert paren_loc

# If parentheses span multiple lines, don't provide a fixit,
Expand Down