@@ -124,11 +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 ( ) {
127+ if let Some ( change) = params. content_changes . first ( )
128+ && let Ok ( mut files) = self . open_files . lock ( ) {
129129 files. insert ( uri, change. text . clone ( ) ) ;
130130 }
131- }
132131 }
133132
134133 async fn did_close ( & self , params : DidCloseTextDocumentParams ) {
@@ -143,7 +142,11 @@ impl LanguageServer for Backend {
143142 }
144143
145144 async fn hover ( & self , params : HoverParams ) -> Result < Option < Hover > > {
146- let uri = params. text_document_position_params . text_document . uri . to_string ( ) ;
145+ let uri = params
146+ . text_document_position_params
147+ . text_document
148+ . uri
149+ . to_string ( ) ;
147150 let position = params. text_document_position_params . position ;
148151
149152 let content = if let Ok ( files) = self . open_files . lock ( ) {
@@ -152,34 +155,27 @@ impl LanguageServer for Backend {
152155 None
153156 } ;
154157
155- if let Some ( content) = content {
156- if let Some ( word) = self . get_word_at_position ( & content, position) {
157- if word == "PHPantom" {
158+ if let Some ( content) = content
159+ && let Some ( word) = self . get_word_at_position ( & content, position)
160+ && word == "PHPantom" {
158161 return Ok ( Some ( Hover {
159162 contents : HoverContents :: Scalar ( MarkedString :: String (
160163 "Welcome to PHPantomLSP!" . to_string ( ) ,
161164 ) ) ,
162165 range : None ,
163166 } ) ) ;
164167 }
165- }
166- }
167168
168169 Ok ( None )
169170 }
170171
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- ] ) ) )
172+ async fn completion ( & self , _params : CompletionParams ) -> Result < Option < CompletionResponse > > {
173+ Ok ( Some ( CompletionResponse :: Array ( vec ! [ CompletionItem {
174+ label: "PHPantomLSP" . to_string( ) ,
175+ kind: Some ( CompletionItemKind :: TEXT ) ,
176+ detail: Some ( "PHPantomLSP completion" . to_string( ) ) ,
177+ insert_text: Some ( "PHPantomLSP" . to_string( ) ) ,
178+ ..CompletionItem :: default ( )
179+ } ] ) ) )
184180 }
185181}
0 commit comments