aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_lsp_server/src/conv.rs20
-rw-r--r--crates/ra_lsp_server/src/main_loop/handlers.rs21
2 files changed, 21 insertions, 20 deletions
diff --git a/crates/ra_lsp_server/src/conv.rs b/crates/ra_lsp_server/src/conv.rs
index 59c5e1582..df8ea6e0d 100644
--- a/crates/ra_lsp_server/src/conv.rs
+++ b/crates/ra_lsp_server/src/conv.rs
@@ -1,13 +1,13 @@
1use lsp_types::{ 1use lsp_types::{
2 self, CreateFile, DocumentChangeOperation, DocumentChanges, Documentation, Location, 2 self, CreateFile, DiagnosticSeverity, DocumentChangeOperation, DocumentChanges, Documentation,
3 LocationLink, MarkupContent, MarkupKind, Position, Range, RenameFile, ResourceOp, SymbolKind, 3 Location, LocationLink, MarkupContent, MarkupKind, Position, Range, RenameFile, ResourceOp,
4 TextDocumentEdit, TextDocumentIdentifier, TextDocumentItem, TextDocumentPositionParams, Url, 4 SymbolKind, TextDocumentEdit, TextDocumentIdentifier, TextDocumentItem,
5 VersionedTextDocumentIdentifier, WorkspaceEdit, 5 TextDocumentPositionParams, Url, VersionedTextDocumentIdentifier, WorkspaceEdit,
6}; 6};
7use ra_ide_api::{ 7use ra_ide_api::{
8 translate_offset_with_edit, CompletionItem, CompletionItemKind, FileId, FilePosition, 8 translate_offset_with_edit, CompletionItem, CompletionItemKind, FileId, FilePosition,
9 FileRange, FileSystemEdit, InsertTextFormat, LineCol, LineIndex, NavigationTarget, RangeInfo, 9 FileRange, FileSystemEdit, InsertTextFormat, LineCol, LineIndex, NavigationTarget, RangeInfo,
10 SourceChange, SourceFileEdit, 10 Severity, SourceChange, SourceFileEdit,
11}; 11};
12use ra_syntax::{SyntaxKind, TextRange, TextUnit}; 12use ra_syntax::{SyntaxKind, TextRange, TextUnit};
13use ra_text_edit::{AtomTextEdit, TextEdit}; 13use ra_text_edit::{AtomTextEdit, TextEdit};
@@ -79,6 +79,16 @@ impl Conv for CompletionItemKind {
79 } 79 }
80} 80}
81 81
82impl Conv for Severity {
83 type Output = DiagnosticSeverity;
84 fn conv(self) -> DiagnosticSeverity {
85 match self {
86 Severity::Error => DiagnosticSeverity::Error,
87 Severity::WeakWarning => DiagnosticSeverity::Hint,
88 }
89 }
90}
91
82impl ConvWith for CompletionItem { 92impl ConvWith for CompletionItem {
83 type Ctx = LineIndex; 93 type Ctx = LineIndex;
84 type Output = ::lsp_types::CompletionItem; 94 type Output = ::lsp_types::CompletionItem;
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs
index c2a44ffa0..005ce08b3 100644
--- a/crates/ra_lsp_server/src/main_loop/handlers.rs
+++ b/crates/ra_lsp_server/src/main_loop/handlers.rs
@@ -3,13 +3,13 @@ use std::{fmt::Write as _, io::Write as _};
3use gen_lsp_server::ErrorCode; 3use gen_lsp_server::ErrorCode;
4use lsp_types::{ 4use lsp_types::{
5 CodeAction, CodeActionResponse, CodeLens, Command, CompletionItem, Diagnostic, 5 CodeAction, CodeActionResponse, CodeLens, Command, CompletionItem, Diagnostic,
6 DiagnosticSeverity, DocumentFormattingParams, DocumentHighlight, DocumentSymbol, FoldingRange, 6 DocumentFormattingParams, DocumentHighlight, DocumentSymbol, FoldingRange, FoldingRangeKind,
7 FoldingRangeKind, FoldingRangeParams, Hover, HoverContents, Location, MarkupContent, 7 FoldingRangeParams, Hover, HoverContents, Location, MarkupContent, MarkupKind, Position,
8 MarkupKind, Position, PrepareRenameResponse, Range, RenameParams, SymbolInformation, 8 PrepareRenameResponse, Range, RenameParams, SymbolInformation, TextDocumentIdentifier,
9 TextDocumentIdentifier, TextEdit, WorkspaceEdit, 9 TextEdit, WorkspaceEdit,
10}; 10};
11use ra_ide_api::{ 11use ra_ide_api::{
12 AssistId, Cancelable, FileId, FilePosition, FileRange, FoldKind, Query, RunnableKind, Severity, 12 AssistId, Cancelable, FileId, FilePosition, FileRange, FoldKind, Query, RunnableKind,
13}; 13};
14use ra_prof::profile; 14use ra_prof::profile;
15use ra_syntax::{AstNode, SyntaxKind, TextRange, TextUnit}; 15use ra_syntax::{AstNode, SyntaxKind, TextRange, TextUnit};
@@ -838,7 +838,7 @@ pub fn publish_diagnostics(
838 .into_iter() 838 .into_iter()
839 .map(|d| Diagnostic { 839 .map(|d| Diagnostic {
840 range: d.range.conv_with(&line_index), 840 range: d.range.conv_with(&line_index),
841 severity: Some(to_diagnostic_severity(d.severity)), 841 severity: Some(d.severity.conv()),
842 code: None, 842 code: None,
843 source: Some("rust-analyzer".to_string()), 843 source: Some("rust-analyzer".to_string()),
844 message: d.message, 844 message: d.message,
@@ -871,15 +871,6 @@ fn highlight(world: &WorldSnapshot, file_id: FileId) -> Result<Vec<Decoration>>
871 Ok(res) 871 Ok(res)
872} 872}
873 873
874fn to_diagnostic_severity(severity: Severity) -> DiagnosticSeverity {
875 use ra_ide_api::Severity::*;
876
877 match severity {
878 Error => DiagnosticSeverity::Error,
879 WeakWarning => DiagnosticSeverity::Hint,
880 }
881}
882
883pub fn handle_inlay_hints( 874pub fn handle_inlay_hints(
884 world: WorldSnapshot, 875 world: WorldSnapshot,
885 params: InlayHintsParams, 876 params: InlayHintsParams,