File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
lib/Test/LanguageServerTester Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change 1010use Phpactor \LanguageServerProtocol \DidOpenTextDocumentParams ;
1111use Phpactor \LanguageServerProtocol \DidOpenTextDocumentNotification ;
1212use Phpactor \LanguageServer \Test \LanguageServerTester ;
13+ use RuntimeException ;
1314
1415class TextDocumentTester
1516{
17+ /**
18+ * @var array<string,int>
19+ */
20+ private static $ versions = [];
21+
1622 /**
1723 * @var LanguageServerTester
1824 */
@@ -25,15 +31,23 @@ public function __construct(LanguageServerTester $tester)
2531
2632 public function open (string $ url , string $ content ): void
2733 {
34+ self ::$ versions [$ url ] = 1 ;
2835 $ this ->tester ->notifyAndWait (DidOpenTextDocumentNotification::METHOD , new DidOpenTextDocumentParams (
2936 ProtocolFactory::textDocumentItem ($ url , $ content )
3037 ));
3138 }
3239
3340 public function update (string $ uri , string $ newText ): void
3441 {
42+ if (!isset (self ::$ versions [$ uri ])) {
43+ throw new RuntimeException (sprintf (
44+ 'Cannot update document that has not been opened: %s ' ,
45+ $ uri
46+ ));
47+ }
48+ self ::$ versions [$ uri ]++;
3549 $ this ->tester ->notifyAndWait (DidChangeTextDocumentNotification::METHOD , new DidChangeTextDocumentParams (
36- ProtocolFactory::versionedTextDocumentIdentifier ($ uri , 1 ),
50+ ProtocolFactory::versionedTextDocumentIdentifier ($ uri , self :: $ versions [ $ uri ] ),
3751 [
3852 [
3953 'text ' => $ newText
You can’t perform that action at this time.
0 commit comments