Skip to content
This repository has been archived by the owner on Aug 1, 2023. It is now read-only.

Commit

Permalink
Require and support hhast 4.158 (#36)
Browse files Browse the repository at this point in the history
* Require hhvm 4.158
  * The hsl is always built-in.
  * ext_watchman and HH\Facts are always available.
  * varray eq vec and darray eq dict is always true.
  * Parsing for varray and darray remains supported.
* Update CI to 4.158
* Support autoloading with ext_watchman
* Fix lint
* Drop scanning for trait conflict resolutions
  * They have been removed from Hack
  • Loading branch information
lexidor committed Apr 21, 2022
1 parent 95e885c commit c26866a
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 49 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
tests/ export-ignore
bin/ export-ignore
.hhconfig export-ignore
.hhvmconfig.hdf export-ignore
*.hack linguist-language=Hack
2 changes: 1 addition & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
matrix:
os: [ ubuntu ]
hhvm:
- '4.157'
- '4.158'
- latest
- nightly
runs-on: ${{matrix.os}}-latest
Expand Down
3 changes: 3 additions & 0 deletions .hhvmconfig.hdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Autoload {
Query = {"expression": ["allof", ["type", "f"], ["suffix", ["anyof", "hack", "php"]], ["not",["anyof",["dirname",".var"],["dirname",".git"]]]]}
}
7 changes: 3 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@
}
},
"require": {
"hhvm": "^4.157",
"hhvm/hhvm-autoload": "^2.0|^3.0",
"hhvm/hsl": "^4.0",
"hhvm": "^4.158",
"hhvm/type-assert": "^3.2|^4.0",
"hhvm/hhast": "^4.157"
"hhvm/hhast": "^4.158"
},
"require-dev": {
"hhvm/hhvm-autoload": "^2.0|^3.0",
"facebook/fbexpect": "^2.6.1",
"hhvm/hacktest": "^2.0"
},
Expand Down
3 changes: 2 additions & 1 deletion hh_autoload.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
],
"devRoots": [
"tests/"
]
],
"useFactsIfAvailable": true
}
10 changes: 2 additions & 8 deletions src/consumers/scope_from_ast_and_ns.hack
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,10 @@ function scope_from_ast_and_ns(
$ast->getChildrenOfType(HHAST\MethodishDeclaration::class),
$node ==> method_from_ast($context, $node),
),
/* trait use statements = */ Vec\concat(
Vec\map(
/* trait use statements = */ Vec\map(
$ast->getChildrenOfType(HHAST\TraitUse::class),
$node ==> $node->getNames()->getChildrenOfType(HHAST\Node::class),
),
Vec\map(
$ast->getChildrenOfType(HHAST\TraitUseConflictResolution::class),
$node ==> $node->getNames()->getChildrenOfType(HHAST\Node::class),
),
)
)
|> Vec\flatten($$)
|> Vec\map($$, $node ==> typehint_from_ast($context, $node))
|> Vec\filter_nulls($$),
Expand Down
6 changes: 3 additions & 3 deletions src/expression/StaticDarrayExpression.hack
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ namespace Facebook\DefinitionFinder\Expression;

use namespace Facebook\HHAST;

