@@ -52,6 +52,7 @@ pub enum Request {
5252}
5353
5454impl Request {
55+ /// Get request method
5556 pub fn method ( & self ) -> & ' static str {
5657 use Request :: * ;
5758 match self {
@@ -73,6 +74,7 @@ impl Request {
7374 }
7475 }
7576
77+ /// Get request id
7678 pub fn id ( & self ) -> & RequestId {
7779 use Request :: * ;
7880 match self {
@@ -93,6 +95,28 @@ impl Request {
9395 | Custom ( id, _, _) => id,
9496 }
9597 }
98+
99+ /// Get request params
100+ pub fn params ( & self ) -> anyhow:: Result < Value > {
101+ use Request :: * ;
102+ let value = match self {
103+ Shutdown ( _) | WorkspaceBuildTargets ( _) | WorkspaceReload ( _) => return Ok ( Value :: Null ) ,
104+ InitializeBuild ( _, ref params) => serde_json:: to_value ( params) ,
105+ BuildTargetDependencyModules ( _, ref params) => serde_json:: to_value ( params) ,
106+ DebugSessionStart ( _, ref params) => serde_json:: to_value ( params) ,
107+ BuildTargetSources ( _, ref params) => serde_json:: to_value ( params) ,
108+ TextDocumentInverseSources ( _, ref params) => serde_json:: to_value ( params) ,
109+ BuildTargetDependencySources ( _, ref params) => serde_json:: to_value ( params) ,
110+ BuildTargetResources ( _, ref params) => serde_json:: to_value ( params) ,
111+ BuildTargetRun ( _, ref params) => serde_json:: to_value ( params) ,
112+ BuildTargetCompile ( _, ref params) => serde_json:: to_value ( params) ,
113+ BuildTargetTest ( _, ref params) => serde_json:: to_value ( params) ,
114+ BuildTargetCleanCache ( _, ref params) => serde_json:: to_value ( params) ,
115+ Custom ( _, ref params, _) => serde_json:: to_value ( params) ,
116+ } ;
117+
118+ Ok ( value?)
119+ }
96120}
97121
98122impl From < Request > for Message {
0 commit comments