Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(645)

Issue 588813002: gn: beginnings of format command (Closed)

Created:
6 years, 3 months ago by scottmg
Modified:
6 years, 3 months ago
Reviewers:
brettw
CC:
chromium-reviews, tfarina
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Project:
chromium
Visibility:
Public.

Description

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

Patch Set 1 #

Patch Set 2 : . #

Patch Set 3 : . #

Patch Set 4 : basic reprint of 001 #

Patch Set 5 : add 002, run compares from gn_unittests #

Patch Set 6 : add not-working comment test #

Patch Set 7 : wip on adding comments to parse tree #

Patch Set 8 : toplevel comments, not sure on others yet #

Patch Set 9 : twiddle #

Patch Set 10 : classify comment tokens into either line or suffix type #

Patch Set 11 : traverse tree to get pre/post order and assign line 'before' comments #

Patch Set 12 : handle line comments at eof #

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

Messages

Total messages: 1 (1 generated)
scottmg
6 years, 3 months ago (2014-09-22 16:32:45 UTC) #1

Powered by Google App Engine
This is Rietveld 408576698