mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-21 16:36:41 +00:00
In order to format comments, it's helpful if they're tracked. This tracks them separately from tokens in order to avoid interfering with parse; it'd be inconvenient if comment tokens could show up in arbitrary locations, albeit possible to support. This additionally extracts out the TokenIterator support into a template in order to generally have it available for IndexBase types. I'm only adding it for CommentInfo, not sure if we'll want it elsewhere, but this structure still felt like a good fit.
58 lines
1.2 KiB
Plaintext
58 lines
1.2 KiB
Plaintext
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
// AUTOUPDATE
|
|
// TIP: To test this file alone, run:
|
|
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/format/testdata/basics/comments.carbon
|
|
// TIP: To dump output, run:
|
|
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/format/testdata/basics/comments.carbon
|
|
|
|
// --- test.carbon
|
|
|
|
// A comment
|
|
fn F() {}
|
|
|
|
// Another comment
|
|
|
|
// Block
|
|
// comment
|
|
|
|
|
|
class C {
|
|
// Internal comment
|
|
}
|
|
|
|
|
|
// Another
|
|
// Block
|
|
//
|
|
// Comment
|
|
|
|
// --- AUTOUPDATE-SPLIT
|
|
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: // A comment
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn F ( ) { }
|
|
// CHECK:STDOUT: // Another comment
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: // Block
|
|
// CHECK:STDOUT: // comment
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: class C {
|
|
// CHECK:STDOUT: // Internal comment
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: // Another
|
|
// CHECK:STDOUT: // Block
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: //
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: // Comment
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT:
|