Skip to content

Commit f7f95a8

Browse files
TysonAndrefelixfbecker
authored andcommitted
feat: add MarkupContent and TextDocumentSyncOptions (#5)
Fixes #4 Fix typos (detected by codespell, should have already been fixed in specification document) remove unused use statements (detected by Phan)
1 parent fba026c commit f7f95a8

11 files changed

+133
-15
lines changed

src/CompletionItem.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
namespace LanguageServerProtocol;
55

6-
use LanguageServer\Definition;
7-
86
class CompletionItem
97
{
108
/**
@@ -40,7 +38,7 @@ class CompletionItem
4038
public $documentation;
4139

4240
/**
43-
* A string that shoud be used when comparing this item
41+
* A string that should be used when comparing this item
4442
* with other items. When `falsy` the label is used.
4543
*
4644
* @var string|null

src/DocumentHighlightKind.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
abstract class DocumentHighlightKind
99
{
1010
/**
11-
* A textual occurrance.
11+
* A textual occurrence.
1212
*/
1313
const TEXT = 1;
1414

src/Hover.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class Hover
1010
/**
1111
* The hover's content
1212
*
13-
* @var string|MarkedString|string[]|MarkedString[]
13+
* @var string|MarkedString|string[]|MarkedString[]|MarkupContent
1414
*/
1515
public $contents;
1616

src/Location.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
namespace LanguageServerProtocol;
44

5-
use Microsoft\PhpParser;
6-
use Microsoft\PhpParser\Node;
7-
85
/**
96
* Represents a location inside a resource, such as a line inside a text file.
107
*/

src/MarkupContent.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
namespace LanguageServerProtocol;
4+
5+
/**
6+
* A `MarkupContent` literal represents a string value which content is interpreted base on its
7+
* kind flag. Currently the protocol supports `plaintext` and `markdown` as markup kinds.
8+
*
9+
* If the kind is `markdown` then the value can contain fenced code blocks like in GitHub issues.
10+
* See https://help.github.com/articles/creating-and-highlighting-code-blocks/#syntax-highlighting
11+
*
12+
* Here is an example how such a string can be constructed using JavaScript / TypeScript:
13+
* ```ts
14+
* let markdown: MarkdownContent = {
15+
* kind: MarkupKind.Markdown,
16+
* value: [
17+
* '# Header',
18+
* 'Some text',
19+
* '```typescript',
20+
* 'someCode();',
21+
* '```'
22+
* ].join('\n')
23+
* };
24+
* ```
25+
*
26+
* *Please Note* that clients might sanitize the return markdown. A client could decide to
27+
* remove HTML from the markdown to avoid script execution.
28+
*/
29+
class MarkupContent
30+
{
31+
/**
32+
* @var string the type of the Markup (from MarkupKind)
33+
*/
34+
public $kind;
35+
36+
/**
37+
* @var string the content itself
38+
*/
39+
public $value;
40+
41+
/**
42+
* @param string $kind the type of the Markup
43+
* @param string $value the content itself
44+
*/
45+
public function __construct(string $kind = null, string $value = null)
46+
{
47+
$this->kind = $kind;
48+
$this->value = $value;
49+
}
50+
}

src/MarkupKind.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace LanguageServerProtocol;
4+
5+
/**
6+
* Describes the content type that a client supports in various
7+
* result literals like `Hover`, `ParameterInfo` or `CompletionItem`.
8+
*
9+
* Please note that `MarkupKinds` must not start with a `$`. This kinds
10+
* are reserved for internal usage.
11+
*/
12+
abstract class MarkupKind
13+
{
14+
/**
15+
* Plain text is supported as a content format
16+
*/
17+
const PLAINTEXT = 'plaintext';
18+
19+
/**
20+
* Markdown is supported as a content format
21+
*/
22+
const MARKDOWN = 'markdown';
23+
}

src/Range.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
namespace LanguageServerProtocol;
44

5-
use Microsoft\PhpParser;
6-
use Microsoft\PhpParser\Node;
7-
85
/**
96
* A range in a text document expressed as (zero-based) start and end positions.
107
*/

src/SaveOptions.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace LanguageServerProtocol;
4+
5+
/**
6+
* Options controlling what is sent to the server with save notifications.
7+
*/
8+
class SaveOptions
9+
{
10+
/**
11+
* The client is supposed to include the content on save.
12+
* @var bool|null
13+
*/
14+
public $includeText;
15+
}

src/ServerCapabilities.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class ServerCapabilities
77
/**
88
* Defines how text documents are synced.
99
*
10-
* @var int|null
10+
* @var TextDocumentSyncOptions|int|null
1111
*/
1212
public $textDocumentSync;
1313

src/SymbolInformation.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
namespace LanguageServerProtocol;
44

5-
use Microsoft\PhpParser;
6-
use Microsoft\PhpParser\Node;
7-
85
/**
96
* Represents information about programming constructs like variables, classes,
107
* interfaces etc.

0 commit comments

Comments
 (0)