aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide/src/lib.rs')
-rw-r--r--crates/ide/src/lib.rs43
1 files changed, 6 insertions, 37 deletions
diff --git a/crates/ide/src/lib.rs b/crates/ide/src/lib.rs
index 4b797f374..e3af6d5bc 100644
--- a/crates/ide/src/lib.rs
+++ b/crates/ide/src/lib.rs
@@ -44,7 +44,7 @@ mod syntax_highlighting;
44mod syntax_tree; 44mod syntax_tree;
45mod typing; 45mod typing;
46 46
47use std::{collections::HashSet, sync::Arc}; 47use std::sync::Arc;
48 48
49use base_db::{ 49use base_db::{
50 salsa::{self, ParallelDatabase}, 50 salsa::{self, ParallelDatabase},
@@ -65,7 +65,7 @@ pub use crate::{
65 completion::{ 65 completion::{
66 CompletionConfig, CompletionItem, CompletionItemKind, CompletionScore, InsertTextFormat, 66 CompletionConfig, CompletionItem, CompletionItemKind, CompletionScore, InsertTextFormat,
67 }, 67 },
68 diagnostics::Severity, 68 diagnostics::{Diagnostic, DiagnosticsConfig, Fix, Severity},
69 display::NavigationTarget, 69 display::NavigationTarget,
70 expand_macro::ExpandedMacro, 70 expand_macro::ExpandedMacro,
71 file_structure::StructureNode, 71 file_structure::StructureNode,
@@ -88,6 +88,7 @@ pub use base_db::{
88pub use hir::{Documentation, Semantics}; 88pub use hir::{Documentation, Semantics};
89pub use ide_db::{ 89pub use ide_db::{
90 change::AnalysisChange, 90 change::AnalysisChange,
91 label::Label,
91 line_index::{LineCol, LineIndex}, 92 line_index::{LineCol, LineIndex},
92 search::SearchScope, 93 search::SearchScope,
93 source_change::{FileSystemEdit, SourceChange, SourceFileEdit}, 94 source_change::{FileSystemEdit, SourceChange, SourceFileEdit},
@@ -99,35 +100,6 @@ pub use text_edit::{Indel, TextEdit};
99 100
100pub type Cancelable<T> = Result<T, Canceled>; 101pub type Cancelable<T> = Result<T, Canceled>;
101 102
102#[derive(Debug)]
103pub struct Diagnostic {
104 pub name: Option<String>,
105 pub message: String,
106 pub range: TextRange,
107 pub severity: Severity,
108 pub fix: Option<Fix>,
109}
110
111#[derive(Debug)]
112pub struct Fix {
113 pub label: String,
114 pub source_change: SourceChange,
115 /// Allows to trigger the fix only when the caret is in the range given
116 pub fix_trigger_range: TextRange,
117}
118
119impl Fix {
120 pub fn new(
121 label: impl Into<String>,
122 source_change: SourceChange,
123 fix_trigger_range: TextRange,
124 ) -> Self {
125 let label = label.into();
126 assert!(label.starts_with(char::is_uppercase) && !label.ends_with('.'));
127 Self { label, source_change, fix_trigger_range }
128 }
129}
130
131/// Info associated with a text range. 103/// Info associated with a text range.
132#[derive(Debug)] 104#[derive(Debug)]
133pub struct RangeInfo<T> { 105pub struct RangeInfo<T> {
@@ -148,7 +120,7 @@ pub struct AnalysisHost {
148} 120}
149 121
150impl AnalysisHost { 122impl AnalysisHost {
151 pub fn new(lru_capacity: Option<usize>) -> Self { 123 pub fn new(lru_capacity: Option<usize>) -> AnalysisHost {
152 AnalysisHost { db: RootDatabase::new(lru_capacity) } 124 AnalysisHost { db: RootDatabase::new(lru_capacity) }
153 } 125 }
154 126
@@ -495,13 +467,10 @@ impl Analysis {
495 /// Computes the set of diagnostics for the given file. 467 /// Computes the set of diagnostics for the given file.
496 pub fn diagnostics( 468 pub fn diagnostics(
497 &self, 469 &self,
470 config: &DiagnosticsConfig,
498 file_id: FileId, 471 file_id: FileId,
499 enable_experimental: bool,
500 disabled_diagnostics: Option<HashSet<String>>,
501 ) -> Cancelable<Vec<Diagnostic>> { 472 ) -> Cancelable<Vec<Diagnostic>> {
502 self.with_db(|db| { 473 self.with_db(|db| diagnostics::diagnostics(db, config, file_id))
503 diagnostics::diagnostics(db, file_id, enable_experimental, disabled_diagnostics)
504 })
505 } 474 }
506 475
507 /// Returns the edit required to rename reference at the position to the new 476 /// Returns the edit required to rename reference at the position to the new