bravo-formatter
Advanced tools
Comparing version 0.0.16 to 0.0.17
@@ -174,4 +174,2 @@ /** | ||
// console.log('case', isTabularStyle(this.cfg)); | ||
// TODO 判断node.expr是否存在,不存在时when可以使用tabular风格如Select | ||
@@ -192,3 +190,2 @@ // 若存在则保留现有逻辑,换行缩进 | ||
} | ||
console.log('case', this.layout.getItems()); | ||
this.layout.add(WS.NEWLINE, WS.INDENT); | ||
@@ -198,3 +195,3 @@ this.formatNode(node.endKw); | ||
formatCaseWhen(node) { | ||
this.layout.add(WS.NEWLINE, WS.INDENT); | ||
// this.layout.add(WS.SPACE); | ||
this.formatNode(node.whenKw); | ||
@@ -287,7 +284,11 @@ this.layout = this.formatSubExpression(node.condition); | ||
formatComma(_node) { | ||
// 逗号前紧跟换行符,则加入indent缩进 | ||
if (!this.layout.isAfterNewLine()) { | ||
this.layout.add(WS.NO_SPACE); | ||
} | ||
if (!this.inline) { | ||
// newline after comma | ||
this.layout.add(WS.NO_SPACE, ',', WS.NEWLINE, WS.INDENT); | ||
this.layout.add(',', WS.NEWLINE, WS.INDENT); | ||
} else { | ||
this.layout.add(WS.NO_SPACE, ',', WS.SPACE); | ||
this.layout.add(',', WS.SPACE); | ||
} | ||
@@ -294,0 +295,0 @@ } |
@@ -34,2 +34,3 @@ import Indentation from './Indentation.js'; | ||
private trimWhitespace; | ||
isAfterNewLine(): boolean; | ||
private addNewline; | ||
@@ -36,0 +37,0 @@ private addIndentation; |
@@ -92,2 +92,9 @@ /** | ||
} | ||
isAfterNewLine() { | ||
let index = this.items.length - 1; | ||
while (index >= 0 && isHorizontalWhitespace(this.items[index])) { | ||
index--; | ||
} | ||
return this.items[index] === WS.NEWLINE || this.items[index] === WS.MANDATORY_NEWLINE; | ||
} | ||
addNewline(newline) { | ||
@@ -94,0 +101,0 @@ if (this.items.length > 0) { |
{ | ||
"name": "bravo-formatter", | ||
"version": "0.0.16", | ||
"version": "0.0.17", | ||
"description": "Format whitespace in a SQL query to make it more readable", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2351867
9440