aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorkjeremy <[email protected]>2019-10-29 20:08:36 +0000
committerkjeremy <[email protected]>2019-10-29 20:08:36 +0000
commit3c140050ff469364db88b4f582533937a8a7fe61 (patch)
treecb005285d0936057debeee83e59709ba19220225 /crates
parent542bc18223fdef60c942d0d6ca0dd9be9de2cd91 (diff)
Profile all request handlers
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_lsp_server/src/main_loop/handlers.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs
index 16fb07266..20f9aee13 100644
--- a/crates/ra_lsp_server/src/main_loop/handlers.rs
+++ b/crates/ra_lsp_server/src/main_loop/handlers.rs
@@ -27,6 +27,7 @@ use crate::{
27}; 27};
28 28
29pub fn handle_analyzer_status(world: WorldSnapshot, _: ()) -> Result<String> { 29pub fn handle_analyzer_status(world: WorldSnapshot, _: ()) -> Result<String> {
30 let _p = profile("handle_analyzer_status");
30 let mut buf = world.status(); 31 let mut buf = world.status();
31 writeln!(buf, "\n\nrequests:").unwrap(); 32 writeln!(buf, "\n\nrequests:").unwrap();
32 let requests = world.latest_requests.read(); 33 let requests = world.latest_requests.read();
@@ -38,6 +39,7 @@ pub fn handle_analyzer_status(world: WorldSnapshot, _: ()) -> Result<String> {
38} 39}
39 40
40pub fn handle_syntax_tree(world: WorldSnapshot, params: req::SyntaxTreeParams) -> Result<String> { 41pub fn handle_syntax_tree(world: WorldSnapshot, params: req::SyntaxTreeParams) -> Result<String> {
42 let _p = profile("handle_syntax_tree");
41 let id = params.text_document.try_conv_with(&world)?; 43 let id = params.text_document.try_conv_with(&world)?;
42 let line_index = world.analysis().file_line_index(id)?; 44 let line_index = world.analysis().file_line_index(id)?;
43 let text_range = params.range.map(|p| p.conv_with(&line_index)); 45 let text_range = params.range.map(|p| p.conv_with(&line_index));
@@ -172,6 +174,7 @@ pub fn handle_document_symbol(
172 world: WorldSnapshot, 174 world: WorldSnapshot,
173 params: req::DocumentSymbolParams, 175 params: req::DocumentSymbolParams,
174) -> Result<Option<req::DocumentSymbolResponse>> { 176) -> Result<Option<req::DocumentSymbolResponse>> {
177 let _p = profile("handle_document_symbol");
175 let file_id = params.text_document.try_conv_with(&world)?; 178 let file_id = params.text_document.try_conv_with(&world)?;
176 let line_index = world.analysis().file_line_index(file_id)?; 179 let line_index = world.analysis().file_line_index(file_id)?;
177 180
@@ -210,6 +213,7 @@ pub fn handle_workspace_symbol(
210 world: WorldSnapshot, 213 world: WorldSnapshot,
211 params: req::WorkspaceSymbolParams, 214 params: req::WorkspaceSymbolParams,
212) -> Result<Option<Vec<SymbolInformation>>> { 215) -> Result<Option<Vec<SymbolInformation>>> {
216 let _p = profile("handle_workspace_symbol");
213 let all_symbols = params.query.contains('#'); 217 let all_symbols = params.query.contains('#');
214 let libs = params.query.contains('*'); 218 let libs = params.query.contains('*');
215 let query = { 219 let query = {
@@ -253,6 +257,7 @@ pub fn handle_goto_definition(
253 world: WorldSnapshot, 257 world: WorldSnapshot,
254 params: req::TextDocumentPositionParams, 258 params: req::TextDocumentPositionParams,
255) -> Result<Option<req::GotoDefinitionResponse>> { 259) -> Result<Option<req::GotoDefinitionResponse>> {
260 let _p = profile("handle_goto_definition");
256 let position = params.try_conv_with(&world)?; 261 let position = params.try_conv_with(&world)?;
257 let nav_info = match world.analysis().goto_definition(position)? { 262 let nav_info = match world.analysis().goto_definition(position)? {
258 None => return Ok(None), 263 None => return Ok(None),
@@ -266,6 +271,7 @@ pub fn handle_goto_implementation(
266 world: WorldSnapshot, 271 world: WorldSnapshot,
267 params: req::TextDocumentPositionParams, 272 params: req::TextDocumentPositionParams,
268) -> Result<Option<req::GotoImplementationResponse>> { 273) -> Result<Option<req::GotoImplementationResponse>> {
274 let _p = profile("handle_goto_implementation");
269 let position = params.try_conv_with(&world)?; 275 let position = params.try_conv_with(&world)?;
270 let nav_info = match world.analysis().goto_implementation(position)? { 276 let nav_info = match world.analysis().goto_implementation(position)? {
271 None => return Ok(None), 277 None => return Ok(None),
@@ -279,6 +285,7 @@ pub fn handle_goto_type_definition(
279 world: WorldSnapshot, 285 world: WorldSnapshot,
280 params: req::TextDocumentPositionParams, 286 params: req::TextDocumentPositionParams,
281) -> Result<Option<req::GotoTypeDefinitionResponse>> { 287) -> Result<Option<req::GotoTypeDefinitionResponse>> {
288 let _p = profile("handle_goto_type_definition");
282 let position = params.try_conv_with(&world)?; 289 let position = params.try_conv_with(&world)?;
283 let nav_info = match world.analysis().goto_type_definition(position)? { 290 let nav_info = match world.analysis().goto_type_definition(position)? {
284 None => return Ok(None), 291 None => return Ok(None),
@@ -292,6 +299,7 @@ pub fn handle_parent_module(
292 world: WorldSnapshot, 299 world: WorldSnapshot,
293 params: req::TextDocumentPositionParams, 300 params: req::TextDocumentPositionParams,
294) -> Result<Vec<Location>> { 301) -> Result<Vec<Location>> {
302 let _p = profile("handle_parent_module");
295 let position = params.try_conv_with(&world)?; 303 let position = params.try_conv_with(&world)?;
296 world.analysis().parent_module(position)?.iter().try_conv_with_to_vec(&world) 304 world.analysis().parent_module(position)?.iter().try_conv_with_to_vec(&world)
297} 305}
@@ -300,6 +308,7 @@ pub fn handle_runnables(
300 world: WorldSnapshot, 308 world: WorldSnapshot,
301 params: req::RunnablesParams, 309 params: req::RunnablesParams,
302) -> Result<Vec<req::Runnable>> { 310) -> Result<Vec<req::Runnable>> {
311 let _p = profile("handle_runnables");
303 let file_id = params.text_document.try_conv_with(&world)?; 312 let file_id = params.text_document.try_conv_with(&world)?;
304 let line_index = world.analysis().file_line_index(file_id)?; 313 let line_index = world.analysis().file_line_index(file_id)?;
305 let offset = params.position.map(|it| it.conv_with(&line_index)); 314 let offset = params.position.map(|it| it.conv_with(&line_index));
@@ -341,6 +350,7 @@ pub fn handle_decorations(
341 world: WorldSnapshot, 350 world: WorldSnapshot,
342 params: TextDocumentIdentifier, 351 params: TextDocumentIdentifier,
343) -> Result<Vec<Decoration>> { 352) -> Result<Vec<Decoration>> {
353 let _p = profile("handle_decorations");
344 let file_id = params.try_conv_with(&world)?; 354 let file_id = params.try_conv_with(&world)?;
345 highlight(&world, file_id) 355 highlight(&world, file_id)
346} 356}
@@ -389,6 +399,7 @@ pub fn handle_folding_range(
389 world: WorldSnapshot, 399 world: WorldSnapshot,
390 params: FoldingRangeParams, 400 params: FoldingRangeParams,
391) -> Result<Option<Vec<FoldingRange>>> { 401) -> Result<Option<Vec<FoldingRange>>> {
402 let _p = profile("handle_folding_range");
392 let file_id = params.text_document.try_conv_with(&world)?; 403 let file_id = params.text_document.try_conv_with(&world)?;
393 let folds = world.analysis().folding_ranges(file_id)?; 404 let folds = world.analysis().folding_ranges(file_id)?;
394 let text = world.analysis().file_text(file_id)?; 405 let text = world.analysis().file_text(file_id)?;
@@ -406,6 +417,7 @@ pub fn handle_signature_help(
406 world: WorldSnapshot, 417 world: WorldSnapshot,
407 params: req::TextDocumentPositionParams, 418 params: req::TextDocumentPositionParams,
408) -> Result<Option<req::SignatureHelp>> { 419) -> Result<Option<req::SignatureHelp>> {
420 let _p = profile("handle_signature_help");
409 let position = params.try_conv_with(&world)?; 421 let position = params.try_conv_with(&world)?;
410 if let Some(call_info) = world.analysis().call_info(position)? { 422 if let Some(call_info) = world.analysis().call_info(position)? {
411 let active_parameter = call_info.active_parameter.map(|it| it as i64); 423 let active_parameter = call_info.active_parameter.map(|it| it as i64);
@@ -425,6 +437,7 @@ pub fn handle_hover(
425 world: WorldSnapshot, 437 world: WorldSnapshot,
426 params: req::TextDocumentPositionParams, 438 params: req::TextDocumentPositionParams,
427) -> Result<Option<Hover>> { 439) -> Result<Option<Hover>> {
440 let _p = profile("handle_hover");
428 let position = params.try_conv_with(&world)?; 441 let position = params.try_conv_with(&world)?;
429 let info = match world.analysis().hover(position)? { 442 let info = match world.analysis().hover(position)? {
430 None => return Ok(None), 443 None => return Ok(None),
@@ -523,6 +536,7 @@ pub fn handle_formatting(
523 world: WorldSnapshot, 536 world: WorldSnapshot,
524 params: DocumentFormattingParams, 537 params: DocumentFormattingParams,
525) -> Result<Option<Vec<TextEdit>>> { 538) -> Result<Option<Vec<TextEdit>>> {
539 let _p = profile("handle_formatting");
526 let file_id = params.text_document.try_conv_with(&world)?; 540 let file_id = params.text_document.try_conv_with(&world)?;
527 let file = world.analysis().file_text(file_id)?; 541 let file = world.analysis().file_text(file_id)?;
528 542
@@ -645,6 +659,7 @@ pub fn handle_code_lens(
645 world: WorldSnapshot, 659 world: WorldSnapshot,
646 params: req::CodeLensParams, 660 params: req::CodeLensParams,
647) -> Result<Option<Vec<CodeLens>>> { 661) -> Result<Option<Vec<CodeLens>>> {
662 let _p = profile("handle_code_lens");
648 let file_id = params.text_document.try_conv_with(&world)?; 663 let file_id = params.text_document.try_conv_with(&world)?;
649 let line_index = world.analysis().file_line_index(file_id)?; 664 let line_index = world.analysis().file_line_index(file_id)?;
650 665
@@ -705,6 +720,7 @@ enum CodeLensResolveData {
705} 720}
706 721
707pub fn handle_code_lens_resolve(world: WorldSnapshot, code_lens: CodeLens) -> Result<CodeLens> { 722pub fn handle_code_lens_resolve(world: WorldSnapshot, code_lens: CodeLens) -> Result<CodeLens> {
723 let _p = profile("handle_code_lens_resolve");
708 let data = code_lens.data.unwrap(); 724 let data = code_lens.data.unwrap();
709 let resolve = serde_json::from_value(data)?; 725 let resolve = serde_json::from_value(data)?;
710 match resolve { 726 match resolve {
@@ -776,6 +792,7 @@ pub fn publish_diagnostics(
776 world: &WorldSnapshot, 792 world: &WorldSnapshot,
777 file_id: FileId, 793 file_id: FileId,
778) -> Result<req::PublishDiagnosticsParams> { 794) -> Result<req::PublishDiagnosticsParams> {
795 let _p = profile("publish_diagnostics");
779 let uri = world.file_id_to_uri(file_id)?; 796 let uri = world.file_id_to_uri(file_id)?;
780 let line_index = world.analysis().file_line_index(file_id)?; 797 let line_index = world.analysis().file_line_index(file_id)?;
781 let diagnostics = world 798 let diagnostics = world
@@ -798,6 +815,7 @@ pub fn publish_decorations(
798 world: &WorldSnapshot, 815 world: &WorldSnapshot,
799 file_id: FileId, 816 file_id: FileId,
800) -> Result<req::PublishDecorationsParams> { 817) -> Result<req::PublishDecorationsParams> {
818 let _p = profile("publish_decorations");
801 let uri = world.file_id_to_uri(file_id)?; 819 let uri = world.file_id_to_uri(file_id)?;
802 Ok(req::PublishDecorationsParams { uri, decorations: highlight(&world, file_id)? }) 820 Ok(req::PublishDecorationsParams { uri, decorations: highlight(&world, file_id)? })
803} 821}
@@ -847,6 +865,7 @@ pub fn handle_inlay_hints(
847 world: WorldSnapshot, 865 world: WorldSnapshot,
848 params: InlayHintsParams, 866 params: InlayHintsParams,
849) -> Result<Vec<InlayHint>> { 867) -> Result<Vec<InlayHint>> {
868 let _p = profile("handle_inlay_hints");
850 let file_id = params.text_document.try_conv_with(&world)?; 869 let file_id = params.text_document.try_conv_with(&world)?;
851 let analysis = world.analysis(); 870 let analysis = world.analysis();
852 let line_index = analysis.file_line_index(file_id)?; 871 let line_index = analysis.file_line_index(file_id)?;