@@ -124,10 +124,10 @@ impl LanguageServer for Backend {
124124 async fn did_change ( & self , params : DidChangeTextDocumentParams ) {
125125 let uri = params. text_document . uri . to_string ( ) ;
126126
127- if let Some ( change) = params. content_changes . first ( ) {
128- if let Ok ( mut files) = self . open_files . lock ( ) {
129- files . insert ( uri , change . text . clone ( ) ) ;
130- }
127+ if let Some ( change) = params. content_changes . first ( )
128+ && let Ok ( mut files) = self . open_files . lock ( )
129+ {
130+ files . insert ( uri , change . text . clone ( ) ) ;
131131 }
132132 }
133133
@@ -143,7 +143,11 @@ impl LanguageServer for Backend {
143143 }
144144
145145 async fn hover ( & self , params : HoverParams ) -> Result < Option < Hover > > {
146- let uri = params. text_document_position_params . text_document . uri . to_string ( ) ;
146+ let uri = params
147+ . text_document_position_params
148+ . text_document
149+ . uri
150+ . to_string ( ) ;
147151 let position = params. text_document_position_params . position ;
148152
149153 let content = if let Ok ( files) = self . open_files . lock ( ) {
@@ -152,34 +156,28 @@ impl LanguageServer for Backend {
152156 None
153157 } ;
154158
155- if let Some ( content) = content {
156- if let Some ( word) = self . get_word_at_position ( & content, position) {
157- if word == "PHPantom" {
158- return Ok ( Some ( Hover {
159- contents : HoverContents :: Scalar ( MarkedString :: String (
160- "Welcome to PHPantomLSP!" . to_string ( ) ,
161- ) ) ,
162- range : None ,
163- } ) ) ;
164- }
165- }
159+ if let Some ( content) = content
160+ && let Some ( word) = self . get_word_at_position ( & content, position)
161+ && word == "PHPantom"
162+ {
163+ return Ok ( Some ( Hover {
164+ contents : HoverContents :: Scalar ( MarkedString :: String (
165+ "Welcome to PHPantomLSP!" . to_string ( ) ,
166+ ) ) ,
167+ range : None ,
168+ } ) ) ;
166169 }
167170
168171 Ok ( None )
169172 }
170173
171- async fn completion (
172- & self ,
173- _params : CompletionParams ,
174- ) -> Result < Option < CompletionResponse > > {
175- Ok ( Some ( CompletionResponse :: Array ( vec ! [
176- CompletionItem {
177- label: "PHPantomLSP" . to_string( ) ,
178- kind: Some ( CompletionItemKind :: TEXT ) ,
179- detail: Some ( "PHPantomLSP completion" . to_string( ) ) ,
180- insert_text: Some ( "PHPantomLSP" . to_string( ) ) ,
181- ..CompletionItem :: default ( )
182- } ,
183- ] ) ) )
174+ async fn completion ( & self , _params : CompletionParams ) -> Result < Option < CompletionResponse > > {
175+ Ok ( Some ( CompletionResponse :: Array ( vec ! [ CompletionItem {
176+ label: "PHPantomLSP" . to_string( ) ,
177+ kind: Some ( CompletionItemKind :: TEXT ) ,
178+ detail: Some ( "PHPantomLSP completion" . to_string( ) ) ,
179+ insert_text: Some ( "PHPantomLSP" . to_string( ) ) ,
180+ ..CompletionItem :: default ( )
181+ } ] ) ) )
184182 }
185183}
0 commit comments