Skip to content

Commit ae4c490

Browse files
authored
Merge pull request #21 from zobo/fix-signature-help
fix: signature help must not send null fields
2 parents 6e82196 + bdc5052 commit ae4c490

File tree

7 files changed

+107
-6
lines changed

7 files changed

+107
-6
lines changed

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
* text=auto
1+
* text=auto eol=lf
22

33
/.gitattributes export-ignore
44
/.gitignore export-ignore

.github/workflows/semantic.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: 'Semantic Pull Request'
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- opened
7+
- edited
8+
- synchronize
9+
# pull_request:
10+
# types:
11+
# - opened
12+
# - edited
13+
# - synchronize
14+
15+
jobs:
16+
main:
17+
name: Validate PR Title
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: semantic-pull-request
21+
uses: amannn/action-semantic-pull-request@v4
22+
env:
23+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24+
with:
25+
validateSingleCommit: false

src/ParameterInformation.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
namespace LanguageServerProtocol;
44

5+
use JsonSerializable;
6+
57
/**
68
* Represents a parameter of a callable-signature. A parameter can
79
* have a label and a doc-comment.
810
*/
9-
class ParameterInformation
11+
class ParameterInformation implements JsonSerializable
1012
{
1113
/**
1214
* The label of this parameter information.
@@ -42,4 +44,16 @@ public function __construct($label, $documentation = null)
4244
$this->label = $label;
4345
$this->documentation = $documentation;
4446
}
47+
48+
/**
49+
* This is needed because VSCode Does not like nulls
50+
* meaning if a null is sent then this will not compute
51+
*
52+
* @return mixed
53+
*/
54+
#[\ReturnTypeWillChange]
55+
public function jsonSerialize()
56+
{
57+
return array_filter(get_object_vars($this));
58+
}
4559
}

src/SignatureHelp.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
namespace LanguageServerProtocol;
44

5+
use JsonSerializable;
6+
57
/**
68
* Signature help represents the signature of something
79
* callable. There can be multiple signature but only one
810
* active and only one active parameter.
911
*/
10-
class SignatureHelp
12+
class SignatureHelp implements JsonSerializable
1113
{
1214
/**
1315
* One or more signatures. If no signatures are available the signature help
@@ -58,4 +60,18 @@ public function __construct(array $signatures = null, $activeSignature = null, i
5860
$this->activeSignature = $activeSignature;
5961
$this->activeParameter = $activeParameter;
6062
}
63+
64+
/**
65+
* This is needed because VSCode Does not like nulls
66+
* meaning if a null is sent then this will not compute
67+
*
68+
* @return mixed
69+
*/
70+
#[\ReturnTypeWillChange]
71+
public function jsonSerialize()
72+
{
73+
return array_filter(get_object_vars($this), function ($v) {
74+
return $v !== null;
75+
});
76+
}
6177
}

src/SignatureHelpClientCapabilities.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
namespace LanguageServerProtocol;
44

5-
class SignatureHelpClientCapabilities
5+
use JsonSerializable;
6+
7+
class SignatureHelpClientCapabilities implements JsonSerializable
68
{
79
/**
810
* Whether signature help supports dynamic registration.
@@ -40,4 +42,18 @@ public function __construct(
4042
$this->signatureInformation = $signatureInformation;
4143
$this->contextSupport = $contextSupport;
4244
}
45+
46+
/**
47+
* This is needed because VSCode Does not like nulls
48+
* meaning if a null is sent then this will not compute
49+
*
50+
* @return mixed
51+
*/
52+
#[\ReturnTypeWillChange]
53+
public function jsonSerialize()
54+
{
55+
return array_filter(get_object_vars($this), function ($v) {
56+
return $v !== null;
57+
});
58+
}
4359
}

src/SignatureHelpOptions.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
namespace LanguageServerProtocol;
44

5+
use JsonSerializable;
6+
57
/**
68
* Signature help options.
79
*/
8-
class SignatureHelpOptions
10+
class SignatureHelpOptions implements JsonSerializable
911
{
1012
/**
1113
* The characters that trigger signature help automatically.
@@ -21,4 +23,16 @@ public function __construct(array $triggerCharacters = null)
2123
{
2224
$this->triggerCharacters = $triggerCharacters;
2325
}
26+
27+
/**
28+
* This is needed because VSCode Does not like nulls
29+
* meaning if a null is sent then this will not compute
30+
*
31+
* @return mixed
32+
*/
33+
#[\ReturnTypeWillChange]
34+
public function jsonSerialize()
35+
{
36+
return array_filter(get_object_vars($this));
37+
}
2438
}

src/SignatureInformation.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
namespace LanguageServerProtocol;
44

5+
use JsonSerializable;
6+
57
/**
68
* Represents the signature of something callable. A signature
79
* can have a label, like a function-name, a doc-comment, and
810
* a set of parameters.
911
*/
10-
class SignatureInformation
12+
class SignatureInformation implements JsonSerializable
1113
{
1214
/**
1315
* The label of this signature. Will be shown in
@@ -63,4 +65,18 @@ public function __construct(
6365
$this->documentation = $documentation;
6466
$this->activeParameter = $activeParameter;
6567
}
68+
69+
/**
70+
* This is needed because VSCode Does not like nulls
71+
* meaning if a null is sent then this will not compute
72+
*
73+
* @return mixed
74+
*/
75+
#[\ReturnTypeWillChange]
76+
public function jsonSerialize()
77+
{
78+
return array_filter(get_object_vars($this), function ($v) {
79+
return $v !== null;
80+
});
81+
}
6682
}

0 commit comments

Comments
 (0)