aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api/src/lib.rs')
-rw-r--r--crates/ra_ide_api/src/lib.rs28
1 files changed, 10 insertions, 18 deletions
diff --git a/crates/ra_ide_api/src/lib.rs b/crates/ra_ide_api/src/lib.rs
index 0832229fd..b2a1d185b 100644
--- a/crates/ra_ide_api/src/lib.rs
+++ b/crates/ra_ide_api/src/lib.rs
@@ -407,24 +407,16 @@ impl Analysis {
407 self.with_db(|db| typing::on_enter(&db, position)) 407 self.with_db(|db| typing::on_enter(&db, position))
408 } 408 }
409 409
410 /// Returns an edit which should be applied after `=` was typed. Primarily, 410 /// Returns an edit which should be applied after a character was typed.
411 /// this works when adding `let =`. 411 ///
412 // FIXME: use a snippet completion instead of this hack here. 412 /// This is useful for some on-the-fly fixups, like adding `;` to `let =`
413 pub fn on_eq_typed(&self, position: FilePosition) -> Cancelable<Option<SourceChange>> { 413 /// automatically.
414 self.with_db(|db| { 414 pub fn on_char_typed(
415 let parse = db.parse(position.file_id); 415 &self,
416 let file = parse.tree(); 416 position: FilePosition,
417 let edit = typing::on_eq_typed(&file, position.offset)?; 417 char_typed: char,
418 Some(SourceChange::source_file_edit( 418 ) -> Cancelable<Option<SourceChange>> {
419 "add semicolon", 419 self.with_db(|db| typing::on_char_typed(&db, position, char_typed))
420 SourceFileEdit { edit, file_id: position.file_id },
421 ))
422 })
423 }
424
425 /// Returns an edit which should be applied when a dot ('.') is typed on a blank line, indenting the line appropriately.
426 pub fn on_dot_typed(&self, position: FilePosition) -> Cancelable<Option<SourceChange>> {
427 self.with_db(|db| typing::on_dot_typed(&db, position))
428 } 420 }
429 421
430 /// Returns a tree representation of symbols in the file. Useful to draw a 422 /// Returns a tree representation of symbols in the file. Useful to draw a