Skip to content

Commit 31a2a67

Browse files
committed
Add ArrayValue to searchForAutocompleting N1ebieski#7
1 parent f23df4b commit 31a2a67

File tree

6 files changed

+17
-22
lines changed

6 files changed

+17
-22
lines changed

app/Contexts/AbstractContext.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,19 @@
22

33
namespace App\Contexts;
44

5-
use App\Contexts\Contracts\PossibleAutocompleting;
65
use Illuminate\Support\Arr;
76
use Microsoft\PhpParser\Range;
87

98
abstract class AbstractContext
109
{
1110
public array $children = [];
1211

12+
/**
13+
* Whether this context can be found as last result
14+
* in findAutocompleting method
15+
*/
16+
public bool $findable = false;
17+
1318
public bool $autocompleting = false;
1419

1520
protected array $freshObject;
@@ -62,7 +67,7 @@ public function findAutocompleting(?AbstractContext $context = null)
6267

6368
protected function searchForAutocompleting(AbstractContext $context, $checkCurrent = false)
6469
{
65-
if ($checkCurrent && $context->autocompleting && $context instanceof PossibleAutocompleting) {
70+
if ($checkCurrent && $context->autocompleting && $context->findable) {
6671
return $context;
6772
}
6873

app/Contexts/ArrayValue.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
namespace App\Contexts;
44

5-
use App\Contexts\Contracts\PossibleAutocompleting;
6-
7-
class ArrayValue extends AbstractContext implements PossibleAutocompleting
5+
class ArrayValue extends AbstractContext
86
{
97
public function type(): string
108
{

app/Contexts/Contracts/PossibleAutocompleting.php

Lines changed: 0 additions & 10 deletions
This file was deleted.

app/Contexts/MethodCall.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
namespace App\Contexts;
44

5-
use App\Contexts\Contracts\PossibleAutocompleting;
6-
7-
class MethodCall extends AbstractContext implements PossibleAutocompleting
5+
class MethodCall extends AbstractContext
86
{
7+
public bool $findable = true;
8+
99
public ?string $methodName = null;
1010

1111
public ?string $className = null;

app/Contexts/ObjectValue.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
namespace App\Contexts;
44

5-
use App\Contexts\Contracts\PossibleAutocompleting;
6-
7-
class ObjectValue extends AbstractContext implements PossibleAutocompleting
5+
class ObjectValue extends AbstractContext
86
{
7+
public bool $findable = true;
8+
99
public ?string $className = null;
1010

1111
public Arguments $arguments;

app/Parsers/ArrayCreationExpressionParser.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,11 @@ public function parse(ArrayCreationExpression $node)
3535
// then we need to ignore autocompleting for ArrayValue because
3636
// priority is given to App\Contexts\MethodCall
3737
if (!$this->isParentNode($node, CallExpression::class)) {
38-
$this->context->autocompleting = $node->closeParenOrBracket instanceof MissingToken;
38+
$this->context->findable = true;
3939
}
4040

41+
$this->context->autocompleting = $node->closeParenOrBracket instanceof MissingToken;
42+
4143
return $this->context;
4244
}
4345

0 commit comments

Comments
 (0)