mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 23:29:47 +00:00
analyzer: Rename some extensions
And add a bit to our style doc about naming of extensions. Change-Id: I22dd05dfe08b46ae38cc200456eb008e02eb002f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347782 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com> Auto-Submit: Samuel Rawlins <srawlins@google.com>
This commit is contained in:
parent
7f6b082216
commit
b19141a202
|
@ -20,7 +20,7 @@ class ThrowStatement {
|
|||
});
|
||||
}
|
||||
|
||||
extension AnnotatedNodeExtensions on AnnotatedNode {
|
||||
extension AnnotatedNodeExtension on AnnotatedNode {
|
||||
/// Return the first token in this node that is not a comment.
|
||||
Token get firstNonCommentToken {
|
||||
final metadata = this.metadata;
|
||||
|
@ -31,7 +31,7 @@ extension AnnotatedNodeExtensions on AnnotatedNode {
|
|||
}
|
||||
}
|
||||
|
||||
extension AstNodeExtensions on AstNode {
|
||||
extension AstNodeExtension on AstNode {
|
||||
/// Returns [ExtensionElement] declared by an enclosing node.
|
||||
ExtensionElement? get enclosingExtensionElement {
|
||||
for (final node in withParents) {
|
||||
|
@ -134,7 +134,7 @@ extension AstNodeExtensions on AstNode {
|
|||
}
|
||||
}
|
||||
|
||||
extension BinaryExpressionExtensions on BinaryExpression {
|
||||
extension BinaryExpressionExtension on BinaryExpression {
|
||||
bool get isNotEqNull {
|
||||
return operator.type == TokenType.BANG_EQ && rightOperand is NullLiteral;
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ extension DeclaredVariablePatternExtension on DeclaredVariablePattern {
|
|||
}
|
||||
}
|
||||
|
||||
extension DirectiveExtensions on Directive {
|
||||
extension DirectiveExtension on Directive {
|
||||
/// If the target imports or exports a [LibraryElement], returns it.
|
||||
LibraryElement? get referencedLibrary {
|
||||
final element = this.element;
|
||||
|
@ -241,7 +241,7 @@ extension DirectiveExtensions on Directive {
|
|||
}
|
||||
}
|
||||
|
||||
extension ExpressionExtensions on Expression {
|
||||
extension ExpressionExtension on Expression {
|
||||
/// Return `true` if this expression is an invocation of the method `cast`
|
||||
/// from either Iterable`, `List`, `Map`, or `Set`.
|
||||
bool get isCastMethodInvocation {
|
||||
|
@ -273,7 +273,7 @@ extension ExpressionExtensions on Expression {
|
|||
}
|
||||
}
|
||||
|
||||
extension FunctionBodyExtensions on FunctionBody {
|
||||
extension FunctionBodyExtension on FunctionBody {
|
||||
bool get isEmpty =>
|
||||
this is EmptyFunctionBody ||
|
||||
(this is BlockFunctionBody && beginToken.isSynthetic);
|
||||
|
|
|
@ -62,10 +62,12 @@ a unique name, such as `filePath`.
|
|||
#### Extensions
|
||||
|
||||
Public extensions (which are intended to be accessible outside their declaring
|
||||
library) are named in a consistent style. An extension on a class `Foo` is
|
||||
named `FooExtension`. While this can lead to long names (like
|
||||
`AnalysisOptionsImplExtension`), the extension name is rarely used (only in
|
||||
explicit extension overrides), and we value consistency.
|
||||
library) are named in a consistent style. An extension on a type `Foo` is
|
||||
named `FooExtension`. An extension on a nullable type `Foo?` uses the word
|
||||
"Nullable" in place of the question mark, like `FooNullableExtension`. While
|
||||
this can lead to long names (like `AnalysisOptionsImplExtension`), the
|
||||
extension name is rarely used (only in explicit extension overrides), and we
|
||||
value consistency.
|
||||
|
||||
### Modifier usage
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ extension AstNodeExtension on AstNode {
|
|||
return node.offset <= offset && node.end >= end;
|
||||
}
|
||||
|
||||
/// Return the child of the [node] that completely contains the [range], or
|
||||
/// Return the child of the [node] that completely contains the range, or
|
||||
/// `null` if none of the children contain the range (which means that the
|
||||
/// [node] is the covering node).
|
||||
AstNode? childContainingRange(AstNode node) {
|
||||
|
|
Loading…
Reference in a new issue