Skip to content

fix: CompletionItem and Diagnostic unset null fields #25

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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
12 changes: 7 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ jobs:
matrix:
include:
- php: '7.4'
os: ubuntu-18.04
os: ubuntu-22.04
- php: '8.0'
os: ubuntu-18.04
os: ubuntu-22.04
- php: '8.1'
os: ubuntu-18.04
os: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '14.15.3' # renovate:keep-up-to-date
node-version: '16.14.2' # renovate:keep-up-to-date
- name: Install npm dependencies
run: npm ci
- name: Setup PHP
Expand All @@ -32,6 +32,8 @@ jobs:
php-version: ${{ matrix.php }}
extensions: ${{ matrix.xdebug }}, ast
tools: composer
- name: Php Lint
uses: michaelw90/[email protected]
- name: Composer Install
run: COMPOSER_ROOT_VERSION=dev-master composer install --prefer-dist --no-interaction
- name: phpcs
Expand All @@ -55,7 +57,7 @@ jobs:
# - name: Setup Node.js
# uses: actions/setup-node@v2
# with:
# node-version: '14.15.3' # renovate:keep-up-to-date
# node-version: '16.14.2' # renovate:keep-up-to-date
# - name: Install npm dependencies
# run: npm ci
# - name: Build VS Code extension
Expand Down
18 changes: 17 additions & 1 deletion src/CompletionItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

namespace LanguageServerProtocol;

class CompletionItem
use JsonSerializable;

