(
parsed: &'a Parsed<N>,
trivia: &'a TriviaRanges,
source: &'a str,
options: PyFormatOptions,
)
| 154 | } |
| 155 | |
| 156 | fn format_node<'a, N>( |
| 157 | parsed: &'a Parsed<N>, |
| 158 | trivia: &'a TriviaRanges, |
| 159 | source: &'a str, |
| 160 | options: PyFormatOptions, |
| 161 | ) -> FormatResult<Formatted<PyFormatContext<'a>>> |
| 162 | where |
| 163 | N: AsFormat<PyFormatContext<'a>>, |
| 164 | &'a N: Into<AnyNodeRef<'a>>, |
| 165 | { |
| 166 | let source_code = SourceCode::new(source); |
| 167 | let comments = Comments::from_ast(parsed.syntax(), source_code, trivia); |
| 168 | |
| 169 | let formatted = format!( |
| 170 | PyFormatContext::new(options, source, comments, trivia, parsed.tokens()), |
| 171 | [parsed.syntax().format()] |
| 172 | )?; |
| 173 | formatted |
| 174 | .context() |
| 175 | .comments() |
| 176 | .assert_all_formatted(source_code); |
| 177 | Ok(formatted) |
| 178 | } |
| 179 | |
| 180 | pub fn formatted_file(db: &dyn Db, file: File) -> Result<Option<String>, FormatModuleError> { |
| 181 | let options = db.format_options(file); |
no test coverage detected