LSP:无法获取文档符号

问题描述 投票:0回答:1

我正在学习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插件,它工作正常,这意味着我搞砸了某个地方。但不能搞清楚!

任何帮助表示赞赏。

language-server-protocol php-language-server
1个回答
0
投票

碰巧我的JSON RPC有效负载包含未转义的0x09或制表符控制字符。用\t替换它解决了这个问题

© www.soinside.com 2019 - 2024. All rights reserved.