Skip to content

Commit

Permalink
Address comments by removing comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
lrhn committed Oct 3, 2023
1 parent fd05e3a commit 489da26
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 10 deletions.
7 changes: 0 additions & 7 deletions lib/src/source_visitor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2631,8 +2631,6 @@ class SourceVisitor extends ThrowingAstVisitor {

@override
void visitRepresentationDeclaration(RepresentationDeclaration node) {
// Consider having `node.asFormalParameterList()`, and format based on that.

visit(node.constructorName);

token(node.leftParenthesis);
Expand All @@ -2646,19 +2644,14 @@ class SourceVisitor extends ThrowingAstVisitor {
builder.startBlockArgumentNesting();
builder.startSpan();

// Inline `visitFormalParameterList`, remove all that doesn't apply
// to a required positional parameter with no modifiers
// and no trailing comma.
visitParameterMetadata(node.fieldMetadata, () {
// Inline `_beginFormalParameter`
builder.startLazyRule(Rule(Cost.parameterType));
builder.nestExpression();

visit(node.fieldType);
_separatorBetweenTypeAndVariable(node.fieldType);
token(node.fieldName);

// Inline `_endFormalParameter`
builder.unnest();
builder.endRule();
});
Expand Down
64 changes: 61 additions & 3 deletions test/whitespace/extension_types.unit
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ extension type A(int a) {
}
<<<
extension type A(int a) {}
>>> leading space before "class"
>>> leading space before "extension type"
extension type A(int a) {
}
<<<
Expand Down Expand Up @@ -110,8 +110,66 @@ extension

type

const

A

A(int a){}
<

T

>

.

name

(

int

a

)

{

}
<<<
extension type A(int a) {}
extension type const A<T>.name(int a) {}
>>> Supports all members except instance fields
extension type const A<T>.name(int a) {
static const int c = 1;
static final int f = 1;
static late final int l;
static var v;
static int get g => c;
static set g(int i) {}
static int m<X>(X x) => c;
const A(int a) : this.a = a;
const A.r(int a) : this(a);
const factory A.rf(int a) = A;
factory A.f(int a) => A(a);
int get pr => 0;
set pr(int x) {}
int me(int x) => x;
int operator+(int x) => x;
}
<<<
extension type const A<T>.name(int a) {
static const int c = 1;
static final int f = 1;
static late final int l;
static var v;
static int get g => c;
static set g(int i) {}
static int m<X>(X x) => c;
const A(int a) : this.a = a;
const A.r(int a) : this(a);
const factory A.rf(int a) = A;
factory A.f(int a) => A(a);
int get pr => 0;
set pr(int x) {}
int me(int x) => x;
int operator +(int x) => x;
}

0 comments on commit 489da26

Please sign in to comment.