mirror of
https://github.com/dart-lang/sdk
synced 2024-09-30 04:48:37 +00:00
analyzer: Deprecate dead properties on Comment
Work towards https://github.com/dart-lang/sdk/issues/56038 Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try Change-Id: If7ae2738fec598f16756c524b6bd6c258ee5609e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/372100 Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Reviewed-by: Nate Bosch <nbosch@google.com> Commit-Queue: Sam Rawlins <srawlins@google.com>
This commit is contained in:
parent
48cadec309
commit
4f5dc5603f
|
@ -24,7 +24,7 @@ class ConvertDocumentationIntoBlock extends ResolvedCorrectionProducer {
|
|||
@override
|
||||
Future<void> compute(ChangeBuilder builder) async {
|
||||
var comment = node.thisOrAncestorOfType<Comment>();
|
||||
if (comment == null || !comment.isDocumentation) {
|
||||
if (comment == null) {
|
||||
return;
|
||||
}
|
||||
var tokens = comment.tokens;
|
||||
|
|
|
@ -31,9 +31,7 @@ class ConvertDocumentationIntoLine extends ParsedCorrectionProducer {
|
|||
@override
|
||||
Future<void> compute(ChangeBuilder builder) async {
|
||||
var comment = node.thisOrAncestorOfType<Comment>();
|
||||
if (comment == null ||
|
||||
!comment.isDocumentation ||
|
||||
comment.tokens.length != 1) {
|
||||
if (comment == null || comment.tokens.length != 1) {
|
||||
return;
|
||||
}
|
||||
var token = comment.tokens.first;
|
||||
|
|
|
@ -3242,12 +3242,15 @@ abstract final class Comment implements AstNode {
|
|||
bool get hasNodoc;
|
||||
|
||||
/// Whether this is a block comment.
|
||||
@Deprecated("Do not use; this value is always 'false'")
|
||||
bool get isBlock;
|
||||
|
||||
/// Whether this is a documentation comment.
|
||||
@Deprecated("Do not use; this value is always 'true'")
|
||||
bool get isDocumentation;
|
||||
|
||||
/// Whether this is an end-of-line comment.
|
||||
@Deprecated("Do not use; this value is always 'false'")
|
||||
bool get isEndOfLine;
|
||||
|
||||
/// The references embedded within the documentation comment.
|
||||
|
@ -3265,9 +3268,6 @@ final class CommentImpl extends AstNodeImpl
|
|||
@override
|
||||
final List<Token> tokens;
|
||||
|
||||
/// The type of the comment.
|
||||
final CommentType _type;
|
||||
|
||||
final NodeListImpl<CommentReferenceImpl> _references = NodeListImpl._();
|
||||
|
||||
@override
|
||||
|
@ -3292,13 +3292,12 @@ final class CommentImpl extends AstNodeImpl
|
|||
/// embedded references.
|
||||
CommentImpl({
|
||||
required this.tokens,
|
||||
required CommentType type,
|
||||
required List<CommentReferenceImpl> references,
|
||||
required this.codeBlocks,
|
||||
required this.docImports,
|
||||
required this.docDirectives,
|
||||
required this.hasNodoc,
|
||||
}) : _type = type {
|
||||
}) {
|
||||
_references._initialize(this, references);
|
||||
}
|
||||
|
||||
|
@ -3309,13 +3308,13 @@ final class CommentImpl extends AstNodeImpl
|
|||
Token get endToken => tokens[tokens.length - 1];
|
||||
|
||||
@override
|
||||
bool get isBlock => _type == CommentType.BLOCK;
|
||||
bool get isBlock => false;
|
||||
|
||||
@override
|
||||
bool get isDocumentation => _type == CommentType.DOCUMENTATION;
|
||||
bool get isDocumentation => true;
|
||||
|
||||
@override
|
||||
bool get isEndOfLine => _type == CommentType.END_OF_LINE;
|
||||
bool get isEndOfLine => false;
|
||||
|
||||
@override
|
||||
NodeListImpl<CommentReferenceImpl> get references => _references;
|
||||
|
@ -3409,27 +3408,6 @@ final class CommentReferenceImpl extends AstNodeImpl
|
|||
}
|
||||
}
|
||||
|
||||
/// The possible types of comments that are recognized by the parser.
|
||||
class CommentType {
|
||||
/// A block comment.
|
||||
static const CommentType BLOCK = CommentType('BLOCK');
|
||||
|
||||
/// A documentation comment.
|
||||
static const CommentType DOCUMENTATION = CommentType('DOCUMENTATION');
|
||||
|
||||
/// An end-of-line comment.
|
||||
static const CommentType END_OF_LINE = CommentType('END_OF_LINE');
|
||||
|
||||
/// The name of the comment type.
|
||||
final String name;
|
||||
|
||||
/// Initializes a newly created comment type to have the given [name].
|
||||
const CommentType(this.name);
|
||||
|
||||
@override
|
||||
String toString() => name;
|
||||
}
|
||||
|
||||
/// A compilation unit.
|
||||
///
|
||||
/// While the grammar restricts the order of the directives and declarations
|
||||
|
|
|
@ -137,7 +137,6 @@ final class DocCommentBuilder {
|
|||
}
|
||||
return CommentImpl(
|
||||
tokens: tokens,
|
||||
type: CommentType.DOCUMENTATION,
|
||||
references: _references,
|
||||
codeBlocks: _codeBlocks,
|
||||
docImports: _docImports,
|
||||
|
|
|
@ -13,7 +13,7 @@ export 'package:_fe_analyzer_shared/src/util/resolve_relative_uri.dart'
|
|||
/// and range into the given [element].
|
||||
void setElementDocumentationComment(ElementImpl element, AnnotatedNode node) {
|
||||
var comment = node.documentationComment;
|
||||
if (comment != null && comment.isDocumentation) {
|
||||
if (comment != null) {
|
||||
element.documentationComment =
|
||||
comment.tokens.map((Token t) => t.lexeme).join('\n');
|
||||
}
|
||||
|
|
|
@ -379,7 +379,6 @@ class C {
|
|||
assertNoErrors();
|
||||
var declaration = unit.declarations[0] as ClassDeclaration;
|
||||
Comment comment = declaration.documentationComment!;
|
||||
expect(comment.isDocumentation, isTrue);
|
||||
expect(comment.tokens, hasLength(1));
|
||||
expect(comment.tokens[0].lexeme, '/** 2 */');
|
||||
expect(declaration.metadata, hasLength(1));
|
||||
|
@ -687,9 +686,6 @@ class C {}
|
|||
Comment comment = unit.declarations[0].documentationComment!;
|
||||
expectNotNullIfNoErrors(comment);
|
||||
assertNoErrors();
|
||||
expect(comment.isBlock, isFalse);
|
||||
expect(comment.isDocumentation, isTrue);
|
||||
expect(comment.isEndOfLine, isFalse);
|
||||
}
|
||||
|
||||
void test_parseDocumentationComment_block_withReference() {
|
||||
|
@ -698,9 +694,6 @@ class C {}
|
|||
Comment comment = unit.declarations[0].documentationComment!;
|
||||
expectNotNullIfNoErrors(comment);
|
||||
assertNoErrors();
|
||||
expect(comment.isBlock, isFalse);
|
||||
expect(comment.isDocumentation, isTrue);
|
||||
expect(comment.isEndOfLine, isFalse);
|
||||
NodeList<CommentReference> references = comment.references;
|
||||
expect(references, hasLength(1));
|
||||
CommentReference reference = references[0];
|
||||
|
@ -714,9 +707,6 @@ class C {}
|
|||
Comment comment = unit.declarations[0].documentationComment!;
|
||||
expectNotNullIfNoErrors(comment);
|
||||
assertNoErrors();
|
||||
expect(comment.isBlock, isFalse);
|
||||
expect(comment.isDocumentation, isTrue);
|
||||
expect(comment.isEndOfLine, isFalse);
|
||||
}
|
||||
|
||||
void test_parseExtendsClause() {
|
||||
|
|
|
@ -198,8 +198,6 @@ class _Visitor extends SimpleAstVisitor<void> {
|
|||
|
||||
@override
|
||||
void visitComment(Comment node) {
|
||||
if (!node.isDocumentation) return;
|
||||
|
||||
var codeBlockLines =
|
||||
node.codeBlocks.map((codeBlock) => codeBlock.lines).flattened;
|
||||
|
||||
|
|
|
@ -169,7 +169,7 @@ class ValidateCommentCodeSamplesVisitor extends GeneralizingAstVisitor {
|
|||
|
||||
void _handleDocumentableNode(AnnotatedNode node) {
|
||||
final docComment = node.documentationComment;
|
||||
if (docComment == null || !docComment.isDocumentation) {
|
||||
if (docComment == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue