Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -969,13 +969,15 @@ public boolean enterVarNode(VarNode varNode) {

@Override
public boolean enterClassElement(ClassElement propertyNode) {
FormatToken colon = tokenUtils.getNextToken(getFinish(propertyNode.getKey()),
JsTokenId.OPERATOR_COLON, getFinish(propertyNode));
if (colon != null) {
TokenUtils.appendToken(colon, FormatToken.forFormat(FormatToken.Kind.AFTER_PROPERTY_OPERATOR));
FormatToken before = colon.previous();
if (before != null) {
TokenUtils.appendTokenAfterLastVirtual(before, FormatToken.forFormat(FormatToken.Kind.BEFORE_PROPERTY_OPERATOR));
if (propertyNode.getKey() != null) {
FormatToken colon = tokenUtils.getNextToken(getFinish(propertyNode.getKey()),
JsTokenId.OPERATOR_COLON, getFinish(propertyNode));
if (colon != null) {
TokenUtils.appendToken(colon, FormatToken.forFormat(FormatToken.Kind.AFTER_PROPERTY_OPERATOR));
FormatToken before = colon.previous();
if (before != null) {
TokenUtils.appendTokenAfterLastVirtual(before, FormatToken.forFormat(FormatToken.Kind.BEFORE_PROPERTY_OPERATOR));
}
}
}
return super.enterPropertyNode(propertyNode);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Dummy {
#privateField;
constructor(v) {
this.#privateField = v;
}
static {
console.log("Dummy");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Dummy {
#privateField;
constructor(v) {
this.#privateField = v;
}
static {
console.log("Dummy");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2543,4 +2543,8 @@ public void testCommentAtTheEdnOfLine() throws Exception {
"} //comment2\n" +
"p = stripName(p);", null);
}

public void testFormatStaticClassInitializer() throws Exception {
reformatFileContents("testfiles/formatter/staticClassInitializer1.js",new IndentPrefs(4, 4));
}
}
Loading