Skip to content

Commit

Permalink
Merge pull request #21 from zobo/fix-signature-help
Browse files Browse the repository at this point in the history
fix: signature help must not send null fields
  • Loading branch information
muglug authored Jun 19, 2022
2 parents 6e82196 + bdc5052 commit ae4c490
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
* text=auto
* text=auto eol=lf

/.gitattributes export-ignore
/.gitignore export-ignore
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/semantic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: 'Semantic Pull Request'

on:
pull_request_target:
types:
- opened
- edited
- synchronize
# pull_request:
# types:
# - opened
# - edited
# - synchronize

jobs:
main:
name: Validate PR Title
runs-on: ubuntu-latest
steps:
- name: semantic-pull-request
uses: amannn/action-semantic-pull-request@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
validateSingleCommit: false
16 changes: 15 additions & 1 deletion src/ParameterInformation.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

namespace LanguageServerProtocol;

use JsonSerializable;

/**
* Represents a parameter of a callable-signature. A parameter can
* have a label and a doc-comment.
*/
class ParameterInformation
class ParameterInformation implements JsonSerializable
{
/**
* The label of this parameter information.
Expand Down Expand Up @@ -42,4 +44,16 @@ public function __construct($label, $documentation = null)
$this->label = $label;
$this->documentation = $documentation;
}

/**
* This is needed because VSCode Does not like nulls
* meaning if a null is sent then this will not compute
*
* @return mixed
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return array_filter(get_object_vars($this));
}
}
18 changes: 17 additions & 1 deletion src/SignatureHelp.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

namespace LanguageServerProtocol;

use JsonSerializable;

/**
* Signature help represents the signature of something
* callable. There can be multiple signature but only one
* active and only one active parameter.
*/
class SignatureHelp
class SignatureHelp implements JsonSerializable
{
/**
* One or more signatures. If no signatures are available the signature help
Expand Down Expand Up @@ -58,4 +60,18 @@ public function __construct(array $signatures = null, $activeSignature = null, i
$this->activeSignature = $activeSignature;
$this->activeParameter = $activeParameter;
}

/**
* This is needed because VSCode Does not like nulls
* meaning if a null is sent then this will not compute
*
* @return mixed
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return array_filter(get_object_vars($this), function ($v) {
return $v !== null;
});
}
}
18 changes: 17 additions & 1 deletion src/SignatureHelpClientCapabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace LanguageServerProtocol;

class SignatureHelpClientCapabilities
use JsonSerializable;

class SignatureHelpClientCapabilities implements JsonSerializable
{
/**
* Whether signature help supports dynamic registration.
Expand Down Expand Up @@ -40,4 +42,18 @@ public function __construct(
$this->signatureInformation = $signatureInformation;
$this->contextSupport = $contextSupport;
}

/**
* This is needed because VSCode Does not like nulls
* meaning if a null is sent then this will not compute
*
* @return mixed
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return array_filter(get_object_vars($this), function ($v) {
return $v !== null;
});
}
}
16 changes: 15 additions & 1 deletion src/SignatureHelpOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

namespace LanguageServerProtocol;

use JsonSerializable;

/**
* Signature help options.
*/
class SignatureHelpOptions
class SignatureHelpOptions implements JsonSerializable
{
/**
* The characters that trigger signature help automatically.
Expand All @@ -21,4 +23,16 @@ public function __construct(array $triggerCharacters = null)
{
$this->triggerCharacters = $triggerCharacters;
}

/**
* This is needed because VSCode Does not like nulls
* meaning if a null is sent then this will not compute
*
* @return mixed
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return array_filter(get_object_vars($this));
}
}
18 changes: 17 additions & 1 deletion src/SignatureInformation.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

namespace LanguageServerProtocol;

use JsonSerializable;

/**
* Represents the signature of something callable. A signature
* can have a label, like a function-name, a doc-comment, and
* a set of parameters.
*/
class SignatureInformation
class SignatureInformation implements JsonSerializable
{
/**
* The label of this signature. Will be shown in
Expand Down Expand Up @@ -63,4 +65,18 @@ public function __construct(
$this->documentation = $documentation;
$this->activeParameter = $activeParameter;
}

/**
* This is needed because VSCode Does not like nulls
* meaning if a null is sent then this will not compute
*
* @return mixed
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return array_filter(get_object_vars($this), function ($v) {
return $v !== null;
});
}
}

0 comments on commit ae4c490

Please # to comment.