358: Add support for formatting entire document with rustfmt r=matklad a=aleksanb

Attempting to format a document when rustfmt isn't installed will result
in an error being returned to the frontend. An alternative
implementation would be returning zero replacements.

Part of https://github.com/rust-analyzer/rust-analyzer/issues/160.

Co-authored-by: Aleksander Vognild Burkow <aleksanderburkow@gmail.com>
This commit is contained in:
bors[bot]
2018-12-30 10:16:22 +00:00
11 changed files with 107 additions and 4 deletions

View File

@@ -140,6 +140,9 @@ impl fmt::Debug for AnalysisImpl {
}
impl AnalysisImpl {
pub fn file_text(&self, file_id: FileId) -> Arc<String> {
self.db.file_text(file_id)
}
pub fn file_syntax(&self, file_id: FileId) -> SourceFileNode {
self.db.source_file(file_id)
}

View File

@@ -274,6 +274,9 @@ pub struct Analysis {
}
impl Analysis {
pub fn file_text(&self, file_id: FileId) -> Arc<String> {
self.imp.file_text(file_id)
}
pub fn file_syntax(&self, file_id: FileId) -> SourceFileNode {
self.imp.file_syntax(file_id).clone()
}