Commit 4af9c79
committed
fix: resolve the syntax the same way deno_media_type does
A review of the deno_ast removal turned up four ways the resolving had
drifted from `deno_media_type::MediaType::from_path`:
- `.d.mts` and `.d.cts` were given `disallow_ambiguous_jsx_like`, which
`deno_ast` only sets for non-declaration `.mts` and `.cts`. That feeds
the trailing comma written after a single identifier type parameter, so
it would have changed formatter output.
- A file whose whole name is an extension (`.ts`) resolved to javascript,
because `Path::extension` returns nothing for those. Split the file
name on its last dot instead, which is what `deno_media_type` does.
- An extension overwrite containing a dot (`d.ts`) no longer resolved.
Overwrite the extension on the file name so it behaves like
`Path::with_extension` did.
- A declaration file is any file with `.d.` in its name, case sensitively
— not just one whose stem ends in `.d`.
Also restores the percent encoding that was lost along with the `url`
crate, so a diagnostic for a path containing a space or a `#` is still a
valid url, and a relative path falls back to just the file name like it
used to.
`format_program` now returns an error rather than panicking when a
`ProgramInfoProvider` doesn't capture the text info, tokens, or comments.1 parent d632f3b commit 4af9c79
5 files changed
Lines changed: 229 additions & 109 deletions
File tree
- src
- parsing
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
110 | 111 | | |
111 | 112 | | |
112 | 113 | | |
113 | | - | |
114 | | - | |
| 114 | + | |
| 115 | + | |
115 | 116 | | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
116 | 120 | | |
117 | 121 | | |
118 | 122 | | |
| |||
144 | 148 | | |
145 | 149 | | |
146 | 150 | | |
147 | | - | |
148 | | - | |
149 | | - | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
150 | 159 | | |
151 | 160 | | |
152 | 161 | | |
| |||
167 | 176 | | |
168 | 177 | | |
169 | 178 | | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
170 | 188 | | |
171 | 189 | | |
172 | 190 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
0 commit comments