Skip to content

Commit

Permalink
Completion (#165)
Browse files Browse the repository at this point in the history
* Add support for method/property completion

* Move completion fixtures into directory

* Add support for variable suggestions

Refactor logic into CompletionProvider class

* Allow getTypeFromNode() to take Variable nodes

* Use property and constant values

* Fix using @var tag for variables

* Improve completion

* classes
* variables with prefix filtering

* Make FQNs more distinct

* use -> for instance methods/properties
* use ::$ for static properties

* Add tests for static access

* Properly filter completion on empty property

* Fix existing tests

* Add support for static access without prefix

* Fix testFullyQualifiedClass

* Add missing fixtures

* Correct file number in init test

* Only insert backslash if not typed yet

* Completion for keywords and bug fixes

* Correct variable insertion

* Support completion for namespaces

* Use CompletionList

* Always set isIncomplete to true

* Update PHPCodeSniffer

* Remove unused method

* And the call

* Handle case where FQN could not be resolved
  • Loading branch information
felixfbecker authored Nov 30, 2016
1 parent f56b144 commit 10fb3c9
Show file tree
Hide file tree
Showing 38 changed files with 1,341 additions and 91 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ indent_size = 2
[composer.json]
indent_size = 4

[*.md]
[{*.md,fixtures/**}]
trim_trailing_whitespace = false
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
"bin": ["bin/php-language-server.php"],
"require": {
"php": ">=7.0",
"nikic/php-parser": "^3.0.0beta2",
"nikic/php-parser": "dev-master#e52ffc4447e034514339a03b450aab9cd625e37c",
"phpdocumentor/reflection-docblock": "^3.0",
"sabre/event": "^5.0",
"felixfbecker/advanced-json-rpc": "^2.0",
"squizlabs/php_codesniffer" : "3.0.0RC1",
"squizlabs/php_codesniffer" : "3.0.x-dev#e8acf8e029301b0e3ea7e7c9eef0aee914db78bf",
"netresearch/jsonmapper": "^1.0",
"webmozart/path-util": "^2.3",
"webmozart/glob": "^4.1",
Expand Down
3 changes: 3 additions & 0 deletions fixtures/completion/class_const_with_prefix.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

TestClass::TE
9 changes: 9 additions & 0 deletions fixtures/completion/fully_qualified_class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace Whatever;

use TestNamespace\{TestClass, TestInterface};

\TestC

class OtherClass {}
Empty file added fixtures/completion/html.php
Empty file.
1 change: 1 addition & 0 deletions fixtures/completion/html_with_prefix.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<
3 changes: 3 additions & 0 deletions fixtures/completion/keywords.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

cl
5 changes: 5 additions & 0 deletions fixtures/completion/namespace.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

namespace SomeNamespace {}

SomeNa
4 changes: 4 additions & 0 deletions fixtures/completion/property.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php

$obj = new TestClass;
$obj->
4 changes: 4 additions & 0 deletions fixtures/completion/property_with_prefix.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php

$obj = new TestClass;
$obj->t
3 changes: 3 additions & 0 deletions fixtures/completion/static.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

TestClass::
3 changes: 3 additions & 0 deletions fixtures/completion/static_method_with_prefix.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

TestClass::st
3 changes: 3 additions & 0 deletions fixtures/completion/static_property_with_prefix.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

TestClass::$st
9 changes: 9 additions & 0 deletions fixtures/completion/used_class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace Whatever;

use TestNamespace\{TestClass, TestInterface};

TestC

class OtherClass {}
7 changes: 7 additions & 0 deletions fixtures/completion/used_new.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace Whatever;

use TestNamespace\{TestClass, TestInterface};

$obj = new
10 changes: 10 additions & 0 deletions fixtures/completion/variable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

/**
* @param string|null $param A parameter
*/
function test(string $param = null)
{
$var = 123;
$
}
10 changes: 10 additions & 0 deletions fixtures/completion/variable_with_prefix.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

/**
* @param string|null $param A parameter
*/
function test(string $param = null)
{
$var = 123;
$p
}
Loading

0 comments on commit 10fb3c9

Please sign in to comment.