|
gn: beginnings of format command
[
This was broken into pieces and improved in other CLS.
]
The main change here is to restructure the ParseNode tree to include
comments. Comments are not included in the tree as normal nodes, but
instead attached subordinate to other |ParseNode|s. This is useful
for two reasons:
- it means neither the evaluator nor the main code of the parser need
to get more complicated, as they do not need to constantly consider
comments.
- it confers additional information about the relative location of
of the comments to their surrounding code when (in the future)
outputting the formatted code.
Comments are added in relation to the node they're attached to as
before, after, or suffix. This is so that formatting can keep them
attached to the correct thing when things are reflowed.
Also added here is the boilerplate and the early part of the actual
format command. It's incomplete, but it should be a relatively simple
tree walk once comments are preserved and attached, assuming everyone
can agree on what actual formatting rules we want.
R=brettw@chromium.org
BUG= 348474
|
Unified diffs |
Side-by-side diffs |
Delta from patch set |
Stats (+590 lines, -53 lines) |
Patch |
 |
M |
tools/gn/BUILD.gn
|
View
|
1
2
3
4
|
2 chunks |
+2 lines, -0 lines |
0 comments
|
Download
|
 |
M |
tools/gn/c_include_iterator.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
|
1 chunk |
+6 lines, -3 lines |
0 comments
|
Download
|
 |
A |
tools/gn/command_format.cc
|
View
|
1
2
3
4
5
6
7
8
|
1 chunk |
+158 lines, -0 lines |
0 comments
|
Download
|
 |
A |
tools/gn/command_format_unittest.cc
|
View
|
1
2
3
4
5
|
1 chunk |
+28 lines, -0 lines |
0 comments
|
Download
|
 |
M |
tools/gn/commands.h
|
View
|
|
1 chunk |
+5 lines, -0 lines |
0 comments
|
Download
|
 |
M |
tools/gn/commands.cc
|
View
|
|
1 chunk |
+1 line, -0 lines |
0 comments
|
Download
|
 |
A |
tools/gn/format_test_data/001.gn
|
View
|
1
2
3
|
1 chunk |
+6 lines, -0 lines |
0 comments
|
Download
|
 |
A |
tools/gn/format_test_data/001.golden
|
View
|
|
1 chunk |
+6 lines, -0 lines |
0 comments
|
Download
|
 |
A |
tools/gn/format_test_data/002.gn
|
View
|
1
2
3
4
|
1 chunk |
+10 lines, -0 lines |
0 comments
|
Download
|
 |
A |
tools/gn/format_test_data/002.golden
|
View
|
1
2
3
4
|
1 chunk |
+8 lines, -0 lines |
0 comments
|
Download
|
 |
A |
tools/gn/format_test_data/003.gn
|
View
|
1
2
3
4
5
|
1 chunk |
+10 lines, -0 lines |
0 comments
|
Download
|
 |
A |
tools/gn/format_test_data/003.golden
|
View
|
1
2
3
4
5
|
1 chunk |
+11 lines, -0 lines |
0 comments
|
Download
|
 |
M |
tools/gn/gn.gyp
|
View
|
1
2
3
4
|
2 chunks |
+2 lines, -0 lines |
0 comments
|
Download
|
 |
M |
tools/gn/header_checker.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
|
1 chunk |
+8 lines, -5 lines |
0 comments
|
Download
|
 |
M |
tools/gn/location.h
|
View
|
1
2
3
4
5
6
7
8
9
10
|
2 chunks |
+3 lines, -1 line |
0 comments
|
Download
|
 |
M |
tools/gn/location.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
|
1 chunk |
+6 lines, -3 lines |
0 comments
|
Download
|
 |
M |
tools/gn/parse_tree.h
|
View
|
1
2
3
4
5
6
7
|
2 chunks |
+40 lines, -0 lines |
0 comments
|
Download
|
 |
M |
tools/gn/parse_tree.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
|
11 chunks |
+34 lines, -4 lines |
0 comments
|
Download
|
 |
M |
tools/gn/parse_tree_unittest.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
|
1 chunk |
+2 lines, -2 lines |
0 comments
|
Download
|
 |
M |
tools/gn/parser.h
|
View
|
1
2
3
4
5
6
7
8
9
10
|
2 chunks |
+14 lines, -2 lines |
0 comments
|
Download
|
 |
M |
tools/gn/parser.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
11
|
5 chunks |
+120 lines, -4 lines |
0 comments
|
Download
|
 |
M |
tools/gn/parser_unittest.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
11
|
1 chunk |
+45 lines, -0 lines |
0 comments
|
Download
|
 |
M |
tools/gn/scope_unittest.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
|
3 chunks |
+3 lines, -3 lines |
0 comments
|
Download
|
 |
M |
tools/gn/string_utils.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
|
1 chunk |
+7 lines, -5 lines |
0 comments
|
Download
|
 |
M |
tools/gn/token.h
|
View
|
1
2
3
4
5
6
7
8
9
10
|
2 chunks |
+11 lines, -6 lines |
0 comments
|
Download
|
 |
M |
tools/gn/tokenizer.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
|
6 chunks |
+20 lines, -11 lines |
0 comments
|
Download
|
 |
M |
tools/gn/tokenizer_unittest.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
|
2 chunks |
+24 lines, -4 lines |
0 comments
|
Download
|
Total messages: 1 (1 generated)
|