Skip to content

refactor(index): rename isGlobal to isMember #511

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

Merged
merged 1 commit into from
Oct 30, 2017
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
6 changes: 3 additions & 3 deletions src/CompletionProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public function provideCompletion(PhpDocument $doc, Position $pos): CompletionLi
// Collect all definitions that match any of the prefixes
foreach ($this->index->getDefinitions() as $fqn => $def) {
foreach ($prefixes as $prefix) {
if (substr($fqn, 0, strlen($prefix)) === $prefix && !$def->isGlobal) {
if (substr($fqn, 0, strlen($prefix)) === $prefix && $def->isMember) {
$list->items[] = CompletionItem::fromDefinition($def);
}
}
Expand Down Expand Up @@ -243,7 +243,7 @@ public function provideCompletion(PhpDocument $doc, Position $pos): CompletionLi
// Collect all definitions that match any of the prefixes
foreach ($this->index->getDefinitions() as $fqn => $def) {
foreach ($prefixes as $prefix) {
if (substr(strtolower($fqn), 0, strlen($prefix)) === strtolower($prefix) && !$def->isGlobal) {
if (substr(strtolower($fqn), 0, strlen($prefix)) === strtolower($prefix) && $def->isMember) {
$list->items[] = CompletionItem::fromDefinition($def);
}
}
Expand Down Expand Up @@ -316,7 +316,7 @@ public function provideCompletion(PhpDocument $doc, Position $pos): CompletionLi

if (
// Exclude methods, properties etc.
$def->isGlobal
!$def->isMember
&& (
!$prefix
|| (
Expand Down
5 changes: 3 additions & 2 deletions src/Definition.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,13 @@ class Definition
public $extends;

/**
* Only true for classes, interfaces, traits, functions and non-class constants
* False for classes, interfaces, traits, functions and non-class constants
* True for methods, properties and class constants
* This is so methods and properties are not suggested in the global scope
*
* @var bool
*/
public $isGlobal;
public $isMember;

/**
* True if this definition is affected by global namespace fallback (global function or global constant)
Expand Down
2 changes: 1 addition & 1 deletion src/DefinitionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public function createDefinitionFromNode(Node $node, string $fqn = null): Defini
);

// Interfaces, classes, traits, namespaces, functions, and global const elements
$def->isGlobal = (
$def->isMember = !(
$node instanceof PhpParser\ClassLike ||

($node instanceof Node\Statement\NamespaceDefinition && $node->name !== null) ||
Expand Down
10 changes: 5 additions & 5 deletions tests/Validation/cases/WithReturnTypehints.php.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"Fixtures\\Prophecy": {
"fqn": "Fixtures\\Prophecy",
"extends": [],
"isGlobal": true,
"isMember": false,
"roamed": false,
"isStatic": false,
"canBeInstantiated": false,
Expand All @@ -41,7 +41,7 @@
"extends": [
"Fixtures\\Prophecy\\EmptyClass"
],
"isGlobal": true,
"isMember": false,
"roamed": false,
"isStatic": false,
"canBeInstantiated": true,
Expand All @@ -60,7 +60,7 @@
"Fixtures\\Prophecy\\WithReturnTypehints->getSelf()": {
"fqn": "Fixtures\\Prophecy\\WithReturnTypehints->getSelf()",
"extends": [],
"isGlobal": false,
"isMember": true,
"roamed": false,
"isStatic": false,
"canBeInstantiated": false,
Expand All @@ -80,7 +80,7 @@
"Fixtures\\Prophecy\\WithReturnTypehints->getName()": {
"fqn": "Fixtures\\Prophecy\\WithReturnTypehints->getName()",
"extends": [],
"isGlobal": false,
"isMember": true,
"roamed": false,
"isStatic": false,
"canBeInstantiated": false,
Expand All @@ -100,7 +100,7 @@
"Fixtures\\Prophecy\\WithReturnTypehints->getParent()": {
"fqn": "Fixtures\\Prophecy\\WithReturnTypehints->getParent()",
"extends": [],
"isGlobal": false,
"isMember": true,
"roamed": false,
"isStatic": false,
"canBeInstantiated": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"MyNamespace": {
"fqn": "MyNamespace",
"extends": [],
"isGlobal": true,
"isMember": false,
"roamed": false,
"isStatic": false,
"canBeInstantiated": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"A": {
"fqn": "A",
"extends": [],
"isGlobal": true,
"isMember": false,
"roamed": false,
"isStatic": false,
"canBeInstantiated": true,
Expand All @@ -23,7 +23,7 @@
"A->foo": {
"fqn": "A->foo",
"extends": [],
"isGlobal": false,
"isMember": true,
"roamed": false,
"isStatic": false,
"canBeInstantiated": false,
Expand Down
2 changes: 1 addition & 1 deletion tests/Validation/cases/caseStatement1.php.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"MyNamespace": {
"fqn": "MyNamespace",
"extends": [],
"isGlobal": true,
"isMember": false,
"roamed": false,
"isStatic": false,
"canBeInstantiated": false,
Expand Down
6 changes: 3 additions & 3 deletions tests/Validation/cases/classDefinition1.php.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"TestNamespace": {
"fqn": "TestNamespace",
"extends": [],
"isGlobal": true,
"isMember": false,
"roamed": false,
"isStatic": false,
"canBeInstantiated": false,
Expand All @@ -30,7 +30,7 @@
"TestNamespace\\A": {
"fqn": "TestNamespace\\A",
"extends": [],
"isGlobal": true,
"isMember": false,
"roamed": false,
"isStatic": false,
"canBeInstantiated": true,
Expand All @@ -49,7 +49,7 @@
"TestNamespace\\A->a": {
"fqn": "TestNamespace\\A->a",
"extends": [],
"isGlobal": false,
"isMember": true,
"roamed": false,
"isStatic": false,
"canBeInstantiated": false,
Expand Down
8 changes: 4 additions & 4 deletions tests/Validation/cases/classProperty1.php.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"TestNamespace": {
"fqn": "TestNamespace",
"extends": [],
"isGlobal": true,
"isMember": false,
"roamed": false,
"isStatic": false,
"canBeInstantiated": false,
Expand All @@ -30,7 +30,7 @@
"TestNamespace\\TestClass": {
"fqn": "TestNamespace\\TestClass",
"extends": [],
"isGlobal": true,
"isMember": false,
"roamed": false,
"isStatic": false,
"canBeInstantiated": true,
Expand All @@ -49,7 +49,7 @@
"TestNamespace\\TestClass->testProperty": {
"fqn": "TestNamespace\\TestClass->testProperty",
"extends": [],
"isGlobal": false,
"isMember": true,
"roamed": false,
"isStatic": false,
"canBeInstantiated": false,
Expand All @@ -69,7 +69,7 @@
"TestNamespace\\TestClass->testMethod()": {
"fqn": "TestNamespace\\TestClass->testMethod()",
"extends": [],
"isGlobal": false,
"isMember": true,
"roamed": false,
"isStatic": false,
"canBeInstantiated": false,
Expand Down
6 changes: 3 additions & 3 deletions tests/Validation/cases/constants.php.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"MyNamespace": {
"fqn": "MyNamespace",
"extends": [],
"isGlobal": true,
"isMember": false,
"roamed": false,
"isStatic": false,
"canBeInstantiated": false,
Expand All @@ -30,7 +30,7 @@
"MyNamespace\\A": {
"fqn": "MyNamespace\\A",
"extends": [],
"isGlobal": true,
"isMember": false,
"roamed": false,
"isStatic": false,
"canBeInstantiated": true,
Expand All @@ -49,7 +49,7 @@
"MyNamespace\\A::suite()": {
"fqn": "MyNamespace\\A::suite()",
"extends": [],
"isGlobal": false,
"isMember": true,
"roamed": false,
"isStatic": true,
"canBeInstantiated": false,
Expand Down
6 changes: 3 additions & 3 deletions tests/Validation/cases/constants2.php.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"MyNamespace": {
"fqn": "MyNamespace",
"extends": [],
"isGlobal": true,
"isMember": false,
"roamed": false,
"isStatic": false,
"canBeInstantiated": false,
Expand All @@ -30,7 +30,7 @@
"MyNamespace\\A": {
"fqn": "MyNamespace\\A",
"extends": [],
"isGlobal": true,
"isMember": false,
"roamed": false,
"isStatic": false,
"canBeInstantiated": true,
Expand All @@ -49,7 +49,7 @@
"MyNamespace\\A::suite()": {
"fqn": "MyNamespace\\A::suite()",
"extends": [],
"isGlobal": false,
"isMember": true,
"roamed": false,
"isStatic": true,
"canBeInstantiated": false,
Expand Down
6 changes: 3 additions & 3 deletions tests/Validation/cases/constants3.php.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"MyNamespace": {
"fqn": "MyNamespace",
"extends": [],
"isGlobal": true,
"isMember": false,
"roamed": false,
"isStatic": false,
"canBeInstantiated": false,
Expand All @@ -30,7 +30,7 @@
"MyNamespace\\A": {
"fqn": "MyNamespace\\A",
"extends": [],
"isGlobal": true,
"isMember": false,
"roamed": false,
"isStatic": false,
"canBeInstantiated": true,
Expand All @@ -49,7 +49,7 @@
"MyNamespace\\A::suite()": {
"fqn": "MyNamespace\\A::suite()",
"extends": [],
"isGlobal": false,
"isMember": true,
"roamed": false,
"isStatic": true,
"canBeInstantiated": false,
Expand Down
6 changes: 3 additions & 3 deletions tests/Validation/cases/constants4.php.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"MyNamespace": {
"fqn": "MyNamespace",
"extends": [],
"isGlobal": true,
"isMember": false,
"roamed": false,
"isStatic": false,
"canBeInstantiated": false,
Expand All @@ -30,7 +30,7 @@
"MyNamespace\\A": {
"fqn": "MyNamespace\\A",
"extends": [],
"isGlobal": true,
"isMember": false,
"roamed": false,
"isStatic": false,
"canBeInstantiated": true,
Expand All @@ -49,7 +49,7 @@
"MyNamespace\\A->suite()": {
"fqn": "MyNamespace\\A->suite()",
"extends": [],
"isGlobal": false,
"isMember": true,
"roamed": false,
"isStatic": false,
"canBeInstantiated": false,
Expand Down
6 changes: 3 additions & 3 deletions tests/Validation/cases/constants5.php.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"MyNamespace": {
"fqn": "MyNamespace",
"extends": [],
"isGlobal": true,
"isMember": false,
"roamed": false,
"isStatic": false,
"canBeInstantiated": false,
Expand All @@ -27,7 +27,7 @@
"MyNamespace\\Mbstring": {
"fqn": "MyNamespace\\Mbstring",
"extends": [],
"isGlobal": true,
"isMember": false,
"roamed": false,
"isStatic": false,
"canBeInstantiated": true,
Expand All @@ -46,7 +46,7 @@
"MyNamespace\\Mbstring::MB_CASE_FOLD": {
"fqn": "MyNamespace\\Mbstring::MB_CASE_FOLD",
"extends": [],
"isGlobal": false,
"isMember": true,
"roamed": false,
"isStatic": false,
"canBeInstantiated": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"A": {
"fqn": "A",
"extends": [],
"isGlobal": true,
"isMember": false,
"roamed": false,
"isStatic": false,
"canBeInstantiated": false,
Expand All @@ -27,7 +27,7 @@
"A->b()": {
"fqn": "A->b()",
"extends": [],
"isGlobal": false,
"isMember": true,
"roamed": false,
"isStatic": false,
"canBeInstantiated": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"MyNamespace": {
"fqn": "MyNamespace",
"extends": [],
"isGlobal": true,
"isMember": false,
"roamed": false,
"isStatic": false,
"canBeInstantiated": false,
Expand Down
2 changes: 1 addition & 1 deletion tests/Validation/cases/exceptions1.php.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"MyNamespace": {
"fqn": "MyNamespace",
"extends": [],
"isGlobal": true,
"isMember": false,
"roamed": false,
"isStatic": false,
"canBeInstantiated": false,
Expand Down
2 changes: 1 addition & 1 deletion tests/Validation/cases/ifStatement1.php.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"MyNamespace": {
"fqn": "MyNamespace",
"extends": [],
"isGlobal": true,
"isMember": false,
"roamed": false,
"isStatic": false,
"canBeInstantiated": false,
Expand Down
2 changes: 1 addition & 1 deletion tests/Validation/cases/interfaceProperty.php.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"A": {
"fqn": "A",
"extends": [],
"isGlobal": true,
"isMember": false,
"roamed": false,
"isStatic": false,
"canBeInstantiated": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"B": {
"fqn": "B",
"extends": [],
"isGlobal": true,
"isMember": false,
"roamed": false,
"isStatic": false,
"canBeInstantiated": false,
Expand Down
Loading