Commit b0d4986
committed
Stop ignoring import clauses in non-unit files
Previously there were concerns over breaking IDE features by formatting
these sections, but after some testing and reconsideration we have
decided that this is a non-issue and it's better to consistently format
all import clauses.
In `program` files (dpr) RAD Studio will sometimes store some metadata in special
comments adjacent to the imports in the `uses` clause. This is
apparently an artifact of a time before Delphi had dproj files, where it
would indicate whether a unit contains a form only using the comment.
Various IDE features depend on 'knowing' what forms are available and
what their names are, including
1. opening the form when you open the unit
2. showing the form in the project overview panel
3. being able to inherit from the form using the IDE dialogs
4. being able to open a frame contained within a form
In modern Delphi, the IDE also reads the dproj to find out about the
contained forms, and in such cases doesn't need the comment at all.
What about when it needs to read the comment? Does the formatting break
that feature? It doesn't appear that it does. `pasfmt` only changes two
things when formatting the uses clause in a dpr file when compared to
what the IDE generates.
1. `{$ifdef}` directives are moved all the way left to the margin, and
2. if a unit name is really long, then the `in '...'` part of the
import is wrapped to the next line.
In our testing all the IDE features continue to work when the dproj
doesn't contain the information about the form and the uses clause is
formatted by `pasfmt`.
A secondary concern to the breakage of form features was the fact that
we would be 'fighting' against the formatting that the IDE generates. On
reconsideration, this doesn't seem like a compelling reason to skip
formatting these sections. It's highly unintuitive that the formatter
skips formatting these sections, and it's undesirable when the user is
writing actual code in the program file, because they will be manually
adding to the import clause for the units they need, and they can't make
the formatter format the changes they are making.
There will inevitably be some level of flip-flopping of formatting, but
if one cares about having all their source files automatically formatted
they should have some other process ensuring that is the case.
Additionally, this flip-flopping is limited to conditional directives
and wrapped `in` expressions, because the style `pasfmt` uses (with
default whitespace configuration) is very similar to the style generated
by the IDE.
In the case of dpk files, we may well make an exception and change our
formatting style for the conditional directives for the `IMPLICITBUILD`
block (see #166), because the file is completely generated and it's
guaranteed to affect every dpk file.
This PR should supersede #200.1 parent 436b9d5 commit b0d4986
File tree
5 files changed
+9
-270
lines changed- core
- src/rules
- front-end/src
5 files changed
+9
-270
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
13 | 16 | | |
14 | 17 | | |
15 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
10 | 14 | | |
11 | 15 | | |
12 | 16 | | |
| |||
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | 6 | | |
8 | 7 | | |
9 | 8 | | |
| |||
12 | 11 | | |
13 | 12 | | |
14 | 13 | | |
15 | | - | |
16 | 14 | | |
17 | 15 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
305 | 305 | | |
306 | 306 | | |
307 | 307 | | |
308 | | - | |
309 | 308 | | |
310 | 309 | | |
311 | 310 | | |
| |||
0 commit comments