]> git.lizzy.rs Git - rust.git/blobdiff - crates/ide/src/lib.rs
Improve completion of cfg attributes
[rust.git] / crates / ide / src / lib.rs
index 98d01f0ced4f80f07131e1764a34d43e425153cb..0693869a208a670e1ff8462b435867e9c0b80f1c 100644 (file)
@@ -39,6 +39,7 @@ macro_rules! eprintln {
 mod move_item;
 mod parent_module;
 mod references;
+mod rename;
 mod fn_references;
 mod runnables;
 mod ssr;
@@ -79,7 +80,8 @@ macro_rules! eprintln {
     markup::Markup,
     move_item::Direction,
     prime_caches::PrimeCachesProgress,
-    references::{rename::RenameError, ReferenceSearchResult},
+    references::ReferenceSearchResult,
+    rename::RenameError,
     runnables::{Runnable, RunnableKind, TestId},
     syntax_highlighting::{
         tags::{Highlight, HlMod, HlMods, HlOperator, HlPunct, HlTag},
@@ -218,6 +220,7 @@ pub fn from_single_file(text: String) -> (Analysis, FileId) {
             cfg_options,
             Env::default(),
             Default::default(),
+            Default::default(),
         );
         change.change_file(file_id, Some(Arc::new(text)));
         change.set_crate_graph(crate_graph);
@@ -406,9 +409,10 @@ pub fn hover(
         &self,
         position: FilePosition,
         links_in_hover: bool,
+        documentation: bool,
         markdown: bool,
     ) -> Cancellable<Option<RangeInfo<HoverResult>>> {
-        self.with_db(|db| hover::hover(db, position, links_in_hover, markdown))
+        self.with_db(|db| hover::hover(db, position, links_in_hover, documentation, markdown))
     }
 
     /// Return URL(s) for the documentation of the symbol under the cursor.
@@ -565,7 +569,6 @@ pub fn assists_with_fixes(
         };
 
         self.with_db(|db| {
-            let ssr_assists = ssr::ssr_assists(db, &resolve, frange);
             let diagnostic_assists = if include_fixes {
                 ide_diagnostics::diagnostics(db, diagnostics_config, &resolve, frange.file_id)
                     .into_iter()
@@ -575,10 +578,12 @@ pub fn assists_with_fixes(
             } else {
                 Vec::new()
             };
+            let ssr_assists = ssr::ssr_assists(db, &resolve, frange);
+            let assists = ide_assists::assists(db, assist_config, resolve, frange);
 
-            let mut res = ide_assists::assists(db, assist_config, resolve, frange);
+            let mut res = diagnostic_assists;
             res.extend(ssr_assists.into_iter());
-            res.extend(diagnostic_assists.into_iter());
+            res.extend(assists.into_iter());
 
             res
         })
@@ -591,14 +596,14 @@ pub fn rename(
         position: FilePosition,
         new_name: &str,
     ) -> Cancellable<Result<SourceChange, RenameError>> {
-        self.with_db(|db| references::rename::rename(db, position, new_name))
+        self.with_db(|db| rename::rename(db, position, new_name))
     }
 
     pub fn prepare_rename(
         &self,
         position: FilePosition,
     ) -> Cancellable<Result<RangeInfo<()>, RenameError>> {
-        self.with_db(|db| references::rename::prepare_rename(db, position))
+        self.with_db(|db| rename::prepare_rename(db, position))
     }
 
     pub fn will_rename_file(
@@ -606,7 +611,7 @@ pub fn will_rename_file(
         file_id: FileId,
         new_name_stem: &str,
     ) -> Cancellable<Option<SourceChange>> {
-        self.with_db(|db| references::rename::will_rename_file(db, file_id, new_name_stem))
+        self.with_db(|db| rename::will_rename_file(db, file_id, new_name_stem))
     }
 
     pub fn structural_search_replace(