blob: 11bdcdfb082df0a75863c094bc8db115e16d1733 [file] [log] [blame]
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import '../comment_type.dart';
import 'selection.dart';
/// A comment in the source, with a bit of information about the surrounding
/// whitespace.
final class SourceComment extends Selection {
/// The text of the comment, including `//`, `/*`, and `*/`.
@override
final String text;
final CommentType type;
/// The number of newlines between the comment or token preceding this comment
/// and the beginning of this one.
///
/// Will be zero if the comment is a trailing one.
int linesBefore;
/// Whether this comment starts at column one in the source.
///
/// Comments that start at the start of the line will not be indented in the
/// output. This way, commented out chunks of code do not get erroneously
/// re-indented.
final bool flushLeft;
SourceComment(
this.text,
this.type,
this.linesBefore, {
required this.flushLeft,
});
}