Skip to content
This repository was archived by the owner on Dec 1, 2024. It is now read-only.

Commit 680174a

Browse files
committed
Merge branch 'main' into banish-hh-ignore-error-from-codegen
2 parents e83c4e8 + 2339345 commit 680174a

20 files changed

+259
-44
lines changed

codegen/inferred_relationships.hack

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

codegen/syntax/LambdaExpression.hack

Lines changed: 7 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

codegen/syntax/QualifiedName.hack

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

codegen/tokens/NameToken.hack

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Linters/NoEmptyStatementsLinter.hack

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ final class NoEmptyStatementsLinter extends AutoFixingASTLinter {
131131
/**
132132
* Returns whether the given token is an assignment operator.
133133
*
134-
* This list is all the types returned from ExpressionStatement::getOperator
134+
* This list is all the types returned from BinaryExpression::getOperator
135135
* that include "Equal" and are not comparison operators (==, >=, etc.);
136136
*/
137137
private function isAssignmentOperator(Token $op): bool {
@@ -140,9 +140,7 @@ final class NoEmptyStatementsLinter extends AutoFixingASTLinter {
140140
$op is CaratEqualToken ||
141141
$op is DotEqualToken ||
142142
$op is EqualToken ||
143-
$op is GreaterThanEqualToken ||
144143
$op is GreaterThanGreaterThanEqualToken ||
145-
$op is LessThanEqualToken ||
146144
$op is LessThanLessThanEqualToken ||
147145
$op is MinusEqualToken ||
148146
$op is PercentEqualToken ||

src/Linters/UnusedUseClauseLinter.hack

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ final class UnusedUseClauseLinter extends AutoFixingASTLinter {
5555
$as = $name->getText();
5656
} else {
5757
invariant($name is QualifiedName, 'Unhandled name type');
58-
$as = $name->getParts()->getChildrenOfItemsOfType(NameToken::class)
59-
|> (C\lastx($$) as nonnull)->getText();
58+
$as = $name->getParts()->getChildrenOfItemsByType<NameToken>()
59+
|> C\lastx($$)->getText();
6060
}
6161
}
6262
if ($kind is NamespaceToken) {

src/Linters/UseStatementWIthoutKindLinter.hack

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,8 @@ final class UseStatementWithoutKindLinter extends AutoFixingASTLinter {
5555
}
5656
$name = $clause->getName();
5757
if ($name is QualifiedName) {
58-
return (
59-
C\lastx(
60-
$name->getParts()->getChildrenOfItemsOfType(NameToken::class),
61-
) as nonnull
58+
return C\lastx(
59+
$name->getParts()->getChildrenOfItemsByType<NameToken>(),
6260
)->getText();
6361
}
6462
invariant(
@@ -73,10 +71,8 @@ final class UseStatementWithoutKindLinter extends AutoFixingASTLinter {
7371
// We need to look at the full file to figure out if this should be a
7472
// `use type`, or `use namespace`
7573
$used = $this->getUnresolvedReferencedNames();
76-
$used_as_ns = C\any(
77-
$names,
78-
$name ==> C\contains($used['namespaces'], $name),
79-
);
74+
$used_as_ns =
75+
C\any($names, $name ==> C\contains($used['namespaces'], $name));
8076
$used_as_type = C\any($names, $name ==> C\contains($used['types'], $name));
8177

8278
$leading = $node->getClauses()->getFirstTokenx()->getLeadingWhitespace();
@@ -94,8 +90,7 @@ final class UseStatementWithoutKindLinter extends AutoFixingASTLinter {
9490
}
9591

9692
<<__Memoize>>
97-
private function getUnresolvedReferencedNames(
98-
): shape(
93+
private function getUnresolvedReferencedNames(): shape(
9994
'namespaces' => keyset<string>,
10095
'types' => keyset<string>,
10196
'functions' => keyset<string>,

src/Migrations/HSLMigration.hack

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ final class HSLMigration extends BaseMigration {
523523
}
524524
$found_prefix = true;
525525
foreach ($parts as $i => $token) {
526-
if ($token?->getText() === $search[$i]) {
526+
if ($token->getText() === $search[$i]) {
527527
continue;
528528
}
529529
$found_prefix = false;
@@ -569,14 +569,14 @@ final class HSLMigration extends BaseMigration {
569569
}
570570

571571
foreach ($parts as $i => $token) {
572-
if ($i < 2 && $token?->getText() !== $search[$i]) {
572+
if ($i < 2 && $token->getText() !== $search[$i]) {
573573
break;
574574
}
575575

576576
if ($i === 2) {
577577
// we found an HH\Lib\* use statement, add the node and suffix
578578
$nodes[] = $decl;
579-
$ns = HslNamespace::coerce($token?->getText());
579+
$ns = HslNamespace::coerce($token->getText());
580580
if ($ns !== null) {
581581
$suffixes[] = $ns;
582582
}

src/__Private/LintRunConfig.hack

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ final class LintRunConfig {
166166
Vec\map($this->configFile['roots'], $dir ==> $this->projectRoot.'/'.$dir);
167167
}
168168

169-
private function findOverride(string $file_path): ?self::TOverride {
170-
return C\find(
169+
private function findOverrides(string $file_path): vec<self::TOverride> {
170+
return Vec\filter(
171171
$this->configFile['overrides'] ?? vec[],
172172
$override ==> C\find(
173173
$override['patterns'],
@@ -206,8 +206,7 @@ final class LintRunConfig {
206206
$blacklist = $this->configFile['disabledLinters'] ?? vec[];
207207
$autofix_blacklist = $this->configFile['disabledAutoFixes'] ?? vec[];
208208
$no_autofixes = $this->configFile['disableAllAutoFixes'] ?? false;
209-
$override = $this->findOverride($file_path);
210-
if ($override is nonnull) {
209+
foreach ($this->findOverrides($file_path) as $override) {
211210
if ($override['disableAllLinters'] ?? false) {
212211
return shape(
213212
'linters' => keyset[],
@@ -264,7 +263,8 @@ final class LintRunConfig {
264263
$file_path is null ? null : $this->relativeFilePath($file_path)
265264
|> $$ is null
266265
? null
267-
: $this->findOverride($$)['linterConfigs'][$classname] ?? null;
266+
// TODO: This doesn't support multiple overrides.
267+
: C\first($this->findOverrides($$))['linterConfigs'][$classname] ?? null;
268268
if ($global_linter_config is null) {
269269
if ($file_linter_config is null) {
270270
return null;

src/__Private/codegen/CodegenBase.hack

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,9 @@ abstract class CodegenBase {
217217
HHAST\ILambdaBody::class => keyset[
218218
HHAST\IExpression::class,
219219
HHAST\CompoundStatement::class,
220+
// Constants are not wrapped in a name expression on the RHS of `==>`.
221+
HHAST\NameToken::class,
222+
HHAST\QualifiedName::class,
220223
],
221224
HHAST\ILambdaSignature::class => keyset[
222225
HHAST\VariableExpression::class,
@@ -239,8 +242,6 @@ abstract class CodegenBase {
239242
HHAST\ParameterDeclaration::class,
240243
HHAST\PropertyDeclaration::class,
241244
HHAST\LambdaExpression::class,
242-
// HHAST\Php7AnonymousFunction::class : not valid in hack. No attributes
243-
// if not hack
244245
],
245246
HHAST\INameishNode::class => keyset[
246247
HHAST\NameToken::class,

0 commit comments

Comments
 (0)