I'm learning LSP and am right now trying to get document symbols. I use Felix Becker PHP language server. No matter what I try I cannot get back the symbols.
I have tried to log what the Language Server receives and here it is (tried to omit sensitive data):
{"id":1,"method":"initialize","params":{"initializationOptions":{},"rootUri":"file:\/\/\/Users\/stef\/Projects\/TestApp","capabilities":{},"rootPath":"\/Users\/stef\/Projects\/TestApp","trace":"verbose","processId":null,"workspaceFolders":[{"uri":"file:\/\/\/Users\/stef\/Projects\/TestApp","name":"TestApp"}]},"jsonrpc":"2.0"}
{"id":2,"method":"initialized","params":{},"jsonrpc":"2.0"}
{"id":3,"method":"textDocument\/didOpen","params":{"textDocument":{"uri":"file:\/\/\/Users\/stef\/Projects\/TestApp\/models\/User.php","languageId":"php","version":1,"text":"<?php\\n\\nnamespace app\\models;\\n\\nuse Yii;\\n\\n\/**\\n * This is the model class for table \"Users\".\\n *\\n * @property integer $id\\n * @property string $User\\n * @property integer $route\\n * @property string $bus\\n * @property string $start\\n * @property string $end\\n * @property string $dept_date\\n * @property string $dept_time\\n * @property integer $customer\\n * @property integer $issued_on\\n * @property string $machine_serial\\n * @property integer $price\\n * @property integer $is_deleted\\n * @property string $OOOPS\\n * @property integer $expired_in\\n * @property integer $created_at\\n * @property integer $created_by\\n * @property integer $updated_at\\n * @property integer $updated_by\\n *\\n * @property PlannedRoutes $deptDate\\n * @property Buses $bus0\\n * @property Customers $customer0\\n * @property Stops $end0\\n * @property POSes $machineSerial\\n * @property Routes $route0\\n * @property Stops $start0\\n *\/\\nclass User extends TenantModel\\n{\\n use \\app\\traits\\Signature;\\n\\n const OOOPS_KOOK = 'BO';\\n const OOOPS_TEMPORARY_KOOK = 'BT';\\n const OOOPS_CANCELLED = 'CA';\\n const OOOPS_CONFIRMED = 'CO';\\n const OOOPS_FOOF_User = 'CT';\\n const OOOPS_FREE = 'FR';\\n \\n public $RWF;\\n public $UGS;\\n public $FIB;\\n public $USD;\\n public $seats; \/\/ total bus seats\\n public $Users; \/\/ sold Users\\n public $bookings; \/\/ valid bookings\\n public $promotion; \/\/ Promotion Users\\n public $staff; \/\/ Staff Users\\n public $location; \/\/ Staff Location\\n public $day; \/\/ User day like Monday\\n public $author; \/\/ Staff who created User\\n public $broute; \/\/ Main Route\\n \\n public $FOOFs; \/\/total FOOFs sold\\n public $crevenue; \/\/total FOOFs Revenue\\n \/**\\n * @inheritdoc\\n *\/\\n ....some sensitive data omitted...}}},"jsonrpc":"2.0"}
{"id":4,"method":"textDocument\/documentSymbol","params":{"textDocument":{"uri":"file:\/\/\/Users\/stef\/Projects\/TestApp\/models\/User.php"}},"jsonrpc":"2.0"}
and here is a logged response from the server
{"method":"window\/logMessage","params"....
{"method":"textDocument\/publishDiagnostics"...
Finally I get
{"result":null,"id":3,"jsonrpc":"2.0"}Content-Type: application/vscode-jsonrpc; charset=utf8
Content-Length: 36
I cannot find why the server is not responding with the symbols. I tried VS Plugin by the same author and It is working fine which means it I mess up somewhere. But can't just figure it out!
Any help is appreciated.
It happened that my JSON RPC payload contained unescaped 0x09 or tab control character. Replacing it with\t
solved the problem