class CompletionItem implements JsonSerializable
{
/**
* The label of this completion item. By default
Expand Down Expand Up @@ -245,4 +247,18 @@ public function __construct(
$this->data = $data;
$this->insertTextFormat = $insertTextFormat;
}

/**
* 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/Diagnostic.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

namespace LanguageServerProtocol;

use JsonSerializable;

/**
* Represents a diagnostic, such as a compiler error or warning. Diagnostic objects are only valid in the scope of a
* resource.
*/
class Diagnostic
class Diagnostic implements JsonSerializable
{
/**
* The range at which the message applies.
Expand Down Expand Up @@ -118,4 +120,18 @@ public function __construct(
$this->relatedInformation = $relatedInformation;
$this->data = $data;
}

/**
* 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;
});
}
}
20 changes: 20 additions & 0 deletions src/InlineValueClientCapabilities.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace LanguageServerProtocol;

class InlineValueClientCapabilities
{

/**
* Whether implementation supports dynamic registration for inline value providers.
*
* @var bool|null
*/
public $dynamicRegistration;

public function __construct(
?bool $dynamicRegistration = null
) {
$this->dynamicRegistration = $dynamicRegistration;
}
}
37 changes: 37 additions & 0 deletions src/InlineValueContext.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace LanguageServerProtocol;

/**
* @since 3.17.0
*/
class InlineValueContext
{
/**
* The stack frame (as a DAP Id) where the execution has stopped.
*
* @var int|null
*/
public $frameId;

/**
* The document range where execution has stopped.
* Typically the end position of the range denotes the line where the
* inline values are shown.
*
* @var Range|null
*/
public $stoppedLocation;

/**
* @param int|null $frameId stack frame Id
* @param Range|null $stoppedLocation Range
*/
public function __construct(?int $frameId = null, ?\LanguageServerProtocol\Range $stoppedLocation = null)
{
/** @psalm-suppress PossiblyNullPropertyAssignmentValue */
$this->frameId = $frameId;
/** @psalm-suppress PossiblyNullPropertyAssignmentValue */
$this->stoppedLocation = $stoppedLocation;
}
}
43 changes: 43 additions & 0 deletions src/InlineValueEvaluatableExpression.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace LanguageServerProtocol;

/**
* Provide an inline value through an expression evaluation.
*
* If only a range is specified, the expression will be extracted from the
* underlying document.
*
* An optional expression can be used to override the extracted expression.
*
* @since 3.17.0
*/
class InlineValueEvaluatableExpression
{
/**
* The document range for which the inline value applies.
* The range is used to extract the evaluatable expression from the
* underlying document.
*
* @var Range|null
*/
public $range;

/**
* If specified the expression overrides the extracted expression.
*
* @var string|null
*/
public $expression;

/**
* @param Range|null $range Range
* @param string|null $expression expression
*/
public function __construct(?\LanguageServerProtocol\Range $range = null, ?string $expression = null)
{
/** @psalm-suppress PossiblyNullPropertyAssignmentValue */
$this->range = $range;
$this->expression = $expression;
}
}
37 changes: 37 additions & 0 deletions src/InlineValueText.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace LanguageServerProtocol;

/**
* Provide inline value as text.
*
* @since 3.17.0
*/
class InlineValueText
{
/**
* The document range for which the inline value applies.
*
* @var Range|null
*/
public $range;

/**
* The text of the inline value.
*
* @var string|null
*/
public $text;

/**
* @param Range|null $range Range
* @param string|null $text Text
*/
public function __construct(?\LanguageServerProtocol\Range $range = null, ?string $text = null)
{
/** @psalm-suppress PossiblyNullPropertyAssignmentValue */
$this->range = $range;
/** @psalm-suppress PossiblyNullPropertyAssignmentValue */
$this->text = $text;
}
}
56 changes: 56 additions & 0 deletions src/InlineValueVariableLookup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

namespace LanguageServerProtocol;

/**
* Provide inline value through a variable lookup.
*
* If only a range is specified, the variable name will be extracted from
* the underlying document.
*
* An optional variable name can be used to override the extracted name.
*
* @since 3.17.0
*/
class InlineValueVariableLookup
{
/**
* The document range for which the inline value applies.
* The range is used to extract the variable name from the underlying
* document.
*
* @var Range|null
*/
public $range;

/**
* If specified the name of the variable to look up.
*
* @var string|null
*/
public $variableName;

/**
* How to perform the lookup.
*
* @var bool|null
*/
public $caseSensitiveLookup;

/**
* @param Range|null $range Range
* @param string|null $variableName variableName
* @param bool|null $caseSensitiveLookup caseSensitiveLookup
*/
public function __construct(
?\LanguageServerProtocol\Range $range = null,
?string $variableName = null,
?bool $caseSensitiveLookup = null
) {
/** @psalm-suppress PossiblyNullPropertyAssignmentValue */
$this->range = $range;
$this->variableName = $variableName;
/** @psalm-suppress PossiblyNullPropertyAssignmentValue */
$this->caseSensitiveLookup = $caseSensitiveLookup;
}
}
13 changes: 12 additions & 1 deletion src/TextDocumentClientCapabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,15 @@ class TextDocumentClientCapabilities
*/
public $moniker;

/**
* Capabilities specific to the `textDocument/inlineValue` request.
*
* @since 3.17.0
*
* @var InlineValueClientCapabilities|null
*/
public $inlineValue;

public function __construct(
?\LanguageServerProtocol\TextDocumentSyncClientCapabilities $synchronization = null,
?\LanguageServerProtocol\CompletionClientCapabilities $completion = null,
Expand All @@ -233,7 +242,8 @@ public function __construct(
?\LanguageServerProtocol\LinkedEditingRangeClientCapabilities $linkedEditingRange = null,
?\LanguageServerProtocol\CallHierarchyClientCapabilities $callHierarchy = null,
?\LanguageServerProtocol\SemanticTokensClientCapabilities $semanticTokens = null,
?\LanguageServerProtocol\MonikerClientCapabilities $moniker = null
?\LanguageServerProtocol\MonikerClientCapabilities $moniker = null,
?\LanguageServerProtocol\InlineValueClientCapabilities $inlineValue = null
) {
$this->synchronization = $synchronization;
$this->completion = $completion;
Expand Down Expand Up @@ -261,5 +271,6 @@ public function __construct(
$this->callHierarchy = $callHierarchy;
$this->semanticTokens = $semanticTokens;
$this->moniker = $moniker;
$this->inlineValue = $inlineValue;
}
}
Loading