final class StaticDarrayExpression extends Expression<darray<arraykey, mixed>> {
final class StaticDarrayExpression extends Expression<dict<arraykey, mixed>> {
const type TNode = HHAST\DarrayIntrinsicExpression;

<<__Override>>
protected static function matchImpl(
this::TNode $node,
): ?Expression<darray<arraykey, mixed>> {
): ?Expression<dict<arraykey, mixed>> {
$members = $node->getMembers();
$members = $members?->getChildrenOfItemsOfType(HHAST\Node::class) ?? vec[];
$ret = darray[];
$ret = dict[];
foreach ($members as $m) {
$pair = StaticElementInitializerExpression::match($m);
if ($pair === null) {
Expand Down
5 changes: 1 addition & 4 deletions src/expression/StaticListExpression.hack
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ final class StaticListExpression extends Expression<vec<mixed>> {
protected static function matchImpl(
HHAST\NodeList<HHAST\ListItem<HHAST\Node>> $n,
): ?Expression<vec<mixed>> {
$items = Vec\map(
$n->getChildrenOfItems(),
StaticExpression::match<>,
);
$items = Vec\map($n->getChildrenOfItems(), StaticExpression::match<>);
$out = vec[];
foreach ($items as $item) {
if ($item === null) {
Expand Down
6 changes: 3 additions & 3 deletions src/expression/StaticShapeExpression.hack
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ namespace Facebook\DefinitionFinder\Expression;

use namespace Facebook\HHAST;

final class StaticShapeExpression extends Expression<darray<arraykey, mixed>> {
final class StaticShapeExpression extends Expression<dict<arraykey, mixed>> {
const type TNode = HHAST\ShapeExpression;

<<__Override>>
protected static function matchImpl(
this::TNode $node,
): ?Expression<darray<arraykey, mixed>> {
): ?Expression<dict<arraykey, mixed>> {
$members = $node->getFields();
$members = $members?->getChildrenOfItemsOfType(HHAST\Node::class) ?? vec[];
$ret = darray[];
$ret = dict[];
foreach ($members as $m) {
$pair = StaticFieldInitializerExpression::match($m);
if ($pair === null) {
Expand Down
8 changes: 4 additions & 4 deletions src/expression/StaticVarrayExpression.hack
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ namespace Facebook\DefinitionFinder\Expression;

use namespace Facebook\HHAST;

final class StaticVarrayExpression extends Expression<varray<mixed>> {
final class StaticVarrayExpression extends Expression<vec<mixed>> {
const type TNode = HHAST\VarrayIntrinsicExpression;

<<__Override>>
protected static function matchImpl(
this::TNode $node,
): ?Expression<varray<mixed>> {
): ?Expression<vec<mixed>> {
$m = $node->getMembers();
if ($m === null) {
return new self(varray[]);
return new self(vec[]);
}
$values = StaticListExpression::match($m);
if ($values === null) {
return null;
}
$out = varray[];
$out = vec[];
foreach ($values->getValue() as $value) {
$out[] = $value;
}
Expand Down
18 changes: 9 additions & 9 deletions tests/AttributesTest.hack
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,16 @@ class AttributesTest extends \Facebook\HackTest\HackTest {
tuple('INF', \INF),
tuple('+123', 123),
tuple('-123', -123),
tuple('varray[]', varray[]),
tuple('varray[123]', varray[123]),
tuple('varray[123,]', varray[123]),
tuple('varray[123,456]', varray[123, 456]),
tuple('varray[123,456,]', varray[123, 456]),
tuple('varray[]', vec[]),
tuple('varray[123]', vec[123]),
tuple('varray[123,]', vec[123]),
tuple('varray[123,456]', vec[123, 456]),
tuple('varray[123,456,]', vec[123, 456]),
tuple('1.23', 1.23),
tuple('varray[123,456]', varray[123, 456]),
tuple('varray[123 , 456]', varray[123, 456]),
tuple('darray[123 => 456]', darray[123 => 456]),
tuple('shape()', darray[]),
tuple('varray[123,456]', vec[123, 456]),
tuple('varray[123 , 456]', vec[123, 456]),
tuple('darray[123 => 456]', dict[123 => 456]),
tuple('shape()', dict[]),
tuple(
'shape("foo" => "bar", "herp" => 123)',
shape('foo' => 'bar', 'herp' => 123),
Expand Down
12 changes: 0 additions & 12 deletions tests/RelationshipsTest.hack
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,6 @@ class RelationshipsTest extends \Facebook\HackTest\HackTest {
expect($def->getTraitNames())->toBeSame(vec['Herp', 'Derp']);
}

public async function testUseTraitWithConflictResolution(): Awaitable<void> {
$data = "<?hh\n".
"class MyClass {\n".
" use Foo, Bar {\n".
" Foo::herp insteadof Bar;\n".
" Bar::herp as derp;\n".
" };\n".
'}';
$def = (await FileParser::fromDataAsync($data))->getClass('MyClass');
expect($def->getTraitNames())->toBeSame(vec['Foo', 'Bar']);
}

public async function testUsesTraitsInNamespace(): Awaitable<void> {
$data =
"<?hh\n".'namespace MyNamespace;'.'class Foo { use Herp; use Derp; }';
Expand Down

0 comments on commit c26866a

Please sign in to comment.