LSP:无法获取文档符号

时间:2019-04-14 13:03:26

标签: language-server-protocol php-language-server

我正在学习LSP,现在正在尝试获取文档符号。我使用Felix Becker PHP language server。无论我尝试什么,我都无法找回符号。

我试图记录语言服务器收到的内容,并在此处记录(试图省略敏感数据):

{"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"}

这是服务器记录的响应

  1. 很多{"method":"window\/logMessage","params"....
  2. 很多{"method":"textDocument\/publishDiagnostics"...

最后我得到

{"result":null,"id":3,"jsonrpc":"2.0"}Content-Type: application/vscode-jsonrpc; charset=utf8
Content-Length: 36

我找不到服务器为什么没有响应的符号。我尝试了同一作者的VS Plugin,它工作正常,这意味着我在某个地方搞砸了。但是不能仅仅弄清楚!

感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

发生了我的JSON RPC有效负载包含未转义的0x09或制表符控制字符的情况。将其替换为\t解决了问题