From ff66089ac3bf1a1004c5c96d27378c4d3a9cf1ce Mon Sep 17 00:00:00 2001
From: PauliusKu
Date: Wed, 14 Aug 2024 23:03:37 +0300
Subject: [PATCH 01/79] initial tests
---
resources/functionalTests/for1-each-false/input.p | 10 ++++++++++
resources/functionalTests/for1-each-false/target.p | 10 ++++++++++
resources/functionalTests/for2-each-true/input.p | 10 ++++++++++
resources/functionalTests/for2-each-true/target.p | 8 ++++++++
resources/functionalTests/for3-each-where/input.p | 8 ++++++++
resources/functionalTests/for3-each-where/target.p | 9 +++++++++
resources/functionalTests/for4-each-where3/input.p | 8 ++++++++
resources/functionalTests/for4-each-where3/target.p | 9 +++++++++
8 files changed, 72 insertions(+)
create mode 100644 resources/functionalTests/for1-each-false/input.p
create mode 100644 resources/functionalTests/for1-each-false/target.p
create mode 100644 resources/functionalTests/for2-each-true/input.p
create mode 100644 resources/functionalTests/for2-each-true/target.p
create mode 100644 resources/functionalTests/for3-each-where/input.p
create mode 100644 resources/functionalTests/for3-each-where/target.p
create mode 100644 resources/functionalTests/for4-each-where3/input.p
create mode 100644 resources/functionalTests/for4-each-where3/target.p
diff --git a/resources/functionalTests/for1-each-false/input.p b/resources/functionalTests/for1-each-false/input.p
new file mode 100644
index 00000000..d675f879
--- /dev/null
+++ b/resources/functionalTests/for1-each-false/input.p
@@ -0,0 +1,10 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.blockFormatting": true,
+"AblFormatter.forFormatting": false
+}*/
+
+for
+each
+Customer:
+ Customer.var += 1.
+end.
\ No newline at end of file
diff --git a/resources/functionalTests/for1-each-false/target.p b/resources/functionalTests/for1-each-false/target.p
new file mode 100644
index 00000000..d675f879
--- /dev/null
+++ b/resources/functionalTests/for1-each-false/target.p
@@ -0,0 +1,10 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.blockFormatting": true,
+"AblFormatter.forFormatting": false
+}*/
+
+for
+each
+Customer:
+ Customer.var += 1.
+end.
\ No newline at end of file
diff --git a/resources/functionalTests/for2-each-true/input.p b/resources/functionalTests/for2-each-true/input.p
new file mode 100644
index 00000000..ef42047e
--- /dev/null
+++ b/resources/functionalTests/for2-each-true/input.p
@@ -0,0 +1,10 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.blockFormatting": true,
+"AblFormatter.forFormatting": true
+}*/
+
+for
+each
+Customer:
+ Customer.var += 1.
+end.
\ No newline at end of file
diff --git a/resources/functionalTests/for2-each-true/target.p b/resources/functionalTests/for2-each-true/target.p
new file mode 100644
index 00000000..dbbe3133
--- /dev/null
+++ b/resources/functionalTests/for2-each-true/target.p
@@ -0,0 +1,8 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.blockFormatting": true,
+"AblFormatter.forFormatting": true
+}*/
+
+for each Customer:
+ Customer.var += 1.
+end.
\ No newline at end of file
diff --git a/resources/functionalTests/for3-each-where/input.p b/resources/functionalTests/for3-each-where/input.p
new file mode 100644
index 00000000..bfed1d6f
--- /dev/null
+++ b/resources/functionalTests/for3-each-where/input.p
@@ -0,0 +1,8 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.blockFormatting": true,
+"AblFormatter.forFormatting": true
+}*/
+
+for each Customer where Customer.var = 1:
+ Customer.var += 1.
+end.
\ No newline at end of file
diff --git a/resources/functionalTests/for3-each-where/target.p b/resources/functionalTests/for3-each-where/target.p
new file mode 100644
index 00000000..a376627f
--- /dev/null
+++ b/resources/functionalTests/for3-each-where/target.p
@@ -0,0 +1,9 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.blockFormatting": true,
+"AblFormatter.forFormatting": true
+}*/
+
+for each Customer where
+ Customer.var = 1:
+ Customer.var += 1.
+end.
\ No newline at end of file
diff --git a/resources/functionalTests/for4-each-where3/input.p b/resources/functionalTests/for4-each-where3/input.p
new file mode 100644
index 00000000..38eba14d
--- /dev/null
+++ b/resources/functionalTests/for4-each-where3/input.p
@@ -0,0 +1,8 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.blockFormatting": true,
+"AblFormatter.forFormatting": true
+}*/
+
+for each Customer where Customer.var = 1 or Customer.var = 2 or Customer.var = 3:
+ Customer.var += 1.
+end.
\ No newline at end of file
diff --git a/resources/functionalTests/for4-each-where3/target.p b/resources/functionalTests/for4-each-where3/target.p
new file mode 100644
index 00000000..154260b4
--- /dev/null
+++ b/resources/functionalTests/for4-each-where3/target.p
@@ -0,0 +1,9 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.blockFormatting": true,
+"AblFormatter.forFormatting": true
+}*/
+
+for each Customer where
+ Customer.var = 1 or Customer.var = 2 or Customer.var = 3:
+ Customer.var += 1.
+end.
\ No newline at end of file
From ff49f5579b75086b33061fce6680f88cc30f0860 Mon Sep 17 00:00:00 2001
From: sjonynaite
Date: Wed, 21 Aug 2024 17:16:47 +0300
Subject: [PATCH 02/79] Updated findFormattter added tests
---
.../find-firstLastNextPrev/input.p | 8 +
.../find-firstLastNextPrev/target.p | 8 +
.../find-multipleConditions-()/input.p | 6 +
.../find-multipleConditions-()/target.p | 6 +
.../find-multipleConditions-()2/input.p | 6 +
.../find-multipleConditions-()2/target.p | 6 +
.../find-multipleConditions/input.p | 8 +
.../find-multipleConditions/target.p | 8 +
resources/functionalTests/find-spaces/input.p | 5 +
.../functionalTests/find-spaces/target.p | 5 +
.../functionalTests/find-useIndex/input.p | 5 +
.../functionalTests/find-useIndex/target.p | 6 +
src/model/SyntaxNodeType.ts | 1 +
.../enableFormatterDecorators.ts | 2 +
src/v2/formatters/find/FindFormatter.ts | 234 ++++++++++++++++++
src/v2/formatters/find/FindSettings.ts | 8 +
16 files changed, 322 insertions(+)
create mode 100644 resources/functionalTests/find-firstLastNextPrev/input.p
create mode 100644 resources/functionalTests/find-firstLastNextPrev/target.p
create mode 100644 resources/functionalTests/find-multipleConditions-()/input.p
create mode 100644 resources/functionalTests/find-multipleConditions-()/target.p
create mode 100644 resources/functionalTests/find-multipleConditions-()2/input.p
create mode 100644 resources/functionalTests/find-multipleConditions-()2/target.p
create mode 100644 resources/functionalTests/find-multipleConditions/input.p
create mode 100644 resources/functionalTests/find-multipleConditions/target.p
create mode 100644 resources/functionalTests/find-spaces/input.p
create mode 100644 resources/functionalTests/find-spaces/target.p
create mode 100644 resources/functionalTests/find-useIndex/input.p
create mode 100644 resources/functionalTests/find-useIndex/target.p
create mode 100644 src/v2/formatters/find/FindFormatter.ts
create mode 100644 src/v2/formatters/find/FindSettings.ts
diff --git a/resources/functionalTests/find-firstLastNextPrev/input.p b/resources/functionalTests/find-firstLastNextPrev/input.p
new file mode 100644
index 00000000..b2b68c7a
--- /dev/null
+++ b/resources/functionalTests/find-firstLastNextPrev/input.p
@@ -0,0 +1,8 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.findFormatting": true,
+"abl.completion.upperCase": true}*/
+
+FIND FIRST Customer WHERE Customer.CustNum = 5 NO-LOCK NO-ERROR.
+FIND LAST Customer WHERE Customer.CustNum = 5 NO-LOCK NO-ERROR.
+FIND NEXT Customer WHERE Customer.CustNum = 5 NO-LOCK NO-ERROR.
+FIND PREV Customer WHERE Customer.CustNum = 5 NO-LOCK NO-ERROR.
\ No newline at end of file
diff --git a/resources/functionalTests/find-firstLastNextPrev/target.p b/resources/functionalTests/find-firstLastNextPrev/target.p
new file mode 100644
index 00000000..0b3d1939
--- /dev/null
+++ b/resources/functionalTests/find-firstLastNextPrev/target.p
@@ -0,0 +1,8 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.findFormatting": true,
+"abl.completion.upperCase": true}*/
+
+FIND FIRST Customer WHERE Customer.CustNum = 5 NO-LOCK NO-ERROR.
+FIND LAST Customer WHERE Customer.CustNum = 5 NO-LOCK NO-ERROR.
+FIND NEXT Customer WHERE Customer.CustNum = 5 NO-LOCK NO-ERROR.
+FIND PREV Customer WHERE Customer.CustNum = 5 NO-LOCK NO-ERROR.
\ No newline at end of file
diff --git a/resources/functionalTests/find-multipleConditions-()/input.p b/resources/functionalTests/find-multipleConditions-()/input.p
new file mode 100644
index 00000000..46cf0147
--- /dev/null
+++ b/resources/functionalTests/find-multipleConditions-()/input.p
@@ -0,0 +1,6 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.findFormatting": true,
+"abl.completion.upperCase": true}*/
+
+FIND Customer WHERE (Customer.CustNum > 50 AND Customer.CustNum < 100) OR
+ Customer.CustNum > 200 NO-ERROR.
\ No newline at end of file
diff --git a/resources/functionalTests/find-multipleConditions-()/target.p b/resources/functionalTests/find-multipleConditions-()/target.p
new file mode 100644
index 00000000..37f2585b
--- /dev/null
+++ b/resources/functionalTests/find-multipleConditions-()/target.p
@@ -0,0 +1,6 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.findFormatting": true,
+"abl.completion.upperCase": true}*/
+
+FIND Customer WHERE (Customer.CustNum > 50 AND Customer.CustNum < 100) OR
+ Customer.CustNum > 200 NO-ERROR.
\ No newline at end of file
diff --git a/resources/functionalTests/find-multipleConditions-()2/input.p b/resources/functionalTests/find-multipleConditions-()2/input.p
new file mode 100644
index 00000000..34d84c22
--- /dev/null
+++ b/resources/functionalTests/find-multipleConditions-()2/input.p
@@ -0,0 +1,6 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.findFormatting": true,
+"abl.completion.upperCase": true}*/
+
+FIND Order WHERE (Order.OrderStatus = "Shipped" AND (Order.ShipDate > TODAY - 7)) OR
+(Order.OrderStatus = "Pending" AND (Order.OrderDate = TODAY)) no-lock.
\ No newline at end of file
diff --git a/resources/functionalTests/find-multipleConditions-()2/target.p b/resources/functionalTests/find-multipleConditions-()2/target.p
new file mode 100644
index 00000000..0b14b407
--- /dev/null
+++ b/resources/functionalTests/find-multipleConditions-()2/target.p
@@ -0,0 +1,6 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.findFormatting": true,
+"abl.completion.upperCase": true}*/
+
+FIND Order WHERE (Order.OrderStatus = "Shipped" AND (Order.ShipDate > TODAY - 7)) OR
+ (Order.OrderStatus = "Pending" AND (Order.OrderDate = TODAY)) no-lock.
\ No newline at end of file
diff --git a/resources/functionalTests/find-multipleConditions/input.p b/resources/functionalTests/find-multipleConditions/input.p
new file mode 100644
index 00000000..0747c5d1
--- /dev/null
+++ b/resources/functionalTests/find-multipleConditions/input.p
@@ -0,0 +1,8 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.findFormatting": true,
+"abl.completion.upperCase": true}*/
+
+FIND Customer WHERE
+Customer.CustNum = 5 AND Customer.CustNum = 6 OR
+ Customer.CustNum = 7 AND
+ Customer.CustNum = 8 no-lock no-error.
\ No newline at end of file
diff --git a/resources/functionalTests/find-multipleConditions/target.p b/resources/functionalTests/find-multipleConditions/target.p
new file mode 100644
index 00000000..5a116d06
--- /dev/null
+++ b/resources/functionalTests/find-multipleConditions/target.p
@@ -0,0 +1,8 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.findFormatting": true,
+"abl.completion.upperCase": true}*/
+
+FIND Customer WHERE Customer.CustNum = 5 AND
+ Customer.CustNum = 6 OR
+ Customer.CustNum = 7 AND
+ Customer.CustNum = 8 no-lock no-error.
\ No newline at end of file
diff --git a/resources/functionalTests/find-spaces/input.p b/resources/functionalTests/find-spaces/input.p
new file mode 100644
index 00000000..d70cac20
--- /dev/null
+++ b/resources/functionalTests/find-spaces/input.p
@@ -0,0 +1,5 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.findFormatting": true,
+"abl.completion.upperCase": true}*/
+
+FIND Customer WHERE Customer.CustNum = 5 NO-LOCK NO-ERROR.
\ No newline at end of file
diff --git a/resources/functionalTests/find-spaces/target.p b/resources/functionalTests/find-spaces/target.p
new file mode 100644
index 00000000..9996f9e2
--- /dev/null
+++ b/resources/functionalTests/find-spaces/target.p
@@ -0,0 +1,5 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.findFormatting": true,
+"abl.completion.upperCase": true}*/
+
+FIND Customer WHERE Customer.CustNum = 5 NO-LOCK NO-ERROR.
\ No newline at end of file
diff --git a/resources/functionalTests/find-useIndex/input.p b/resources/functionalTests/find-useIndex/input.p
new file mode 100644
index 00000000..6a13e2cc
--- /dev/null
+++ b/resources/functionalTests/find-useIndex/input.p
@@ -0,0 +1,5 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.findFormatting": true,
+"abl.completion.upperCase": true}*/
+
+find Order where Order.OrderStatus = "Shipped" and Order.ShipDate = today use-index OrderNum.
\ No newline at end of file
diff --git a/resources/functionalTests/find-useIndex/target.p b/resources/functionalTests/find-useIndex/target.p
new file mode 100644
index 00000000..4fcd22c0
--- /dev/null
+++ b/resources/functionalTests/find-useIndex/target.p
@@ -0,0 +1,6 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.findFormatting": true,
+"abl.completion.upperCase": true}*/
+
+find Order where Order.OrderStatus = "Shipped" and
+ Order.ShipDate = today use-index OrderNum.
\ No newline at end of file
diff --git a/src/model/SyntaxNodeType.ts b/src/model/SyntaxNodeType.ts
index 4ea3d3c5..1603a570 100644
--- a/src/model/SyntaxNodeType.ts
+++ b/src/model/SyntaxNodeType.ts
@@ -54,4 +54,5 @@ export enum SyntaxNodeType {
EachKeyword = "EACH",
EndKeyword = "END",
IfKeyword = "IF",
+ FindKeyword = "FIND",
}
diff --git a/src/v2/formatterFramework/enableFormatterDecorators.ts b/src/v2/formatterFramework/enableFormatterDecorators.ts
index 4881628c..a8e1273f 100644
--- a/src/v2/formatterFramework/enableFormatterDecorators.ts
+++ b/src/v2/formatterFramework/enableFormatterDecorators.ts
@@ -4,6 +4,7 @@ import { IfFormatter } from "../formatters/if/IfFormatter";
import { DefineFormatter } from "../formatters/define/DefineFormatter";
import { UsingFormatter } from "../formatters/using/UsingFormatter";
import { CaseFormatter } from "../formatters/case/CaseFormatter";
+import { FindFormatter } from "../formatters/find/FindFormatter";
// needed just for enabling decorators. Decorators does not work if there is no usage of a class in the reachable code
export function enableFormatterDecorators(): void {
@@ -13,4 +14,5 @@ export function enableFormatterDecorators(): void {
DefineFormatter;
UsingFormatter;
CaseFormatter;
+ FindFormatter;
}
diff --git a/src/v2/formatters/find/FindFormatter.ts b/src/v2/formatters/find/FindFormatter.ts
new file mode 100644
index 00000000..79750243
--- /dev/null
+++ b/src/v2/formatters/find/FindFormatter.ts
@@ -0,0 +1,234 @@
+import { SyntaxNode } from "web-tree-sitter";
+import { IFormatter } from "../../formatterFramework/IFormatter";
+import { SyntaxNodeType } from "../../../model/SyntaxNodeType";
+import { CodeEdit } from "../../model/CodeEdit";
+import { FullText } from "../../model/FullText";
+import { FormatterHelper } from "../../formatterFramework/FormatterHelper";
+import { AFormatter } from "../AFormatter";
+import { RegisterFormatter } from "../../formatterFramework/formatterDecorator";
+import { FindSettings } from "./FindSettings";
+import { IConfigurationManager } from "../../../utils/IConfigurationManager";
+
+/**
+ * Note: The WHERE clause block with multiple LogicalExpressions does not align correctly
+ * during the first formatting if there are spaces before the WHERE clause.
+ *
+ * Question: Should QueryTuning also be formatted in a similar manner to LogicalExpressions,
+ * with aligned spacing and line breaks?
+ */
+
+@RegisterFormatter
+export class FindFormatter extends AFormatter implements IFormatter {
+ private startColumn = 0;
+ private findBodyValue = "";
+
+ public static readonly formatterLabel = "findFormatting";
+ private readonly settings: FindSettings;
+
+ public constructor(configurationManager: IConfigurationManager) {
+ super(configurationManager);
+ this.settings = new FindSettings(configurationManager);
+ }
+
+ match(node: Readonly): boolean {
+ return node.type === SyntaxNodeType.FindStatement;
+ }
+
+ parse(
+ node: Readonly,
+ fullText: Readonly
+ ): CodeEdit | CodeEdit[] | undefined {
+ this.collectCaseStructure(node, fullText);
+ return this.getCodeEdit(
+ node,
+ FormatterHelper.getCurrentText(node, fullText),
+ this.findBodyValue,
+ fullText
+ );
+ }
+
+ private collectCaseStructure(
+ node: SyntaxNode,
+ fullText: Readonly
+ ) {
+ this.startColumn = this.getStartColumn(node);
+ this.findBodyValue = this.getFindStatementBlock(node, fullText);
+ }
+
+ private getFindStatementBlock(
+ node: SyntaxNode,
+ fullText: Readonly
+ ): string {
+ let resultString = "";
+
+ node.children.forEach((child) => {
+ resultString = resultString.concat(
+ this.getFindExpressionString(child, fullText)
+ );
+ });
+
+ resultString = resultString.concat(".");
+ return resultString;
+ }
+
+ private getFindExpressionString(
+ node: SyntaxNode,
+ fullText: Readonly
+ ): string {
+ let newString = "";
+
+ switch (node.type) {
+ case SyntaxNodeType.FindKeyword:
+ newString =
+ " ".repeat(this.startColumn) +
+ FormatterHelper.getCurrentText(node, fullText).trim();
+ break;
+ case SyntaxNodeType.WhereClause:
+ newString = this.getWhereClauseBlock(node, fullText);
+ break;
+ case SyntaxNodeType.QueryTuning:
+ newString =
+ " " + FormatterHelper.getCurrentText(node, fullText).trim();
+ break;
+ default:
+ const text = FormatterHelper.getCurrentText(
+ node,
+ fullText
+ ).trim();
+ newString = text.length === 0 ? "" : " " + text;
+ break;
+ }
+
+ return newString;
+ }
+
+ private getWhereClauseBlock(
+ node: SyntaxNode,
+ fullText: Readonly
+ ): string {
+ let resultString = "";
+
+ node.children.forEach((child) => {
+ switch (child.type) {
+ case SyntaxNodeType.LogicalExpression:
+ resultString = resultString.concat(
+ this.getLogicalExpressionBlock(
+ child,
+ fullText,
+ child.startPosition.column
+ )
+ );
+ break;
+ case SyntaxNodeType.WhereKeyword:
+ resultString = resultString.concat(
+ " ",
+ FormatterHelper.getCurrentText(child, fullText).trim()
+ );
+ break;
+ case SyntaxNodeType.ComparisonExpression:
+ resultString = resultString.concat(
+ this.getComparisonExpressionBlock(child, fullText)
+ );
+ break;
+ default:
+ const text = FormatterHelper.getCurrentText(
+ node,
+ fullText
+ ).trim();
+ resultString = text.length === 0 ? "" : " " + text;
+ break;
+ }
+ });
+
+ return resultString;
+ }
+
+ private getComparisonExpressionBlock(
+ node: SyntaxNode,
+ fullText: Readonly
+ ): string {
+ let resultString = "";
+
+ node.children.forEach((child) => {
+ resultString = resultString.concat(
+ " ",
+ FormatterHelper.getCurrentText(child, fullText).trim()
+ );
+ });
+
+ return resultString;
+ }
+
+ private getLogicalExpressionBlock(
+ node: SyntaxNode,
+ fullText: Readonly,
+ LogicalExpressionStartColumn: number
+ ): string {
+ let resultString = "";
+
+ node.children.forEach((child) => {
+ resultString = resultString.concat(
+ this.getLogicalExpressionString(
+ child,
+ fullText,
+ LogicalExpressionStartColumn
+ )
+ );
+ });
+
+ return resultString;
+ }
+
+ private getLogicalExpressionString(
+ node: SyntaxNode,
+ fullText: Readonly,
+ LogicalExpressionStartColumn: number
+ ): string {
+ let newString = "";
+
+ switch (node.type) {
+ case SyntaxNodeType.OrKeyword:
+ case SyntaxNodeType.AndKeyword:
+ newString =
+ " " +
+ FormatterHelper.getCurrentText(node, fullText).trim() +
+ fullText.eolDelimiter +
+ " ".repeat(LogicalExpressionStartColumn);
+ break;
+ case SyntaxNodeType.LogicalExpression:
+ newString = this.getLogicalExpressionBlock(
+ node,
+ fullText,
+ LogicalExpressionStartColumn
+ );
+ break;
+ default:
+ const text = FormatterHelper.getCurrentText(
+ node,
+ fullText
+ ).trim();
+ newString = text.length === 0 ? "" : " " + text;
+ break;
+ }
+
+ return newString;
+ }
+
+ private getStartColumn(node: SyntaxNode): number {
+ if (node.type === SyntaxNodeType.FindKeyword) {
+ return node.startPosition.column;
+ } else {
+ return this.findParentFindStatementStartColumn(node);
+ }
+ }
+
+ private findParentFindStatementStartColumn(node: SyntaxNode): number {
+ if (node.parent === null) {
+ return 0;
+ }
+
+ return node.type === SyntaxNodeType.FindKeyword
+ ? node.startPosition.column
+ : this.findParentFindStatementStartColumn(node.parent);
+ }
+}
diff --git a/src/v2/formatters/find/FindSettings.ts b/src/v2/formatters/find/FindSettings.ts
new file mode 100644
index 00000000..a0887861
--- /dev/null
+++ b/src/v2/formatters/find/FindSettings.ts
@@ -0,0 +1,8 @@
+import { ASettings } from "../ASettings";
+
+export class FindSettings extends ASettings {
+ // token settings
+ public findFormatting() {
+ return this.configurationManager.get("findFormatting") ? true : false;
+ }
+}
From cc4e797836c5ca31e282d8f5630067f968d8b388 Mon Sep 17 00:00:00 2001
From: sjonynaite
Date: Mon, 26 Aug 2024 10:17:16 +0300
Subject: [PATCH 03/79] Updated test structure
---
.../1find-firstLastNextPrev}/input.p | 0
.../1find-firstLastNextPrev}/target.p | 0
.../2find-multipleConditions}/input.p | 0
.../2find-multipleConditions}/target.p | 0
.../3find-multipleConditions-()}/input.p | 0
.../3find-multipleConditions-()}/target.p | 0
.../4find-multipleConditions-()2}/input.p | 0
.../4find-multipleConditions-()2}/target.p | 0
.../functionalTests/{find-spaces => find/5find-spaces}/input.p | 0
.../functionalTests/{find-spaces => find/5find-spaces}/target.p | 0
.../{find-useIndex => find/6find-useIndex}/input.p | 0
.../{find-useIndex => find/6find-useIndex}/target.p | 0
12 files changed, 0 insertions(+), 0 deletions(-)
rename resources/functionalTests/{find-firstLastNextPrev => find/1find-firstLastNextPrev}/input.p (100%)
rename resources/functionalTests/{find-firstLastNextPrev => find/1find-firstLastNextPrev}/target.p (100%)
rename resources/functionalTests/{find-multipleConditions => find/2find-multipleConditions}/input.p (100%)
rename resources/functionalTests/{find-multipleConditions => find/2find-multipleConditions}/target.p (100%)
rename resources/functionalTests/{find-multipleConditions-() => find/3find-multipleConditions-()}/input.p (100%)
rename resources/functionalTests/{find-multipleConditions-() => find/3find-multipleConditions-()}/target.p (100%)
rename resources/functionalTests/{find-multipleConditions-()2 => find/4find-multipleConditions-()2}/input.p (100%)
rename resources/functionalTests/{find-multipleConditions-()2 => find/4find-multipleConditions-()2}/target.p (100%)
rename resources/functionalTests/{find-spaces => find/5find-spaces}/input.p (100%)
rename resources/functionalTests/{find-spaces => find/5find-spaces}/target.p (100%)
rename resources/functionalTests/{find-useIndex => find/6find-useIndex}/input.p (100%)
rename resources/functionalTests/{find-useIndex => find/6find-useIndex}/target.p (100%)
diff --git a/resources/functionalTests/find-firstLastNextPrev/input.p b/resources/functionalTests/find/1find-firstLastNextPrev/input.p
similarity index 100%
rename from resources/functionalTests/find-firstLastNextPrev/input.p
rename to resources/functionalTests/find/1find-firstLastNextPrev/input.p
diff --git a/resources/functionalTests/find-firstLastNextPrev/target.p b/resources/functionalTests/find/1find-firstLastNextPrev/target.p
similarity index 100%
rename from resources/functionalTests/find-firstLastNextPrev/target.p
rename to resources/functionalTests/find/1find-firstLastNextPrev/target.p
diff --git a/resources/functionalTests/find-multipleConditions/input.p b/resources/functionalTests/find/2find-multipleConditions/input.p
similarity index 100%
rename from resources/functionalTests/find-multipleConditions/input.p
rename to resources/functionalTests/find/2find-multipleConditions/input.p
diff --git a/resources/functionalTests/find-multipleConditions/target.p b/resources/functionalTests/find/2find-multipleConditions/target.p
similarity index 100%
rename from resources/functionalTests/find-multipleConditions/target.p
rename to resources/functionalTests/find/2find-multipleConditions/target.p
diff --git a/resources/functionalTests/find-multipleConditions-()/input.p b/resources/functionalTests/find/3find-multipleConditions-()/input.p
similarity index 100%
rename from resources/functionalTests/find-multipleConditions-()/input.p
rename to resources/functionalTests/find/3find-multipleConditions-()/input.p
diff --git a/resources/functionalTests/find-multipleConditions-()/target.p b/resources/functionalTests/find/3find-multipleConditions-()/target.p
similarity index 100%
rename from resources/functionalTests/find-multipleConditions-()/target.p
rename to resources/functionalTests/find/3find-multipleConditions-()/target.p
diff --git a/resources/functionalTests/find-multipleConditions-()2/input.p b/resources/functionalTests/find/4find-multipleConditions-()2/input.p
similarity index 100%
rename from resources/functionalTests/find-multipleConditions-()2/input.p
rename to resources/functionalTests/find/4find-multipleConditions-()2/input.p
diff --git a/resources/functionalTests/find-multipleConditions-()2/target.p b/resources/functionalTests/find/4find-multipleConditions-()2/target.p
similarity index 100%
rename from resources/functionalTests/find-multipleConditions-()2/target.p
rename to resources/functionalTests/find/4find-multipleConditions-()2/target.p
diff --git a/resources/functionalTests/find-spaces/input.p b/resources/functionalTests/find/5find-spaces/input.p
similarity index 100%
rename from resources/functionalTests/find-spaces/input.p
rename to resources/functionalTests/find/5find-spaces/input.p
diff --git a/resources/functionalTests/find-spaces/target.p b/resources/functionalTests/find/5find-spaces/target.p
similarity index 100%
rename from resources/functionalTests/find-spaces/target.p
rename to resources/functionalTests/find/5find-spaces/target.p
diff --git a/resources/functionalTests/find-useIndex/input.p b/resources/functionalTests/find/6find-useIndex/input.p
similarity index 100%
rename from resources/functionalTests/find-useIndex/input.p
rename to resources/functionalTests/find/6find-useIndex/input.p
diff --git a/resources/functionalTests/find-useIndex/target.p b/resources/functionalTests/find/6find-useIndex/target.p
similarity index 100%
rename from resources/functionalTests/find-useIndex/target.p
rename to resources/functionalTests/find/6find-useIndex/target.p
From 329e1c5be21c3aa319d4b2182c677634c1db2d8c Mon Sep 17 00:00:00 2001
From: sjonynaite
Date: Mon, 26 Aug 2024 15:28:41 +0300
Subject: [PATCH 04/79] Update AssignFormatter
---
.../find/1find-firstLastNextPrev/target.p | 8 -
.../input.p | 5 +-
.../find/1firstLastNextPrev/target.p | 11 ++
.../find/2find-multipleConditions/input.p | 8 -
.../find/2find-multipleConditions/target.p | 8 -
.../find/2multipleConditions/input.p | 5 +
.../find/2multipleConditions/target.p | 5 +
.../find/3find-multipleConditions-()/input.p | 6 -
.../find/3find-multipleConditions-()/target.p | 6 -
.../find/3multipleConditions-()/input.p | 4 +
.../find/3multipleConditions-()/target.p | 5 +
.../find/4find-multipleConditions-()2/input.p | 6 -
.../4find-multipleConditions-()2/target.p | 6 -
.../find/4multipleConditions-()2/input.p | 4 +
.../find/4multipleConditions-()2/target.p | 5 +
.../functionalTests/find/5find-spaces/input.p | 5 -
.../find/5find-spaces/target.p | 5 -
.../functionalTests/find/5spaces/input.p | 4 +
.../functionalTests/find/5spaces/target.p | 5 +
.../find/6find-useIndex/target.p | 6 -
.../{6find-useIndex => 6useIndex}/input.p | 3 +-
.../functionalTests/find/6useIndex/target.p | 5 +
.../functionalTests/find/7noWhere/input.p | 5 +
.../functionalTests/find/7noWhere/target.p | 4 +
src/model/SyntaxNodeType.ts | 1 +
src/v2/formatters/find/FindFormatter.ts | 155 +++---------------
26 files changed, 93 insertions(+), 197 deletions(-)
delete mode 100644 resources/functionalTests/find/1find-firstLastNextPrev/target.p
rename resources/functionalTests/find/{1find-firstLastNextPrev => 1firstLastNextPrev}/input.p (61%)
create mode 100644 resources/functionalTests/find/1firstLastNextPrev/target.p
delete mode 100644 resources/functionalTests/find/2find-multipleConditions/input.p
delete mode 100644 resources/functionalTests/find/2find-multipleConditions/target.p
create mode 100644 resources/functionalTests/find/2multipleConditions/input.p
create mode 100644 resources/functionalTests/find/2multipleConditions/target.p
delete mode 100644 resources/functionalTests/find/3find-multipleConditions-()/input.p
delete mode 100644 resources/functionalTests/find/3find-multipleConditions-()/target.p
create mode 100644 resources/functionalTests/find/3multipleConditions-()/input.p
create mode 100644 resources/functionalTests/find/3multipleConditions-()/target.p
delete mode 100644 resources/functionalTests/find/4find-multipleConditions-()2/input.p
delete mode 100644 resources/functionalTests/find/4find-multipleConditions-()2/target.p
create mode 100644 resources/functionalTests/find/4multipleConditions-()2/input.p
create mode 100644 resources/functionalTests/find/4multipleConditions-()2/target.p
delete mode 100644 resources/functionalTests/find/5find-spaces/input.p
delete mode 100644 resources/functionalTests/find/5find-spaces/target.p
create mode 100644 resources/functionalTests/find/5spaces/input.p
create mode 100644 resources/functionalTests/find/5spaces/target.p
delete mode 100644 resources/functionalTests/find/6find-useIndex/target.p
rename resources/functionalTests/find/{6find-useIndex => 6useIndex}/input.p (61%)
create mode 100644 resources/functionalTests/find/6useIndex/target.p
create mode 100644 resources/functionalTests/find/7noWhere/input.p
create mode 100644 resources/functionalTests/find/7noWhere/target.p
diff --git a/resources/functionalTests/find/1find-firstLastNextPrev/target.p b/resources/functionalTests/find/1find-firstLastNextPrev/target.p
deleted file mode 100644
index 0b3d1939..00000000
--- a/resources/functionalTests/find/1find-firstLastNextPrev/target.p
+++ /dev/null
@@ -1,8 +0,0 @@
-/* formatterSettingsOverride */
-/* { "AblFormatter.findFormatting": true,
-"abl.completion.upperCase": true}*/
-
-FIND FIRST Customer WHERE Customer.CustNum = 5 NO-LOCK NO-ERROR.
-FIND LAST Customer WHERE Customer.CustNum = 5 NO-LOCK NO-ERROR.
-FIND NEXT Customer WHERE Customer.CustNum = 5 NO-LOCK NO-ERROR.
-FIND PREV Customer WHERE Customer.CustNum = 5 NO-LOCK NO-ERROR.
\ No newline at end of file
diff --git a/resources/functionalTests/find/1find-firstLastNextPrev/input.p b/resources/functionalTests/find/1firstLastNextPrev/input.p
similarity index 61%
rename from resources/functionalTests/find/1find-firstLastNextPrev/input.p
rename to resources/functionalTests/find/1firstLastNextPrev/input.p
index b2b68c7a..699c8767 100644
--- a/resources/functionalTests/find/1find-firstLastNextPrev/input.p
+++ b/resources/functionalTests/find/1firstLastNextPrev/input.p
@@ -1,8 +1,7 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.findFormatting": true,
-"abl.completion.upperCase": true}*/
+/* { "AblFormatter.findFormatting": true}*/
FIND FIRST Customer WHERE Customer.CustNum = 5 NO-LOCK NO-ERROR.
FIND LAST Customer WHERE Customer.CustNum = 5 NO-LOCK NO-ERROR.
-FIND NEXT Customer WHERE Customer.CustNum = 5 NO-LOCK NO-ERROR.
+FIND NEXT Customer WHERE Customer.CustNum = 5 NO-LOCK NO-ERROR.
FIND PREV Customer WHERE Customer.CustNum = 5 NO-LOCK NO-ERROR.
\ No newline at end of file
diff --git a/resources/functionalTests/find/1firstLastNextPrev/target.p b/resources/functionalTests/find/1firstLastNextPrev/target.p
new file mode 100644
index 00000000..cfc38741
--- /dev/null
+++ b/resources/functionalTests/find/1firstLastNextPrev/target.p
@@ -0,0 +1,11 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.findFormatting": true}*/
+
+FIND FIRST Customer WHERE
+ Customer.CustNum = 5 NO-LOCK NO-ERROR.
+FIND LAST Customer WHERE
+ Customer.CustNum = 5 NO-LOCK NO-ERROR.
+FIND NEXT Customer WHERE
+ Customer.CustNum = 5 NO-LOCK NO-ERROR.
+FIND PREV Customer WHERE
+ Customer.CustNum = 5 NO-LOCK NO-ERROR.
\ No newline at end of file
diff --git a/resources/functionalTests/find/2find-multipleConditions/input.p b/resources/functionalTests/find/2find-multipleConditions/input.p
deleted file mode 100644
index 0747c5d1..00000000
--- a/resources/functionalTests/find/2find-multipleConditions/input.p
+++ /dev/null
@@ -1,8 +0,0 @@
-/* formatterSettingsOverride */
-/* { "AblFormatter.findFormatting": true,
-"abl.completion.upperCase": true}*/
-
-FIND Customer WHERE
-Customer.CustNum = 5 AND Customer.CustNum = 6 OR
- Customer.CustNum = 7 AND
- Customer.CustNum = 8 no-lock no-error.
\ No newline at end of file
diff --git a/resources/functionalTests/find/2find-multipleConditions/target.p b/resources/functionalTests/find/2find-multipleConditions/target.p
deleted file mode 100644
index 5a116d06..00000000
--- a/resources/functionalTests/find/2find-multipleConditions/target.p
+++ /dev/null
@@ -1,8 +0,0 @@
-/* formatterSettingsOverride */
-/* { "AblFormatter.findFormatting": true,
-"abl.completion.upperCase": true}*/
-
-FIND Customer WHERE Customer.CustNum = 5 AND
- Customer.CustNum = 6 OR
- Customer.CustNum = 7 AND
- Customer.CustNum = 8 no-lock no-error.
\ No newline at end of file
diff --git a/resources/functionalTests/find/2multipleConditions/input.p b/resources/functionalTests/find/2multipleConditions/input.p
new file mode 100644
index 00000000..50c502ad
--- /dev/null
+++ b/resources/functionalTests/find/2multipleConditions/input.p
@@ -0,0 +1,5 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.findFormatting": true}*/
+
+FIND Customer WHERE
+Customer.CustNum = 5 AND Customer.CustNum = 6 OR Customer.CustNum = 8 no-lock no-error.
\ No newline at end of file
diff --git a/resources/functionalTests/find/2multipleConditions/target.p b/resources/functionalTests/find/2multipleConditions/target.p
new file mode 100644
index 00000000..fe069370
--- /dev/null
+++ b/resources/functionalTests/find/2multipleConditions/target.p
@@ -0,0 +1,5 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.findFormatting": true}*/
+
+FIND Customer WHERE
+ Customer.CustNum = 5 AND Customer.CustNum = 6 OR Customer.CustNum = 8 no-lock no-error.
\ No newline at end of file
diff --git a/resources/functionalTests/find/3find-multipleConditions-()/input.p b/resources/functionalTests/find/3find-multipleConditions-()/input.p
deleted file mode 100644
index 46cf0147..00000000
--- a/resources/functionalTests/find/3find-multipleConditions-()/input.p
+++ /dev/null
@@ -1,6 +0,0 @@
-/* formatterSettingsOverride */
-/* { "AblFormatter.findFormatting": true,
-"abl.completion.upperCase": true}*/
-
-FIND Customer WHERE (Customer.CustNum > 50 AND Customer.CustNum < 100) OR
- Customer.CustNum > 200 NO-ERROR.
\ No newline at end of file
diff --git a/resources/functionalTests/find/3find-multipleConditions-()/target.p b/resources/functionalTests/find/3find-multipleConditions-()/target.p
deleted file mode 100644
index 37f2585b..00000000
--- a/resources/functionalTests/find/3find-multipleConditions-()/target.p
+++ /dev/null
@@ -1,6 +0,0 @@
-/* formatterSettingsOverride */
-/* { "AblFormatter.findFormatting": true,
-"abl.completion.upperCase": true}*/
-
-FIND Customer WHERE (Customer.CustNum > 50 AND Customer.CustNum < 100) OR
- Customer.CustNum > 200 NO-ERROR.
\ No newline at end of file
diff --git a/resources/functionalTests/find/3multipleConditions-()/input.p b/resources/functionalTests/find/3multipleConditions-()/input.p
new file mode 100644
index 00000000..57b76b6b
--- /dev/null
+++ b/resources/functionalTests/find/3multipleConditions-()/input.p
@@ -0,0 +1,4 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.findFormatting": true}*/
+
+FIND Customer WHERE (Customer.CustNum > 50 AND Customer.CustNum < 100) OR Customer.CustNum > 200 NO-ERROR.
\ No newline at end of file
diff --git a/resources/functionalTests/find/3multipleConditions-()/target.p b/resources/functionalTests/find/3multipleConditions-()/target.p
new file mode 100644
index 00000000..2cdc88aa
--- /dev/null
+++ b/resources/functionalTests/find/3multipleConditions-()/target.p
@@ -0,0 +1,5 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.findFormatting": true}*/
+
+FIND Customer WHERE
+ (Customer.CustNum > 50 AND Customer.CustNum < 100) OR Customer.CustNum > 200 NO-ERROR.
\ No newline at end of file
diff --git a/resources/functionalTests/find/4find-multipleConditions-()2/input.p b/resources/functionalTests/find/4find-multipleConditions-()2/input.p
deleted file mode 100644
index 34d84c22..00000000
--- a/resources/functionalTests/find/4find-multipleConditions-()2/input.p
+++ /dev/null
@@ -1,6 +0,0 @@
-/* formatterSettingsOverride */
-/* { "AblFormatter.findFormatting": true,
-"abl.completion.upperCase": true}*/
-
-FIND Order WHERE (Order.OrderStatus = "Shipped" AND (Order.ShipDate > TODAY - 7)) OR
-(Order.OrderStatus = "Pending" AND (Order.OrderDate = TODAY)) no-lock.
\ No newline at end of file
diff --git a/resources/functionalTests/find/4find-multipleConditions-()2/target.p b/resources/functionalTests/find/4find-multipleConditions-()2/target.p
deleted file mode 100644
index 0b14b407..00000000
--- a/resources/functionalTests/find/4find-multipleConditions-()2/target.p
+++ /dev/null
@@ -1,6 +0,0 @@
-/* formatterSettingsOverride */
-/* { "AblFormatter.findFormatting": true,
-"abl.completion.upperCase": true}*/
-
-FIND Order WHERE (Order.OrderStatus = "Shipped" AND (Order.ShipDate > TODAY - 7)) OR
- (Order.OrderStatus = "Pending" AND (Order.OrderDate = TODAY)) no-lock.
\ No newline at end of file
diff --git a/resources/functionalTests/find/4multipleConditions-()2/input.p b/resources/functionalTests/find/4multipleConditions-()2/input.p
new file mode 100644
index 00000000..4eb239d4
--- /dev/null
+++ b/resources/functionalTests/find/4multipleConditions-()2/input.p
@@ -0,0 +1,4 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.findFormatting": true}*/
+
+FIND Order WHERE (Order.OrderStatus = "Shipped" AND (Order.ShipDate > TODAY - 7)) OR (Order.OrderStatus = "Pending" AND (Order.OrderDate = TODAY)) no-lock.
\ No newline at end of file
diff --git a/resources/functionalTests/find/4multipleConditions-()2/target.p b/resources/functionalTests/find/4multipleConditions-()2/target.p
new file mode 100644
index 00000000..39b6cdf3
--- /dev/null
+++ b/resources/functionalTests/find/4multipleConditions-()2/target.p
@@ -0,0 +1,5 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.findFormatting": true}*/
+
+FIND Order WHERE
+ (Order.OrderStatus = "Shipped" AND (Order.ShipDate > TODAY - 7)) OR (Order.OrderStatus = "Pending" AND (Order.OrderDate = TODAY)) no-lock.
\ No newline at end of file
diff --git a/resources/functionalTests/find/5find-spaces/input.p b/resources/functionalTests/find/5find-spaces/input.p
deleted file mode 100644
index d70cac20..00000000
--- a/resources/functionalTests/find/5find-spaces/input.p
+++ /dev/null
@@ -1,5 +0,0 @@
-/* formatterSettingsOverride */
-/* { "AblFormatter.findFormatting": true,
-"abl.completion.upperCase": true}*/
-
-FIND Customer WHERE Customer.CustNum = 5 NO-LOCK NO-ERROR.
\ No newline at end of file
diff --git a/resources/functionalTests/find/5find-spaces/target.p b/resources/functionalTests/find/5find-spaces/target.p
deleted file mode 100644
index 9996f9e2..00000000
--- a/resources/functionalTests/find/5find-spaces/target.p
+++ /dev/null
@@ -1,5 +0,0 @@
-/* formatterSettingsOverride */
-/* { "AblFormatter.findFormatting": true,
-"abl.completion.upperCase": true}*/
-
-FIND Customer WHERE Customer.CustNum = 5 NO-LOCK NO-ERROR.
\ No newline at end of file
diff --git a/resources/functionalTests/find/5spaces/input.p b/resources/functionalTests/find/5spaces/input.p
new file mode 100644
index 00000000..8a056f56
--- /dev/null
+++ b/resources/functionalTests/find/5spaces/input.p
@@ -0,0 +1,4 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.findFormatting": true}*/
+
+ FIND FIRST Customer WHERE Customer.CustNum = 5 NO-LOCK NO-ERROR.
\ No newline at end of file
diff --git a/resources/functionalTests/find/5spaces/target.p b/resources/functionalTests/find/5spaces/target.p
new file mode 100644
index 00000000..e0b3888c
--- /dev/null
+++ b/resources/functionalTests/find/5spaces/target.p
@@ -0,0 +1,5 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.findFormatting": true}*/
+
+ FIND FIRST Customer WHERE
+ Customer.CustNum = 5 NO-LOCK NO-ERROR.
\ No newline at end of file
diff --git a/resources/functionalTests/find/6find-useIndex/target.p b/resources/functionalTests/find/6find-useIndex/target.p
deleted file mode 100644
index 4fcd22c0..00000000
--- a/resources/functionalTests/find/6find-useIndex/target.p
+++ /dev/null
@@ -1,6 +0,0 @@
-/* formatterSettingsOverride */
-/* { "AblFormatter.findFormatting": true,
-"abl.completion.upperCase": true}*/
-
-find Order where Order.OrderStatus = "Shipped" and
- Order.ShipDate = today use-index OrderNum.
\ No newline at end of file
diff --git a/resources/functionalTests/find/6find-useIndex/input.p b/resources/functionalTests/find/6useIndex/input.p
similarity index 61%
rename from resources/functionalTests/find/6find-useIndex/input.p
rename to resources/functionalTests/find/6useIndex/input.p
index 6a13e2cc..73cb4551 100644
--- a/resources/functionalTests/find/6find-useIndex/input.p
+++ b/resources/functionalTests/find/6useIndex/input.p
@@ -1,5 +1,4 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.findFormatting": true,
-"abl.completion.upperCase": true}*/
+/* { "AblFormatter.findFormatting": true}*/
find Order where Order.OrderStatus = "Shipped" and Order.ShipDate = today use-index OrderNum.
\ No newline at end of file
diff --git a/resources/functionalTests/find/6useIndex/target.p b/resources/functionalTests/find/6useIndex/target.p
new file mode 100644
index 00000000..4b8db549
--- /dev/null
+++ b/resources/functionalTests/find/6useIndex/target.p
@@ -0,0 +1,5 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.findFormatting": true}*/
+
+find Order where
+ Order.OrderStatus = "Shipped" and Order.ShipDate = today use-index OrderNum.
\ No newline at end of file
diff --git a/resources/functionalTests/find/7noWhere/input.p b/resources/functionalTests/find/7noWhere/input.p
new file mode 100644
index 00000000..b362157c
--- /dev/null
+++ b/resources/functionalTests/find/7noWhere/input.p
@@ -0,0 +1,5 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.findFormatting": true}*/
+
+find first b_vac
+no-lock no-error.
\ No newline at end of file
diff --git a/resources/functionalTests/find/7noWhere/target.p b/resources/functionalTests/find/7noWhere/target.p
new file mode 100644
index 00000000..82462207
--- /dev/null
+++ b/resources/functionalTests/find/7noWhere/target.p
@@ -0,0 +1,4 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.findFormatting": true}*/
+
+find first b_vac no-lock no-error.
\ No newline at end of file
diff --git a/src/model/SyntaxNodeType.ts b/src/model/SyntaxNodeType.ts
index 286811e8..f0a4c182 100644
--- a/src/model/SyntaxNodeType.ts
+++ b/src/model/SyntaxNodeType.ts
@@ -19,6 +19,7 @@ export enum SyntaxNodeType {
WhereClause = "where_clause",
AssignStatement = "assign_statement",
Assignment = "assignment",
+ Identifier = "identifier",
SourceCode = "source_code",
ForStatement = "for_statement",
QueryTuning = "query_tuning",
diff --git a/src/v2/formatters/find/FindFormatter.ts b/src/v2/formatters/find/FindFormatter.ts
index 79750243..68d3338f 100644
--- a/src/v2/formatters/find/FindFormatter.ts
+++ b/src/v2/formatters/find/FindFormatter.ts
@@ -9,14 +9,6 @@ import { RegisterFormatter } from "../../formatterFramework/formatterDecorator";
import { FindSettings } from "./FindSettings";
import { IConfigurationManager } from "../../../utils/IConfigurationManager";
-/**
- * Note: The WHERE clause block with multiple LogicalExpressions does not align correctly
- * during the first formatting if there are spaces before the WHERE clause.
- *
- * Question: Should QueryTuning also be formatted in a similar manner to LogicalExpressions,
- * with aligned spacing and line breaks?
- */
-
@RegisterFormatter
export class FindFormatter extends AFormatter implements IFormatter {
private startColumn = 0;
@@ -51,7 +43,7 @@ export class FindFormatter extends AFormatter implements IFormatter {
node: SyntaxNode,
fullText: Readonly
) {
- this.startColumn = this.getStartColumn(node);
+ this.startColumn = node.startPosition.column;
this.findBodyValue = this.getFindStatementBlock(node, fullText);
}
@@ -60,35 +52,40 @@ export class FindFormatter extends AFormatter implements IFormatter {
fullText: Readonly
): string {
let resultString = "";
+ let alignColumn = 0;
node.children.forEach((child) => {
+ if (child.type === SyntaxNodeType.Identifier) {
+ alignColumn = this.startColumn + resultString.length;
+ }
resultString = resultString.concat(
- this.getFindExpressionString(child, fullText)
+ this.getFindExpressionString(child, fullText, alignColumn)
);
});
- resultString = resultString.concat(".");
- return resultString;
+ return resultString + ".";
}
private getFindExpressionString(
node: SyntaxNode,
- fullText: Readonly
+ fullText: Readonly,
+ alignColumn: number
): string {
let newString = "";
switch (node.type) {
case SyntaxNodeType.FindKeyword:
- newString =
- " ".repeat(this.startColumn) +
- FormatterHelper.getCurrentText(node, fullText).trim();
+ newString = FormatterHelper.getCurrentText(
+ node,
+ fullText
+ ).trim();
break;
case SyntaxNodeType.WhereClause:
- newString = this.getWhereClauseBlock(node, fullText);
- break;
- case SyntaxNodeType.QueryTuning:
- newString =
- " " + FormatterHelper.getCurrentText(node, fullText).trim();
+ newString = this.getWhereClauseBlock(
+ node,
+ fullText,
+ alignColumn
+ );
break;
default:
const text = FormatterHelper.getCurrentText(
@@ -104,131 +101,33 @@ export class FindFormatter extends AFormatter implements IFormatter {
private getWhereClauseBlock(
node: SyntaxNode,
- fullText: Readonly
+ fullText: Readonly,
+ alignColumn: number
): string {
let resultString = "";
node.children.forEach((child) => {
switch (child.type) {
- case SyntaxNodeType.LogicalExpression:
- resultString = resultString.concat(
- this.getLogicalExpressionBlock(
- child,
- fullText,
- child.startPosition.column
- )
- );
- break;
case SyntaxNodeType.WhereKeyword:
resultString = resultString.concat(
" ",
- FormatterHelper.getCurrentText(child, fullText).trim()
- );
- break;
- case SyntaxNodeType.ComparisonExpression:
- resultString = resultString.concat(
- this.getComparisonExpressionBlock(child, fullText)
+ FormatterHelper.getCurrentText(child, fullText).trim(),
+ fullText.eolDelimiter,
+ " ".repeat(alignColumn)
);
break;
default:
const text = FormatterHelper.getCurrentText(
- node,
+ child,
fullText
).trim();
- resultString = text.length === 0 ? "" : " " + text;
+ resultString = resultString.concat(
+ text.length === 0 ? "" : " " + text
+ );
break;
}
});
return resultString;
}
-
- private getComparisonExpressionBlock(
- node: SyntaxNode,
- fullText: Readonly
- ): string {
- let resultString = "";
-
- node.children.forEach((child) => {
- resultString = resultString.concat(
- " ",
- FormatterHelper.getCurrentText(child, fullText).trim()
- );
- });
-
- return resultString;
- }
-
- private getLogicalExpressionBlock(
- node: SyntaxNode,
- fullText: Readonly,
- LogicalExpressionStartColumn: number
- ): string {
- let resultString = "";
-
- node.children.forEach((child) => {
- resultString = resultString.concat(
- this.getLogicalExpressionString(
- child,
- fullText,
- LogicalExpressionStartColumn
- )
- );
- });
-
- return resultString;
- }
-
- private getLogicalExpressionString(
- node: SyntaxNode,
- fullText: Readonly,
- LogicalExpressionStartColumn: number
- ): string {
- let newString = "";
-
- switch (node.type) {
- case SyntaxNodeType.OrKeyword:
- case SyntaxNodeType.AndKeyword:
- newString =
- " " +
- FormatterHelper.getCurrentText(node, fullText).trim() +
- fullText.eolDelimiter +
- " ".repeat(LogicalExpressionStartColumn);
- break;
- case SyntaxNodeType.LogicalExpression:
- newString = this.getLogicalExpressionBlock(
- node,
- fullText,
- LogicalExpressionStartColumn
- );
- break;
- default:
- const text = FormatterHelper.getCurrentText(
- node,
- fullText
- ).trim();
- newString = text.length === 0 ? "" : " " + text;
- break;
- }
-
- return newString;
- }
-
- private getStartColumn(node: SyntaxNode): number {
- if (node.type === SyntaxNodeType.FindKeyword) {
- return node.startPosition.column;
- } else {
- return this.findParentFindStatementStartColumn(node);
- }
- }
-
- private findParentFindStatementStartColumn(node: SyntaxNode): number {
- if (node.parent === null) {
- return 0;
- }
-
- return node.type === SyntaxNodeType.FindKeyword
- ? node.startPosition.column
- : this.findParentFindStatementStartColumn(node.parent);
- }
}
From e43c32a6d0c666123c89d5e768cbc66b402dc7da Mon Sep 17 00:00:00 2001
From: sjonynaite
Date: Mon, 26 Aug 2024 16:46:55 +0300
Subject: [PATCH 05/79] Not working new For Formatter
---
.../{ => for}/for1-each-false/input.p | 0
.../{ => for}/for1-each-false/target.p | 0
.../{ => for}/for2-each-true/input.p | 0
.../{ => for}/for2-each-true/target.p | 0
.../{ => for}/for3-each-where/input.p | 0
.../{ => for}/for3-each-where/target.p | 0
.../{ => for}/for4-each-where3/input.p | 0
.../{ => for}/for4-each-where3/target.p | 0
src/model/SyntaxNodeType.ts | 2 +
.../enableFormatterDecorators.ts | 2 +
src/v2/formatters/for/ForFormatter.ts | 157 ++++++++++++++++++
src/v2/formatters/for/ForSettings.ts | 8 +
12 files changed, 169 insertions(+)
rename resources/functionalTests/{ => for}/for1-each-false/input.p (100%)
rename resources/functionalTests/{ => for}/for1-each-false/target.p (100%)
rename resources/functionalTests/{ => for}/for2-each-true/input.p (100%)
rename resources/functionalTests/{ => for}/for2-each-true/target.p (100%)
rename resources/functionalTests/{ => for}/for3-each-where/input.p (100%)
rename resources/functionalTests/{ => for}/for3-each-where/target.p (100%)
rename resources/functionalTests/{ => for}/for4-each-where3/input.p (100%)
rename resources/functionalTests/{ => for}/for4-each-where3/target.p (100%)
create mode 100644 src/v2/formatters/for/ForFormatter.ts
create mode 100644 src/v2/formatters/for/ForSettings.ts
diff --git a/resources/functionalTests/for1-each-false/input.p b/resources/functionalTests/for/for1-each-false/input.p
similarity index 100%
rename from resources/functionalTests/for1-each-false/input.p
rename to resources/functionalTests/for/for1-each-false/input.p
diff --git a/resources/functionalTests/for1-each-false/target.p b/resources/functionalTests/for/for1-each-false/target.p
similarity index 100%
rename from resources/functionalTests/for1-each-false/target.p
rename to resources/functionalTests/for/for1-each-false/target.p
diff --git a/resources/functionalTests/for2-each-true/input.p b/resources/functionalTests/for/for2-each-true/input.p
similarity index 100%
rename from resources/functionalTests/for2-each-true/input.p
rename to resources/functionalTests/for/for2-each-true/input.p
diff --git a/resources/functionalTests/for2-each-true/target.p b/resources/functionalTests/for/for2-each-true/target.p
similarity index 100%
rename from resources/functionalTests/for2-each-true/target.p
rename to resources/functionalTests/for/for2-each-true/target.p
diff --git a/resources/functionalTests/for3-each-where/input.p b/resources/functionalTests/for/for3-each-where/input.p
similarity index 100%
rename from resources/functionalTests/for3-each-where/input.p
rename to resources/functionalTests/for/for3-each-where/input.p
diff --git a/resources/functionalTests/for3-each-where/target.p b/resources/functionalTests/for/for3-each-where/target.p
similarity index 100%
rename from resources/functionalTests/for3-each-where/target.p
rename to resources/functionalTests/for/for3-each-where/target.p
diff --git a/resources/functionalTests/for4-each-where3/input.p b/resources/functionalTests/for/for4-each-where3/input.p
similarity index 100%
rename from resources/functionalTests/for4-each-where3/input.p
rename to resources/functionalTests/for/for4-each-where3/input.p
diff --git a/resources/functionalTests/for4-each-where3/target.p b/resources/functionalTests/for/for4-each-where3/target.p
similarity index 100%
rename from resources/functionalTests/for4-each-where3/target.p
rename to resources/functionalTests/for/for4-each-where3/target.p
diff --git a/src/model/SyntaxNodeType.ts b/src/model/SyntaxNodeType.ts
index 26f88e24..35461cc5 100644
--- a/src/model/SyntaxNodeType.ts
+++ b/src/model/SyntaxNodeType.ts
@@ -19,6 +19,7 @@ export enum SyntaxNodeType {
WhereClause = "where_clause",
AssignStatement = "assign_statement",
Assignment = "assignment",
+ Identifier = "identifier",
SourceCode = "source_code",
ForStatement = "for_statement",
QueryTuning = "query_tuning",
@@ -55,4 +56,5 @@ export enum SyntaxNodeType {
EachKeyword = "EACH",
EndKeyword = "END",
IfKeyword = "IF",
+ ForKeyword = "FOR",
}
diff --git a/src/v2/formatterFramework/enableFormatterDecorators.ts b/src/v2/formatterFramework/enableFormatterDecorators.ts
index 4881628c..12668e14 100644
--- a/src/v2/formatterFramework/enableFormatterDecorators.ts
+++ b/src/v2/formatterFramework/enableFormatterDecorators.ts
@@ -4,6 +4,7 @@ import { IfFormatter } from "../formatters/if/IfFormatter";
import { DefineFormatter } from "../formatters/define/DefineFormatter";
import { UsingFormatter } from "../formatters/using/UsingFormatter";
import { CaseFormatter } from "../formatters/case/CaseFormatter";
+import { ForFormatter } from "../formatters/for/ForFormatter";
// needed just for enabling decorators. Decorators does not work if there is no usage of a class in the reachable code
export function enableFormatterDecorators(): void {
@@ -13,4 +14,5 @@ export function enableFormatterDecorators(): void {
DefineFormatter;
UsingFormatter;
CaseFormatter;
+ ForFormatter;
}
diff --git a/src/v2/formatters/for/ForFormatter.ts b/src/v2/formatters/for/ForFormatter.ts
new file mode 100644
index 00000000..69969c42
--- /dev/null
+++ b/src/v2/formatters/for/ForFormatter.ts
@@ -0,0 +1,157 @@
+import { SyntaxNode } from "web-tree-sitter";
+import { IFormatter } from "../../formatterFramework/IFormatter";
+import { SyntaxNodeType } from "../../../model/SyntaxNodeType";
+import { CodeEdit } from "../../model/CodeEdit";
+import { FullText } from "../../model/FullText";
+import { FormatterHelper } from "../../formatterFramework/FormatterHelper";
+import { AFormatter } from "../AFormatter";
+import { RegisterFormatter } from "../../formatterFramework/formatterDecorator";
+import { ForSettings } from "./ForSettings";
+import { IConfigurationManager } from "../../../utils/IConfigurationManager";
+
+@RegisterFormatter
+export class ForFormatter extends AFormatter implements IFormatter {
+ private startColumn = 0;
+ private forBodyValue = "";
+
+ public static readonly formatterLabel = "forFormatting";
+ private readonly settings: ForSettings;
+
+ public constructor(configurationManager: IConfigurationManager) {
+ super(configurationManager);
+ this.settings = new ForSettings(configurationManager);
+ }
+
+ match(node: Readonly): boolean {
+ return node.type === SyntaxNodeType.ForStatement;
+ }
+
+ parse(
+ node: Readonly,
+ fullText: Readonly
+ ): CodeEdit | CodeEdit[] | undefined {
+ this.collectCaseStructure(node, fullText);
+ return this.getCodeEdit(
+ node,
+ FormatterHelper.getCurrentText(node, fullText),
+ this.forBodyValue,
+ fullText
+ );
+ }
+
+ private collectCaseStructure(
+ node: SyntaxNode,
+ fullText: Readonly
+ ) {
+ this.startColumn = node.startPosition.column;
+ console.log("startColumn");
+ console.log(this.startColumn);
+ this.forBodyValue = this.getForStatementBlock(node, fullText);
+ }
+
+ private getForStatementBlock(
+ node: SyntaxNode,
+ fullText: Readonly
+ ): string {
+ let resultString = "";
+ let alignColumn = 0;
+
+ node.children.forEach((child) => {
+ console.log("BEFOREE:::::");
+ console.log("child.type:", child.type);
+ console.log("resultString:", resultString);
+
+ if (child.type === SyntaxNodeType.Identifier) {
+ alignColumn = this.startColumn + resultString.length;
+ }
+ resultString = resultString.concat(
+ this.getForExpressionString(child, fullText, alignColumn)
+ );
+
+ console.log("AFFTERRR:::::");
+ console.log("child.type:", child.type);
+ console.log("resultString:", resultString);
+ });
+
+ return resultString;
+ }
+
+ private getForExpressionString(
+ node: SyntaxNode,
+ fullText: Readonly,
+ alignColumn: number
+ ): string {
+ let newString = "";
+
+ switch (node.type) {
+ case SyntaxNodeType.ForKeyword:
+ console.log("Node Type:", node.type);
+ console.log("Node Start Position:", node.startIndex);
+ console.log("Node End Position:", node.endIndex);
+
+ newString = FormatterHelper.getCurrentText(
+ node,
+ fullText
+ ).trim();
+ console.log("Extracted newString for ForKeyword:", newString);
+ break;
+ case SyntaxNodeType.WhereClause:
+ console.log("Node Type:", node.type);
+ console.log("Node Start Position:", node.startIndex);
+ console.log("Node End Position:", node.endIndex);
+ newString = this.getWhereClauseBlock(
+ node,
+ fullText,
+ alignColumn
+ );
+ break;
+ default:
+ console.log("Node Type:", node.type);
+ console.log("Node Start Position:", node.startIndex);
+ console.log("Node End Position:", node.endIndex);
+ const text = FormatterHelper.getCurrentText(
+ node,
+ fullText
+ ).trim();
+ newString = text.length === 0 ? "" : " " + text;
+ console.log("Default Case - Text:", newString);
+ break;
+ }
+
+ return newString;
+ }
+
+ private getWhereClauseBlock(
+ node: SyntaxNode,
+ fullText: Readonly,
+ alignColumn: number
+ ): string {
+ let resultString = "";
+
+ node.children.forEach((child) => {
+ switch (child.type) {
+ case SyntaxNodeType.WhereKeyword:
+ console.log("WhereKeyword");
+ resultString = resultString.concat(
+ " ",
+ FormatterHelper.getCurrentText(child, fullText).trim(),
+ fullText.eolDelimiter,
+ " ".repeat(alignColumn)
+ );
+ break;
+ default:
+ const text = FormatterHelper.getCurrentText(
+ child,
+ fullText
+ ).trim();
+ console.log("default getWhereClauseBlock");
+ resultString = resultString.concat(
+ text.length === 0 ? "" : " " + text
+ );
+ break;
+ }
+ });
+
+ return resultString;
+ }
+}
diff --git a/src/v2/formatters/for/ForSettings.ts b/src/v2/formatters/for/ForSettings.ts
new file mode 100644
index 00000000..95612096
--- /dev/null
+++ b/src/v2/formatters/for/ForSettings.ts
@@ -0,0 +1,8 @@
+import { ASettings } from "../ASettings";
+
+export class ForSettings extends ASettings {
+ // token settings
+ public forFormatting() {
+ return this.configurationManager.get("forFormatting") ? true : false;
+ }
+}
\ No newline at end of file
From 93e66ece9deceac23b4b8cd792ce89b87788e344 Mon Sep 17 00:00:00 2001
From: sjonynaite
Date: Tue, 27 Aug 2024 09:35:19 +0300
Subject: [PATCH 06/79] update
---
src/v2/formatters/for/ForFormatter.ts | 41 +++++++++++++--------------
1 file changed, 19 insertions(+), 22 deletions(-)
diff --git a/src/v2/formatters/for/ForFormatter.ts b/src/v2/formatters/for/ForFormatter.ts
index 69969c42..46b2a88e 100644
--- a/src/v2/formatters/for/ForFormatter.ts
+++ b/src/v2/formatters/for/ForFormatter.ts
@@ -23,14 +23,19 @@ export class ForFormatter extends AFormatter implements IFormatter {
}
match(node: Readonly): boolean {
- return node.type === SyntaxNodeType.ForStatement;
+ if (node.type === SyntaxNodeType.ForStatement) {
+ return true;
+ }
+
+ return false;
}
parse(
node: Readonly,
fullText: Readonly
): CodeEdit | CodeEdit[] | undefined {
- this.collectCaseStructure(node, fullText);
+ this.collectForStructure(node, fullText);
+
return this.getCodeEdit(
node,
FormatterHelper.getCurrentText(node, fullText),
@@ -39,7 +44,7 @@ export class ForFormatter extends AFormatter implements IFormatter {
);
}
- private collectCaseStructure(
+ private collectForStructure(
node: SyntaxNode,
fullText: Readonly
) {
@@ -56,21 +61,17 @@ export class ForFormatter extends AFormatter implements IFormatter {
let resultString = "";
let alignColumn = 0;
- node.children.forEach((child) => {
- console.log("BEFOREE:::::");
- console.log("child.type:", child.type);
- console.log("resultString:", resultString);
+ console.log("Node Type:", node.type);
+ console.log("Node Start Position:", node.startIndex);
+ console.log("Node End Position:", node.endIndex);
+ node.children.forEach((child) => {
if (child.type === SyntaxNodeType.Identifier) {
alignColumn = this.startColumn + resultString.length;
}
resultString = resultString.concat(
this.getForExpressionString(child, fullText, alignColumn)
);
-
- console.log("AFFTERRR:::::");
- console.log("child.type:", child.type);
- console.log("resultString:", resultString);
});
return resultString;
@@ -83,22 +84,20 @@ export class ForFormatter extends AFormatter implements IFormatter {
): string {
let newString = "";
+ console.log("Node Type:", node.type);
+ console.log("Node Start Position:", node.startIndex);
+ console.log("Node End Position:", node.endIndex);
+
switch (node.type) {
case SyntaxNodeType.ForKeyword:
- console.log("Node Type:", node.type);
- console.log("Node Start Position:", node.startIndex);
- console.log("Node End Position:", node.endIndex);
-
+ console.log("ForKeyword");
newString = FormatterHelper.getCurrentText(
node,
fullText
).trim();
- console.log("Extracted newString for ForKeyword:", newString);
break;
case SyntaxNodeType.WhereClause:
- console.log("Node Type:", node.type);
- console.log("Node Start Position:", node.startIndex);
- console.log("Node End Position:", node.endIndex);
+ console.log("WhereClause");
newString = this.getWhereClauseBlock(
node,
fullText,
@@ -106,9 +105,7 @@ export class ForFormatter extends AFormatter implements IFormatter {
);
break;
default:
- console.log("Node Type:", node.type);
- console.log("Node Start Position:", node.startIndex);
- console.log("Node End Position:", node.endIndex);
+ console.log("default");
const text = FormatterHelper.getCurrentText(
node,
fullText
From c1a16f9669e38dc43970cc715bf759e32521e534 Mon Sep 17 00:00:00 2001
From: sjonynaite
Date: Tue, 27 Aug 2024 10:33:49 +0300
Subject: [PATCH 07/79] update
---
src/v2/formatters/for/ForFormatter.ts | 287 ++++++++++++++--------
src/v2/formatters/for/ForFormatterrrrr.ts | 154 ++++++++++++
2 files changed, 345 insertions(+), 96 deletions(-)
create mode 100644 src/v2/formatters/for/ForFormatterrrrr.ts
diff --git a/src/v2/formatters/for/ForFormatter.ts b/src/v2/formatters/for/ForFormatter.ts
index 46b2a88e..34bdaecb 100644
--- a/src/v2/formatters/for/ForFormatter.ts
+++ b/src/v2/formatters/for/ForFormatter.ts
@@ -11,23 +11,31 @@ import { IConfigurationManager } from "../../../utils/IConfigurationManager";
@RegisterFormatter
export class ForFormatter extends AFormatter implements IFormatter {
- private startColumn = 0;
- private forBodyValue = "";
-
public static readonly formatterLabel = "forFormatting";
private readonly settings: ForSettings;
+ private startColumn = 0;
+ private recordValueColumn = 0;
+ private forBlockValueColumn = 0;
+ private forKey = ""; // FOR
+ private forTypeKey = ""; // EACH | FIRST | LAST
+ private recordValue = "";
+ private byValue = ""; // BY
+ private whereKey = ""; // WHERE
+ private whereValue = "";
+ private forBodyValue = "";
+ private useIndexValue = ""; //USE-INDEX
+ private queryTuningLockKey = ""; // SHARE-LOCK | EXCLUSIVE-LOCK | NO-LOCK
+ private queryTuningNoPrefetchKey = ""; // NO-PREFETCH
+ private endValue = "";
+
public constructor(configurationManager: IConfigurationManager) {
super(configurationManager);
this.settings = new ForSettings(configurationManager);
}
match(node: Readonly): boolean {
- if (node.type === SyntaxNodeType.ForStatement) {
- return true;
- }
-
- return false;
+ return node.type === SyntaxNodeType.ForStatement;
}
parse(
@@ -36,12 +44,14 @@ export class ForFormatter extends AFormatter implements IFormatter {
): CodeEdit | CodeEdit[] | undefined {
this.collectForStructure(node, fullText);
- return this.getCodeEdit(
- node,
- FormatterHelper.getCurrentText(node, fullText),
- this.forBodyValue,
- fullText
- );
+ const formattedBlock = this.getPrettyBlock();
+
+ const originalText = FormatterHelper.getCurrentText(node, fullText);
+ if (originalText === formattedBlock) {
+ return undefined; // No changes needed
+ }
+
+ return this.getCodeEdit(node, originalText, formattedBlock, fullText);
}
private collectForStructure(
@@ -49,106 +59,191 @@ export class ForFormatter extends AFormatter implements IFormatter {
fullText: Readonly
) {
this.startColumn = node.startPosition.column;
- console.log("startColumn");
- console.log(this.startColumn);
- this.forBodyValue = this.getForStatementBlock(node, fullText);
+ console.log("startColumn", this.startColumn);
+ this.forKey = FormatterHelper.getCurrentText(node, fullText).trim();
+ console.log("forKey", this.forKey);
+ this.forTypeKey = this.getForTypeKey(node);
+ console.log("forTypeKey", this.forTypeKey);
+ this.recordValue = node.text;
+ console.log("recordValue", this.recordValue);
+ this.recordValueColumn =
+ this.startColumn + this.forKey.length + this.forTypeKey.length + 1; // +1 is a space between FOR EACH
+ console.log("recordValueColumn", this.recordValueColumn);
+ this.forBlockValueColumn = this.startColumn + this.settings.tabSize();
+ console.log("forBlockValueColumn", this.forBlockValueColumn);
+
+ this.assignQueryTuningStatements(node);
+
+
+ const whereNode = this.getWhereNode(node);
+ console.log("whereNode", whereNode);
+
+ if (whereNode !== undefined) {
+ this.whereKey = this.getWhereKey(whereNode, fullText);
+ this.whereValue = this.getPrettyWhereBlock(
+ whereNode,
+ "\r\n".concat(" ".repeat(this.recordValueColumn)),
+ fullText
+ );
+ }
+
+ this.assignByValue(node, fullText);
+
+ const bodyNode = this.getForBodyNode(node);
+ console.log("bodyNode", bodyNode);
+
+ if (bodyNode !== undefined) {
+ this.forBodyValue = this.getPrettyBodyBlock(
+ bodyNode,
+ "\r\n".concat(" ".repeat(this.forBlockValueColumn)),
+ fullText
+ );
+ }
+
+ this.assignEndValue(node, fullText);
}
- private getForStatementBlock(
- node: SyntaxNode,
- fullText: Readonly
- ): string {
- let resultString = "";
- let alignColumn = 0;
+ private getForTypeKey(node: SyntaxNode): string {
+ const forTypeNode = node.child(1);
- console.log("Node Type:", node.type);
- console.log("Node Start Position:", node.startIndex);
- console.log("Node End Position:", node.endIndex);
+ if (forTypeNode === null) {
+ return "";
+ }
+
+ if (
+ forTypeNode.type === SyntaxNodeType.EachKeyword ||
+ forTypeNode.type === SyntaxNodeType.FirstKeyword ||
+ forTypeNode.type === SyntaxNodeType.LastKeyword
+ ) {
+ return forTypeNode.text;
+ } else {
+ return "";
+ }
+ }
+ private assignQueryTuningStatements(node: SyntaxNode): void {
node.children.forEach((child) => {
- if (child.type === SyntaxNodeType.Identifier) {
- alignColumn = this.startColumn + resultString.length;
+ if (child.type === SyntaxNodeType.QueryTuning) {
+ const tuneNode = child.child(0);
+ if (tuneNode !== null) {
+ const text = tuneNode.text;
+
+ switch (tuneNode.type) {
+ case SyntaxNodeType.ShareLockKeyword:
+ case SyntaxNodeType.ExclLockKeyword:
+ case SyntaxNodeType.NoLockKeyword:
+ this.queryTuningLockKey = text;
+ break;
+ case SyntaxNodeType.NoPrefetchKeyword:
+ this.queryTuningNoPrefetchKey = text;
+ break;
+ }
+ }
}
- resultString = resultString.concat(
- this.getForExpressionString(child, fullText, alignColumn)
- );
});
+ }
- return resultString;
+ private getWhereNode(node: SyntaxNode): SyntaxNode | undefined {
+ return node.children.find(
+ (child) => child.type === SyntaxNodeType.WhereClause
+ );
}
- private getForExpressionString(
+ private getWhereKey(
+ whereNode: SyntaxNode,
+ fullText: Readonly
+ ): string {
+ return FormatterHelper.getCurrentText(whereNode, fullText).trim(); // Assuming first child is WHERE keyword
+ }
+
+ private getPrettyWhereBlock(
node: SyntaxNode,
- fullText: Readonly,
- alignColumn: number
+ separator: string,
+ fullText: Readonly
): string {
- let newString = "";
-
- console.log("Node Type:", node.type);
- console.log("Node Start Position:", node.startIndex);
- console.log("Node End Position:", node.endIndex);
-
- switch (node.type) {
- case SyntaxNodeType.ForKeyword:
- console.log("ForKeyword");
- newString = FormatterHelper.getCurrentText(
- node,
- fullText
- ).trim();
- break;
- case SyntaxNodeType.WhereClause:
- console.log("WhereClause");
- newString = this.getWhereClauseBlock(
- node,
- fullText,
- alignColumn
- );
- break;
- default:
- console.log("default");
- const text = FormatterHelper.getCurrentText(
- node,
- fullText
- ).trim();
- newString = text.length === 0 ? "" : " " + text;
- console.log("Default Case - Text:", newString);
- break;
- }
+ return node.children
+ .map((child) =>
+ FormatterHelper.getCurrentText(child, fullText).trim()
+ )
+ .join(separator);
+ }
+
+ private assignByValue(
+ node: SyntaxNode,
+ fullText: Readonly
+ ): void {
+ const byNode = node.children.find(
+ (child) => child.type === SyntaxNodeType.SortClause
+ );
+ this.byValue = byNode
+ ? FormatterHelper.getCurrentText(byNode, fullText).trim()
+ : "";
+ }
- return newString;
+ private getForBodyNode(node: SyntaxNode): SyntaxNode | undefined {
+ return node.children.find(
+ (child) => child.type === SyntaxNodeType.Body
+ );
}
- private getWhereClauseBlock(
+ private getPrettyBodyBlock(
node: SyntaxNode,
- fullText: Readonly,
- alignColumn: number
+ separator: string,
+ fullText: Readonly
): string {
- let resultString = "";
+ return node.children
+ .map(
+ (child) =>
+ FormatterHelper.getCurrentText(child, fullText).trim() +
+ separator
+ )
+ .join("");
+ }
- node.children.forEach((child) => {
- switch (child.type) {
- case SyntaxNodeType.WhereKeyword:
- console.log("WhereKeyword");
- resultString = resultString.concat(
- " ",
- FormatterHelper.getCurrentText(child, fullText).trim(),
- fullText.eolDelimiter,
- " ".repeat(alignColumn)
- );
- break;
- default:
- const text = FormatterHelper.getCurrentText(
- child,
- fullText
- ).trim();
- console.log("default getWhereClauseBlock");
- resultString = resultString.concat(
- text.length === 0 ? "" : " " + text
- );
- break;
- }
- });
+ private assignEndValue(
+ node: SyntaxNode,
+ fullText: Readonly
+ ): void {
+ const endNode = node.children.find(
+ (child) => child.type === SyntaxNodeType.EndKeyword
+ );
+ this.endValue = endNode
+ ? FormatterHelper.getCurrentText(endNode, fullText).trim()
+ : "";
+ }
- return resultString;
+ private getPrettyBlock(): string {
+ return ""
+ .concat(this.forKey)
+ .concat(this.forTypeKey === "" ? "" : " ")
+ .concat(this.forTypeKey.trim())
+ .concat(this.recordValue === "" ? "" : " ")
+ .concat(this.recordValue.trim())
+ .concat(this.queryTuningLockKey === "" ? "" : " ")
+ .concat(this.queryTuningLockKey.trim())
+ .concat(this.whereKey === "" ? "" : " ")
+ .concat(this.whereKey.trim())
+ .concat(this.whereValue === "" ? "" : " ")
+ .concat(this.whereValue === "" ? " " : "\r\n")
+ .concat(
+ this.whereValue === "" ? "" : " ".repeat(this.recordValueColumn)
+ )
+ .concat(this.whereValue.trim())
+ .concat(this.byValue === "" ? "" : " ")
+ .concat(this.byValue.trim())
+ .concat(":")
+ .concat(this.forBodyValue === "" ? " " : "\r\n")
+ .concat(
+ this.forBodyValue === ""
+ ? ""
+ : " ".repeat(this.forBlockValueColumn)
+ )
+ .concat(this.forBodyValue.trim())
+ .concat(this.queryTuningNoPrefetchKey === "" ? "" : " ")
+ .concat(this.queryTuningNoPrefetchKey.trim())
+ .concat("\r\n")
+ .concat(" ".repeat(this.startColumn))
+ .concat(this.endValue)
+ .concat(".");
}
}
diff --git a/src/v2/formatters/for/ForFormatterrrrr.ts b/src/v2/formatters/for/ForFormatterrrrr.ts
new file mode 100644
index 00000000..46b2a88e
--- /dev/null
+++ b/src/v2/formatters/for/ForFormatterrrrr.ts
@@ -0,0 +1,154 @@
+import { SyntaxNode } from "web-tree-sitter";
+import { IFormatter } from "../../formatterFramework/IFormatter";
+import { SyntaxNodeType } from "../../../model/SyntaxNodeType";
+import { CodeEdit } from "../../model/CodeEdit";
+import { FullText } from "../../model/FullText";
+import { FormatterHelper } from "../../formatterFramework/FormatterHelper";
+import { AFormatter } from "../AFormatter";
+import { RegisterFormatter } from "../../formatterFramework/formatterDecorator";
+import { ForSettings } from "./ForSettings";
+import { IConfigurationManager } from "../../../utils/IConfigurationManager";
+
+@RegisterFormatter
+export class ForFormatter extends AFormatter implements IFormatter {
+ private startColumn = 0;
+ private forBodyValue = "";
+
+ public static readonly formatterLabel = "forFormatting";
+ private readonly settings: ForSettings;
+
+ public constructor(configurationManager: IConfigurationManager) {
+ super(configurationManager);
+ this.settings = new ForSettings(configurationManager);
+ }
+
+ match(node: Readonly): boolean {
+ if (node.type === SyntaxNodeType.ForStatement) {
+ return true;
+ }
+
+ return false;
+ }
+
+ parse(
+ node: Readonly,
+ fullText: Readonly
+ ): CodeEdit | CodeEdit[] | undefined {
+ this.collectForStructure(node, fullText);
+
+ return this.getCodeEdit(
+ node,
+ FormatterHelper.getCurrentText(node, fullText),
+ this.forBodyValue,
+ fullText
+ );
+ }
+
+ private collectForStructure(
+ node: SyntaxNode,
+ fullText: Readonly
+ ) {
+ this.startColumn = node.startPosition.column;
+ console.log("startColumn");
+ console.log(this.startColumn);
+ this.forBodyValue = this.getForStatementBlock(node, fullText);
+ }
+
+ private getForStatementBlock(
+ node: SyntaxNode,
+ fullText: Readonly
+ ): string {
+ let resultString = "";
+ let alignColumn = 0;
+
+ console.log("Node Type:", node.type);
+ console.log("Node Start Position:", node.startIndex);
+ console.log("Node End Position:", node.endIndex);
+
+ node.children.forEach((child) => {
+ if (child.type === SyntaxNodeType.Identifier) {
+ alignColumn = this.startColumn + resultString.length;
+ }
+ resultString = resultString.concat(
+ this.getForExpressionString(child, fullText, alignColumn)
+ );
+ });
+
+ return resultString;
+ }
+
+ private getForExpressionString(
+ node: SyntaxNode,
+ fullText: Readonly,
+ alignColumn: number
+ ): string {
+ let newString = "";
+
+ console.log("Node Type:", node.type);
+ console.log("Node Start Position:", node.startIndex);
+ console.log("Node End Position:", node.endIndex);
+
+ switch (node.type) {
+ case SyntaxNodeType.ForKeyword:
+ console.log("ForKeyword");
+ newString = FormatterHelper.getCurrentText(
+ node,
+ fullText
+ ).trim();
+ break;
+ case SyntaxNodeType.WhereClause:
+ console.log("WhereClause");
+ newString = this.getWhereClauseBlock(
+ node,
+ fullText,
+ alignColumn
+ );
+ break;
+ default:
+ console.log("default");
+ const text = FormatterHelper.getCurrentText(
+ node,
+ fullText
+ ).trim();
+ newString = text.length === 0 ? "" : " " + text;
+ console.log("Default Case - Text:", newString);
+ break;
+ }
+
+ return newString;
+ }
+
+ private getWhereClauseBlock(
+ node: SyntaxNode,
+ fullText: Readonly,
+ alignColumn: number
+ ): string {
+ let resultString = "";
+
+ node.children.forEach((child) => {
+ switch (child.type) {
+ case SyntaxNodeType.WhereKeyword:
+ console.log("WhereKeyword");
+ resultString = resultString.concat(
+ " ",
+ FormatterHelper.getCurrentText(child, fullText).trim(),
+ fullText.eolDelimiter,
+ " ".repeat(alignColumn)
+ );
+ break;
+ default:
+ const text = FormatterHelper.getCurrentText(
+ child,
+ fullText
+ ).trim();
+ console.log("default getWhereClauseBlock");
+ resultString = resultString.concat(
+ text.length === 0 ? "" : " " + text
+ );
+ break;
+ }
+ });
+
+ return resultString;
+ }
+}
From bb3c3faba61a576f2a91a135a9dde4ffab5e080a Mon Sep 17 00:00:00 2001
From: sjonynaite
Date: Tue, 27 Aug 2024 21:33:29 +0300
Subject: [PATCH 08/79] Update for formatter
---
.../{for1-each-false => 1each-false}/input.p | 2 +-
.../{for1-each-false => 1each-false}/target.p | 2 +-
.../{for2-each-true => 2each-true}/input.p | 2 +-
.../{for2-each-true => 2each-true}/target.p | 2 +-
.../functionalTests/for/3each-each/input.p | 8 +
.../functionalTests/for/3each-each/target.p | 13 +
.../{for3-each-where => 3each-where}/input.p | 2 +-
.../{for3-each-where => 3each-where}/target.p | 2 +-
.../functionalTests/for/3first-by/input.p | 9 +
.../functionalTests/for/3first-by/target.p | 9 +
.../input.p | 2 +-
.../target.p | 2 +-
src/model/SyntaxNodeType.ts | 4 +
src/v2/formatters/for/ForFormatter.ts | 331 ++++++++----------
src/v2/formatters/for/ForFormatterrrrr.ts | 154 --------
15 files changed, 194 insertions(+), 350 deletions(-)
rename resources/functionalTests/for/{for1-each-false => 1each-false}/input.p (72%)
rename resources/functionalTests/for/{for1-each-false => 1each-false}/target.p (72%)
rename resources/functionalTests/for/{for2-each-true => 2each-true}/input.p (72%)
rename resources/functionalTests/for/{for2-each-true => 2each-true}/target.p (72%)
create mode 100644 resources/functionalTests/for/3each-each/input.p
create mode 100644 resources/functionalTests/for/3each-each/target.p
rename resources/functionalTests/for/{for3-each-where => 3each-where}/input.p (75%)
rename resources/functionalTests/for/{for3-each-where => 3each-where}/target.p (76%)
create mode 100644 resources/functionalTests/for/3first-by/input.p
create mode 100644 resources/functionalTests/for/3first-by/target.p
rename resources/functionalTests/for/{for4-each-where3 => 4each-where3}/input.p (80%)
rename resources/functionalTests/for/{for4-each-where3 => 4each-where3}/target.p (80%)
delete mode 100644 src/v2/formatters/for/ForFormatterrrrr.ts
diff --git a/resources/functionalTests/for/for1-each-false/input.p b/resources/functionalTests/for/1each-false/input.p
similarity index 72%
rename from resources/functionalTests/for/for1-each-false/input.p
rename to resources/functionalTests/for/1each-false/input.p
index d675f879..a8ac99fd 100644
--- a/resources/functionalTests/for/for1-each-false/input.p
+++ b/resources/functionalTests/for/1each-false/input.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.blockFormatting": true,
+/* { "AblFormatter.blockFormatting": false,
"AblFormatter.forFormatting": false
}*/
diff --git a/resources/functionalTests/for/for1-each-false/target.p b/resources/functionalTests/for/1each-false/target.p
similarity index 72%
rename from resources/functionalTests/for/for1-each-false/target.p
rename to resources/functionalTests/for/1each-false/target.p
index d675f879..a8ac99fd 100644
--- a/resources/functionalTests/for/for1-each-false/target.p
+++ b/resources/functionalTests/for/1each-false/target.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.blockFormatting": true,
+/* { "AblFormatter.blockFormatting": false,
"AblFormatter.forFormatting": false
}*/
diff --git a/resources/functionalTests/for/for2-each-true/input.p b/resources/functionalTests/for/2each-true/input.p
similarity index 72%
rename from resources/functionalTests/for/for2-each-true/input.p
rename to resources/functionalTests/for/2each-true/input.p
index ef42047e..9e0bcf5c 100644
--- a/resources/functionalTests/for/for2-each-true/input.p
+++ b/resources/functionalTests/for/2each-true/input.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.blockFormatting": true,
+/* { "AblFormatter.blockFormatting": false,
"AblFormatter.forFormatting": true
}*/
diff --git a/resources/functionalTests/for/for2-each-true/target.p b/resources/functionalTests/for/2each-true/target.p
similarity index 72%
rename from resources/functionalTests/for/for2-each-true/target.p
rename to resources/functionalTests/for/2each-true/target.p
index dbbe3133..c17ee35d 100644
--- a/resources/functionalTests/for/for2-each-true/target.p
+++ b/resources/functionalTests/for/2each-true/target.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.blockFormatting": true,
+/* { "AblFormatter.blockFormatting": false,
"AblFormatter.forFormatting": true
}*/
diff --git a/resources/functionalTests/for/3each-each/input.p b/resources/functionalTests/for/3each-each/input.p
new file mode 100644
index 00000000..6fd53d69
--- /dev/null
+++ b/resources/functionalTests/for/3each-each/input.p
@@ -0,0 +1,8 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.forFormatting": true,
+"AblFormatter.blockFormatting": false,
+"abl.completion.upperCase": true}*/
+
+FOR EACH Customer NO-LOCK, EACH Order OF Customer NO-LOCK, EACH OrderLine OF Order NO-LOCK BY Order.PromiseDate BY Customer.CustNum BY OrderLine.LineNum:
+ DISPLAY Order.PromiseDate.
+END.
\ No newline at end of file
diff --git a/resources/functionalTests/for/3each-each/target.p b/resources/functionalTests/for/3each-each/target.p
new file mode 100644
index 00000000..e1b14473
--- /dev/null
+++ b/resources/functionalTests/for/3each-each/target.p
@@ -0,0 +1,13 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.forFormatting": true,
+"AblFormatter.blockFormatting": false,
+"abl.completion.upperCase": true}*/
+
+FOR EACH Customer NO-LOCK,
+ EACH Order OF Customer NO-LOCK,
+ EACH OrderLine OF Order NO-LOCK
+ BY Order.PromiseDate
+ BY Customer.CustNum
+ BY OrderLine.LineNum:
+ DISPLAY Order.PromiseDate.
+END.
\ No newline at end of file
diff --git a/resources/functionalTests/for/for3-each-where/input.p b/resources/functionalTests/for/3each-where/input.p
similarity index 75%
rename from resources/functionalTests/for/for3-each-where/input.p
rename to resources/functionalTests/for/3each-where/input.p
index bfed1d6f..89fdd870 100644
--- a/resources/functionalTests/for/for3-each-where/input.p
+++ b/resources/functionalTests/for/3each-where/input.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.blockFormatting": true,
+/* { "AblFormatter.blockFormatting": false,
"AblFormatter.forFormatting": true
}*/
diff --git a/resources/functionalTests/for/for3-each-where/target.p b/resources/functionalTests/for/3each-where/target.p
similarity index 76%
rename from resources/functionalTests/for/for3-each-where/target.p
rename to resources/functionalTests/for/3each-where/target.p
index a376627f..241df442 100644
--- a/resources/functionalTests/for/for3-each-where/target.p
+++ b/resources/functionalTests/for/3each-where/target.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.blockFormatting": true,
+/* { "AblFormatter.blockFormatting": false,
"AblFormatter.forFormatting": true
}*/
diff --git a/resources/functionalTests/for/3first-by/input.p b/resources/functionalTests/for/3first-by/input.p
new file mode 100644
index 00000000..34adf0a4
--- /dev/null
+++ b/resources/functionalTests/for/3first-by/input.p
@@ -0,0 +1,9 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.blockFormatting": false,
+"AblFormatter.forFormatting": true
+}*/
+
+FOR FIRST Customer NO-LOCK
+ BY Customer.CreditLimit:
+ DISPLAY Customer.
+ END.
\ No newline at end of file
diff --git a/resources/functionalTests/for/3first-by/target.p b/resources/functionalTests/for/3first-by/target.p
new file mode 100644
index 00000000..bebe9df1
--- /dev/null
+++ b/resources/functionalTests/for/3first-by/target.p
@@ -0,0 +1,9 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.blockFormatting": false,
+"AblFormatter.forFormatting": true
+}*/
+
+FOR FIRST Customer NO-LOCK
+ BY Customer.CreditLimit:
+ DISPLAY Customer.
+END.
\ No newline at end of file
diff --git a/resources/functionalTests/for/for4-each-where3/input.p b/resources/functionalTests/for/4each-where3/input.p
similarity index 80%
rename from resources/functionalTests/for/for4-each-where3/input.p
rename to resources/functionalTests/for/4each-where3/input.p
index 38eba14d..038c7aba 100644
--- a/resources/functionalTests/for/for4-each-where3/input.p
+++ b/resources/functionalTests/for/4each-where3/input.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.blockFormatting": true,
+/* { "AblFormatter.blockFormatting": false,
"AblFormatter.forFormatting": true
}*/
diff --git a/resources/functionalTests/for/for4-each-where3/target.p b/resources/functionalTests/for/4each-where3/target.p
similarity index 80%
rename from resources/functionalTests/for/for4-each-where3/target.p
rename to resources/functionalTests/for/4each-where3/target.p
index 154260b4..3f9c1e4c 100644
--- a/resources/functionalTests/for/for4-each-where3/target.p
+++ b/resources/functionalTests/for/4each-where3/target.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.blockFormatting": true,
+/* { "AblFormatter.blockFormatting": false,
"AblFormatter.forFormatting": true
}*/
diff --git a/src/model/SyntaxNodeType.ts b/src/model/SyntaxNodeType.ts
index 3ad55a67..d3ab2fbf 100644
--- a/src/model/SyntaxNodeType.ts
+++ b/src/model/SyntaxNodeType.ts
@@ -24,6 +24,7 @@ export enum SyntaxNodeType {
Assignment = "assignment",
Identifier = "identifier",
SourceCode = "source_code",
+ ForPhrase = "for_phrase",
ForStatement = "for_statement",
QueryTuning = "query_tuning",
SortClause = "sort_clause",
@@ -69,4 +70,7 @@ export enum SyntaxNodeType {
EndKeyword = "END",
IfKeyword = "IF",
ForKeyword = "FOR",
+ DotKeyword = ".",
+ ColonKeyword = ":",
+ CommaKeyword = ",",
}
diff --git a/src/v2/formatters/for/ForFormatter.ts b/src/v2/formatters/for/ForFormatter.ts
index 34bdaecb..f793c7e1 100644
--- a/src/v2/formatters/for/ForFormatter.ts
+++ b/src/v2/formatters/for/ForFormatter.ts
@@ -11,23 +11,11 @@ import { IConfigurationManager } from "../../../utils/IConfigurationManager";
@RegisterFormatter
export class ForFormatter extends AFormatter implements IFormatter {
- public static readonly formatterLabel = "forFormatting";
- private readonly settings: ForSettings;
-
private startColumn = 0;
- private recordValueColumn = 0;
- private forBlockValueColumn = 0;
- private forKey = ""; // FOR
- private forTypeKey = ""; // EACH | FIRST | LAST
- private recordValue = "";
- private byValue = ""; // BY
- private whereKey = ""; // WHERE
- private whereValue = "";
private forBodyValue = "";
- private useIndexValue = ""; //USE-INDEX
- private queryTuningLockKey = ""; // SHARE-LOCK | EXCLUSIVE-LOCK | NO-LOCK
- private queryTuningNoPrefetchKey = ""; // NO-PREFETCH
- private endValue = "";
+
+ public static readonly formatterLabel = "forFormatting";
+ private readonly settings: ForSettings;
public constructor(configurationManager: IConfigurationManager) {
super(configurationManager);
@@ -35,7 +23,11 @@ export class ForFormatter extends AFormatter implements IFormatter {
}
match(node: Readonly): boolean {
- return node.type === SyntaxNodeType.ForStatement;
+ if (node.type === SyntaxNodeType.ForStatement) {
+ return true;
+ }
+
+ return false;
}
parse(
@@ -44,14 +36,12 @@ export class ForFormatter extends AFormatter implements IFormatter {
): CodeEdit | CodeEdit[] | undefined {
this.collectForStructure(node, fullText);
- const formattedBlock = this.getPrettyBlock();
-
- const originalText = FormatterHelper.getCurrentText(node, fullText);
- if (originalText === formattedBlock) {
- return undefined; // No changes needed
- }
-
- return this.getCodeEdit(node, originalText, formattedBlock, fullText);
+ return this.getCodeEdit(
+ node,
+ FormatterHelper.getCurrentText(node, fullText),
+ this.forBodyValue,
+ fullText
+ );
}
private collectForStructure(
@@ -59,191 +49,156 @@ export class ForFormatter extends AFormatter implements IFormatter {
fullText: Readonly
) {
this.startColumn = node.startPosition.column;
- console.log("startColumn", this.startColumn);
- this.forKey = FormatterHelper.getCurrentText(node, fullText).trim();
- console.log("forKey", this.forKey);
- this.forTypeKey = this.getForTypeKey(node);
- console.log("forTypeKey", this.forTypeKey);
- this.recordValue = node.text;
- console.log("recordValue", this.recordValue);
- this.recordValueColumn =
- this.startColumn + this.forKey.length + this.forTypeKey.length + 1; // +1 is a space between FOR EACH
- console.log("recordValueColumn", this.recordValueColumn);
- this.forBlockValueColumn = this.startColumn + this.settings.tabSize();
- console.log("forBlockValueColumn", this.forBlockValueColumn);
-
- this.assignQueryTuningStatements(node);
-
-
- const whereNode = this.getWhereNode(node);
- console.log("whereNode", whereNode);
-
- if (whereNode !== undefined) {
- this.whereKey = this.getWhereKey(whereNode, fullText);
- this.whereValue = this.getPrettyWhereBlock(
- whereNode,
- "\r\n".concat(" ".repeat(this.recordValueColumn)),
- fullText
- );
- }
-
- this.assignByValue(node, fullText);
-
- const bodyNode = this.getForBodyNode(node);
- console.log("bodyNode", bodyNode);
-
- if (bodyNode !== undefined) {
- this.forBodyValue = this.getPrettyBodyBlock(
- bodyNode,
- "\r\n".concat(" ".repeat(this.forBlockValueColumn)),
- fullText
- );
- }
-
- this.assignEndValue(node, fullText);
+ this.forBodyValue = this.getForStatementBlock(node, fullText);
}
- private getForTypeKey(node: SyntaxNode): string {
- const forTypeNode = node.child(1);
-
- if (forTypeNode === null) {
- return "";
- }
-
- if (
- forTypeNode.type === SyntaxNodeType.EachKeyword ||
- forTypeNode.type === SyntaxNodeType.FirstKeyword ||
- forTypeNode.type === SyntaxNodeType.LastKeyword
- ) {
- return forTypeNode.text;
- } else {
- return "";
- }
- }
+ private getForStatementBlock(
+ node: SyntaxNode,
+ fullText: Readonly
+ ): string {
+ let resultString = "";
+ let alignColumn = 0;
- private assignQueryTuningStatements(node: SyntaxNode): void {
node.children.forEach((child) => {
- if (child.type === SyntaxNodeType.QueryTuning) {
- const tuneNode = child.child(0);
- if (tuneNode !== null) {
- const text = tuneNode.text;
-
- switch (tuneNode.type) {
- case SyntaxNodeType.ShareLockKeyword:
- case SyntaxNodeType.ExclLockKeyword:
- case SyntaxNodeType.NoLockKeyword:
- this.queryTuningLockKey = text;
- break;
- case SyntaxNodeType.NoPrefetchKeyword:
- this.queryTuningNoPrefetchKey = text;
- break;
- }
- }
+ if (child.type === SyntaxNodeType.Identifier) {
+ alignColumn = this.startColumn + resultString.length;
}
+ resultString = resultString.concat(
+ this.getForExpressionString(child, fullText, alignColumn)
+ );
});
- }
- private getWhereNode(node: SyntaxNode): SyntaxNode | undefined {
- return node.children.find(
- (child) => child.type === SyntaxNodeType.WhereClause
- );
+ return resultString;
}
- private getWhereKey(
- whereNode: SyntaxNode,
- fullText: Readonly
+ private getForExpressionString(
+ node: SyntaxNode,
+ fullText: Readonly,
+ alignColumn: number
): string {
- return FormatterHelper.getCurrentText(whereNode, fullText).trim(); // Assuming first child is WHERE keyword
+ let newString = "";
+
+ switch (node.type) {
+ case SyntaxNodeType.ForKeyword:
+ case SyntaxNodeType.DotKeyword:
+ case SyntaxNodeType.ColonKeyword:
+ case SyntaxNodeType.CommaKeyword:
+ newString = FormatterHelper.getCurrentText(
+ node,
+ fullText
+ ).trim();
+ break;
+ case SyntaxNodeType.WhereClause:
+ newString = this.getWhereClauseBlock(
+ node,
+ fullText,
+ alignColumn
+ );
+ break;
+ case SyntaxNodeType.EndKeyword:
+ newString =
+ fullText.eolDelimiter +
+ " ".repeat(this.startColumn) +
+ FormatterHelper.getCurrentText(node, fullText).trim();
+ break;
+ case SyntaxNodeType.SortClause:
+ newString =
+ fullText.eolDelimiter +
+ " ".repeat(alignColumn + 1) +
+ FormatterHelper.getCurrentText(node, fullText).trim();
+ break;
+ case SyntaxNodeType.ForPhrase:
+ newString = this.getSortClauseBlock(
+ node,
+ fullText,
+ alignColumn
+ );
+ break;
+ case SyntaxNodeType.Body:
+ newString =
+ fullText.eolDelimiter +
+ " ".repeat(this.startColumn + this.settings.tabSize()) +
+ FormatterHelper.getCurrentText(node, fullText).trim();
+ break;
+ default:
+ const text = FormatterHelper.getCurrentText(
+ node,
+ fullText
+ ).trim();
+ newString = text.length === 0 ? "" : " " + text;
+ break;
+ }
+
+ return newString;
}
- private getPrettyWhereBlock(
+ private getWhereClauseBlock(
node: SyntaxNode,
- separator: string,
- fullText: Readonly
+ fullText: Readonly,
+ alignColumn: number
): string {
- return node.children
- .map((child) =>
- FormatterHelper.getCurrentText(child, fullText).trim()
- )
- .join(separator);
- }
+ let resultString = "";
- private assignByValue(
- node: SyntaxNode,
- fullText: Readonly
- ): void {
- const byNode = node.children.find(
- (child) => child.type === SyntaxNodeType.SortClause
- );
- this.byValue = byNode
- ? FormatterHelper.getCurrentText(byNode, fullText).trim()
- : "";
- }
+ node.children.forEach((child) => {
+ switch (child.type) {
+ case SyntaxNodeType.WhereKeyword:
+ resultString = resultString.concat(
+ " ",
+ FormatterHelper.getCurrentText(child, fullText).trim(),
+ fullText.eolDelimiter,
+ " ".repeat(alignColumn)
+ );
+ break;
+ default:
+ const text = FormatterHelper.getCurrentText(
+ child,
+ fullText
+ ).trim();
+ resultString = resultString.concat(
+ text.length === 0 ? "" : " " + text
+ );
+ break;
+ }
+ });
- private getForBodyNode(node: SyntaxNode): SyntaxNode | undefined {
- return node.children.find(
- (child) => child.type === SyntaxNodeType.Body
- );
+ return resultString;
}
- private getPrettyBodyBlock(
+ private getSortClauseBlock(
node: SyntaxNode,
- separator: string,
- fullText: Readonly
+ fullText: Readonly,
+ alignColumn: number
): string {
- return node.children
- .map(
- (child) =>
- FormatterHelper.getCurrentText(child, fullText).trim() +
- separator
- )
- .join("");
- }
+ let resultString = "";
- private assignEndValue(
- node: SyntaxNode,
- fullText: Readonly
- ): void {
- const endNode = node.children.find(
- (child) => child.type === SyntaxNodeType.EndKeyword
- );
- this.endValue = endNode
- ? FormatterHelper.getCurrentText(endNode, fullText).trim()
- : "";
- }
+ node.children.forEach((child) => {
+ switch (child.type) {
+ case SyntaxNodeType.EachKeyword:
+ resultString = resultString.concat(
+ fullText.eolDelimiter,
+ " ".repeat(this.startColumn + this.settings.tabSize()),
+ FormatterHelper.getCurrentText(child, fullText).trim()
+ );
+ break;
+ case SyntaxNodeType.SortClause:
+ resultString = resultString.concat(
+ fullText.eolDelimiter,
+ " ".repeat(alignColumn + 1),
+ FormatterHelper.getCurrentText(child, fullText).trim()
+ );
+ break;
+ default:
+ const text = FormatterHelper.getCurrentText(
+ child,
+ fullText
+ ).trim();
+ resultString = resultString.concat(
+ text.length === 0 ? "" : " " + text
+ );
+ break;
+ }
+ });
- private getPrettyBlock(): string {
- return ""
- .concat(this.forKey)
- .concat(this.forTypeKey === "" ? "" : " ")
- .concat(this.forTypeKey.trim())
- .concat(this.recordValue === "" ? "" : " ")
- .concat(this.recordValue.trim())
- .concat(this.queryTuningLockKey === "" ? "" : " ")
- .concat(this.queryTuningLockKey.trim())
- .concat(this.whereKey === "" ? "" : " ")
- .concat(this.whereKey.trim())
- .concat(this.whereValue === "" ? "" : " ")
- .concat(this.whereValue === "" ? " " : "\r\n")
- .concat(
- this.whereValue === "" ? "" : " ".repeat(this.recordValueColumn)
- )
- .concat(this.whereValue.trim())
- .concat(this.byValue === "" ? "" : " ")
- .concat(this.byValue.trim())
- .concat(":")
- .concat(this.forBodyValue === "" ? " " : "\r\n")
- .concat(
- this.forBodyValue === ""
- ? ""
- : " ".repeat(this.forBlockValueColumn)
- )
- .concat(this.forBodyValue.trim())
- .concat(this.queryTuningNoPrefetchKey === "" ? "" : " ")
- .concat(this.queryTuningNoPrefetchKey.trim())
- .concat("\r\n")
- .concat(" ".repeat(this.startColumn))
- .concat(this.endValue)
- .concat(".");
+ return resultString;
}
}
diff --git a/src/v2/formatters/for/ForFormatterrrrr.ts b/src/v2/formatters/for/ForFormatterrrrr.ts
deleted file mode 100644
index 46b2a88e..00000000
--- a/src/v2/formatters/for/ForFormatterrrrr.ts
+++ /dev/null
@@ -1,154 +0,0 @@
-import { SyntaxNode } from "web-tree-sitter";
-import { IFormatter } from "../../formatterFramework/IFormatter";
-import { SyntaxNodeType } from "../../../model/SyntaxNodeType";
-import { CodeEdit } from "../../model/CodeEdit";
-import { FullText } from "../../model/FullText";
-import { FormatterHelper } from "../../formatterFramework/FormatterHelper";
-import { AFormatter } from "../AFormatter";
-import { RegisterFormatter } from "../../formatterFramework/formatterDecorator";
-import { ForSettings } from "./ForSettings";
-import { IConfigurationManager } from "../../../utils/IConfigurationManager";
-
-@RegisterFormatter
-export class ForFormatter extends AFormatter implements IFormatter {
- private startColumn = 0;
- private forBodyValue = "";
-
- public static readonly formatterLabel = "forFormatting";
- private readonly settings: ForSettings;
-
- public constructor(configurationManager: IConfigurationManager) {
- super(configurationManager);
- this.settings = new ForSettings(configurationManager);
- }
-
- match(node: Readonly): boolean {
- if (node.type === SyntaxNodeType.ForStatement) {
- return true;
- }
-
- return false;
- }
-
- parse(
- node: Readonly,
- fullText: Readonly
- ): CodeEdit | CodeEdit[] | undefined {
- this.collectForStructure(node, fullText);
-
- return this.getCodeEdit(
- node,
- FormatterHelper.getCurrentText(node, fullText),
- this.forBodyValue,
- fullText
- );
- }
-
- private collectForStructure(
- node: SyntaxNode,
- fullText: Readonly
- ) {
- this.startColumn = node.startPosition.column;
- console.log("startColumn");
- console.log(this.startColumn);
- this.forBodyValue = this.getForStatementBlock(node, fullText);
- }
-
- private getForStatementBlock(
- node: SyntaxNode,
- fullText: Readonly
- ): string {
- let resultString = "";
- let alignColumn = 0;
-
- console.log("Node Type:", node.type);
- console.log("Node Start Position:", node.startIndex);
- console.log("Node End Position:", node.endIndex);
-
- node.children.forEach((child) => {
- if (child.type === SyntaxNodeType.Identifier) {
- alignColumn = this.startColumn + resultString.length;
- }
- resultString = resultString.concat(
- this.getForExpressionString(child, fullText, alignColumn)
- );
- });
-
- return resultString;
- }
-
- private getForExpressionString(
- node: SyntaxNode,
- fullText: Readonly,
- alignColumn: number
- ): string {
- let newString = "";
-
- console.log("Node Type:", node.type);
- console.log("Node Start Position:", node.startIndex);
- console.log("Node End Position:", node.endIndex);
-
- switch (node.type) {
- case SyntaxNodeType.ForKeyword:
- console.log("ForKeyword");
- newString = FormatterHelper.getCurrentText(
- node,
- fullText
- ).trim();
- break;
- case SyntaxNodeType.WhereClause:
- console.log("WhereClause");
- newString = this.getWhereClauseBlock(
- node,
- fullText,
- alignColumn
- );
- break;
- default:
- console.log("default");
- const text = FormatterHelper.getCurrentText(
- node,
- fullText
- ).trim();
- newString = text.length === 0 ? "" : " " + text;
- console.log("Default Case - Text:", newString);
- break;
- }
-
- return newString;
- }
-
- private getWhereClauseBlock(
- node: SyntaxNode,
- fullText: Readonly,
- alignColumn: number
- ): string {
- let resultString = "";
-
- node.children.forEach((child) => {
- switch (child.type) {
- case SyntaxNodeType.WhereKeyword:
- console.log("WhereKeyword");
- resultString = resultString.concat(
- " ",
- FormatterHelper.getCurrentText(child, fullText).trim(),
- fullText.eolDelimiter,
- " ".repeat(alignColumn)
- );
- break;
- default:
- const text = FormatterHelper.getCurrentText(
- child,
- fullText
- ).trim();
- console.log("default getWhereClauseBlock");
- resultString = resultString.concat(
- text.length === 0 ? "" : " " + text
- );
- break;
- }
- });
-
- return resultString;
- }
-}
From f50de77eedc0bf5112a303af9dd35d1cbcc9a5e5 Mon Sep 17 00:00:00 2001
From: sjonynaite
Date: Fri, 30 Aug 2024 10:05:44 +0300
Subject: [PATCH 09/79] changed some block test, because forFormatter was
turned on
---
resources/functionalTests/block/12for-block-end2/input.p | 3 ++-
resources/functionalTests/block/12for-block-end2/target.p | 3 ++-
resources/functionalTests/block/15for-block-inner2/input.p | 3 ++-
resources/functionalTests/block/15for-block-inner2/target.p | 3 ++-
resources/functionalTests/block/17for-block-inner4/input.p | 3 ++-
resources/functionalTests/block/17for-block-inner4/target.p | 3 ++-
.../functionalTests/block/51do-for-block-inner1/input.p | 3 ++-
.../functionalTests/block/51do-for-block-inner1/target.p | 3 ++-
.../functionalTests/block/51for-for-block-inner1/input.p | 3 ++-
.../functionalTests/block/51for-for-block-inner1/target.p | 3 ++-
resources/functionalTests/emptyBlock/11for/input.p | 3 ++-
resources/functionalTests/emptyBlock/11for/target.p | 3 ++-
src/v2/formatters/for/ForFormatter.ts | 5 ++++-
13 files changed, 28 insertions(+), 13 deletions(-)
diff --git a/resources/functionalTests/block/12for-block-end2/input.p b/resources/functionalTests/block/12for-block-end2/input.p
index 8dc92c9f..51b7eb73 100644
--- a/resources/functionalTests/block/12for-block-end2/input.p
+++ b/resources/functionalTests/block/12for-block-end2/input.p
@@ -1,5 +1,6 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.blockFormatting": false}*/
+/* { "AblFormatter.blockFormatting": false,
+"AblFormatter.forFormatting": false}*/
for each Customer no-lock:
Customer.var += 1.
diff --git a/resources/functionalTests/block/12for-block-end2/target.p b/resources/functionalTests/block/12for-block-end2/target.p
index 8dc92c9f..51b7eb73 100644
--- a/resources/functionalTests/block/12for-block-end2/target.p
+++ b/resources/functionalTests/block/12for-block-end2/target.p
@@ -1,5 +1,6 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.blockFormatting": false}*/
+/* { "AblFormatter.blockFormatting": false,
+"AblFormatter.forFormatting": false}*/
for each Customer no-lock:
Customer.var += 1.
diff --git a/resources/functionalTests/block/15for-block-inner2/input.p b/resources/functionalTests/block/15for-block-inner2/input.p
index 9718d0f1..b3ff775e 100644
--- a/resources/functionalTests/block/15for-block-inner2/input.p
+++ b/resources/functionalTests/block/15for-block-inner2/input.p
@@ -1,5 +1,6 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.blockFormatting": false}*/
+/* { "AblFormatter.blockFormatting": false,
+"AblFormatter.forFormatting": false}*/
for each Customer no-lock:
Customer.var += 1.
diff --git a/resources/functionalTests/block/15for-block-inner2/target.p b/resources/functionalTests/block/15for-block-inner2/target.p
index 9718d0f1..b3ff775e 100644
--- a/resources/functionalTests/block/15for-block-inner2/target.p
+++ b/resources/functionalTests/block/15for-block-inner2/target.p
@@ -1,5 +1,6 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.blockFormatting": false}*/
+/* { "AblFormatter.blockFormatting": false,
+"AblFormatter.forFormatting": false}*/
for each Customer no-lock:
Customer.var += 1.
diff --git a/resources/functionalTests/block/17for-block-inner4/input.p b/resources/functionalTests/block/17for-block-inner4/input.p
index 9ca202f6..e0218896 100644
--- a/resources/functionalTests/block/17for-block-inner4/input.p
+++ b/resources/functionalTests/block/17for-block-inner4/input.p
@@ -1,5 +1,6 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.blockFormatting": false}*/
+/* { "AblFormatter.blockFormatting": false,
+"AblFormatter.forFormatting": false}*/
for each Customer no-lock:
Customer.var += 1.
diff --git a/resources/functionalTests/block/17for-block-inner4/target.p b/resources/functionalTests/block/17for-block-inner4/target.p
index 9ca202f6..e0218896 100644
--- a/resources/functionalTests/block/17for-block-inner4/target.p
+++ b/resources/functionalTests/block/17for-block-inner4/target.p
@@ -1,5 +1,6 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.blockFormatting": false}*/
+/* { "AblFormatter.blockFormatting": false,
+"AblFormatter.forFormatting": false}*/
for each Customer no-lock:
Customer.var += 1.
diff --git a/resources/functionalTests/block/51do-for-block-inner1/input.p b/resources/functionalTests/block/51do-for-block-inner1/input.p
index fc9a2559..3da3c26a 100644
--- a/resources/functionalTests/block/51do-for-block-inner1/input.p
+++ b/resources/functionalTests/block/51do-for-block-inner1/input.p
@@ -1,5 +1,6 @@
/* formattersettingsoverride */
-/* { "AblFormatter.blockFormatting": true}*/
+/* { "AblFormatter.blockFormatting": true,
+"AblFormatter.forFormatting": false}*/
do transaction:
for each Customer no-lock:
diff --git a/resources/functionalTests/block/51do-for-block-inner1/target.p b/resources/functionalTests/block/51do-for-block-inner1/target.p
index 90344ec5..5c03e7c6 100644
--- a/resources/functionalTests/block/51do-for-block-inner1/target.p
+++ b/resources/functionalTests/block/51do-for-block-inner1/target.p
@@ -1,5 +1,6 @@
/* formattersettingsoverride */
-/* { "AblFormatter.blockFormatting": true}*/
+/* { "AblFormatter.blockFormatting": true,
+"AblFormatter.forFormatting": false}*/
do transaction:
for each Customer no-lock:
diff --git a/resources/functionalTests/block/51for-for-block-inner1/input.p b/resources/functionalTests/block/51for-for-block-inner1/input.p
index 9b59fbaa..c19d9714 100644
--- a/resources/functionalTests/block/51for-for-block-inner1/input.p
+++ b/resources/functionalTests/block/51for-for-block-inner1/input.p
@@ -1,5 +1,6 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.blockFormatting": true}*/
+/* { "AblFormatter.blockFormatting": true,
+"AblFormatter.forFormatting": false}*/
for each A no-lock:
for each B no-lock where A.id = B.id:
diff --git a/resources/functionalTests/block/51for-for-block-inner1/target.p b/resources/functionalTests/block/51for-for-block-inner1/target.p
index 097c6beb..b0383df6 100644
--- a/resources/functionalTests/block/51for-for-block-inner1/target.p
+++ b/resources/functionalTests/block/51for-for-block-inner1/target.p
@@ -1,5 +1,6 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.blockFormatting": true}*/
+/* { "AblFormatter.blockFormatting": true,
+"AblFormatter.forFormatting": false}*/
for each A no-lock:
for each B no-lock where A.id = B.id:
diff --git a/resources/functionalTests/emptyBlock/11for/input.p b/resources/functionalTests/emptyBlock/11for/input.p
index e0c04cc9..bde39dc9 100644
--- a/resources/functionalTests/emptyBlock/11for/input.p
+++ b/resources/functionalTests/emptyBlock/11for/input.p
@@ -1,5 +1,6 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.emptyBlockFormatting": true}*/
+/* { "AblFormatter.emptyBlockFormatting": true,
+"AblFormatter.forFormatting": false}*/
for each Customer by Customer.CreditLimit by Customer.Name:
end.
diff --git a/resources/functionalTests/emptyBlock/11for/target.p b/resources/functionalTests/emptyBlock/11for/target.p
index bfcf75dc..c4e7b25e 100644
--- a/resources/functionalTests/emptyBlock/11for/target.p
+++ b/resources/functionalTests/emptyBlock/11for/target.p
@@ -1,5 +1,6 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.emptyBlockFormatting": true}*/
+/* { "AblFormatter.emptyBlockFormatting": true,
+"AblFormatter.forFormatting": false}*/
for each Customer by Customer.CreditLimit by Customer.Name:
end.
diff --git a/src/v2/formatters/for/ForFormatter.ts b/src/v2/formatters/for/ForFormatter.ts
index f793c7e1..14ca3b9d 100644
--- a/src/v2/formatters/for/ForFormatter.ts
+++ b/src/v2/formatters/for/ForFormatter.ts
@@ -48,7 +48,10 @@ export class ForFormatter extends AFormatter implements IFormatter {
node: SyntaxNode,
fullText: Readonly
) {
- this.startColumn = node.startPosition.column;
+ this.startColumn = FormatterHelper.getActualStatementIndentation(
+ node,
+ fullText
+ );
this.forBodyValue = this.getForStatementBlock(node, fullText);
}
From ad4979281d45722b8ab2a57065a90bd8b5397dd8 Mon Sep 17 00:00:00 2001
From: gmickus
Date: Fri, 6 Sep 2024 11:48:24 +0300
Subject: [PATCH 10/79] Change block node instead of parent
---
src/v2/formatters/block/BlockFormatter.ts | 42 +++++++++++++++--------
src/v2/formatters/for/ForFormatter.ts | 4 +++
2 files changed, 32 insertions(+), 14 deletions(-)
diff --git a/src/v2/formatters/block/BlockFormatter.ts b/src/v2/formatters/block/BlockFormatter.ts
index 87fb72b8..155be66b 100644
--- a/src/v2/formatters/block/BlockFormatter.ts
+++ b/src/v2/formatters/block/BlockFormatter.ts
@@ -1,6 +1,9 @@
import { SyntaxNode } from "web-tree-sitter";
import { IFormatter } from "../../formatterFramework/IFormatter";
-import { bodyBlockKeywords, SyntaxNodeType } from "../../../model/SyntaxNodeType";
+import {
+ bodyBlockKeywords,
+ SyntaxNodeType,
+} from "../../../model/SyntaxNodeType";
import { CodeEdit } from "../../model/CodeEdit";
import { FullText } from "../../model/FullText";
import { FormatterHelper } from "../../formatterFramework/FormatterHelper";
@@ -32,6 +35,7 @@ export class BlockFormater extends AFormatter implements IFormatter {
node: Readonly,
fullText: Readonly
): CodeEdit | CodeEdit[] | undefined {
+ console.log("found: " + node.type);
let indentationEdits: IndentationEdits[] = [];
let parent = node.parent;
@@ -58,25 +62,32 @@ export class BlockFormater extends AFormatter implements IFormatter {
);
const indentationStep = this.settings.tabSize();
- const blockStatementsStartRows = node.children.map(
- (node) =>
- node.startPosition.row +
- FormatterHelper.getActualTextRow(
- FormatterHelper.getCurrentText(node, fullText),
- fullText
- )
- );
+ console.log("text:\n" + FormatterHelper.getCurrentText(node, fullText));
+ const blockStatementsStartRows = node.children
+ .filter((child) => {
+ if (child.type === ":") {
+ return false;
+ }
+ return true;
+ })
+ .map(
+ (child) =>
+ child.startPosition.row +
+ FormatterHelper.getActualTextRow(
+ FormatterHelper.getCurrentText(child, fullText),
+ fullText
+ )
+ );
const codeLines = FormatterHelper.getCurrentText(parent, fullText)
.split(fullText.eolDelimiter)
- .slice(1, -1);
+ .slice(0, -1);
let n = 0;
let lineChangeDelta = 0;
codeLines.forEach((codeLine, index) => {
- // the first line was removed, so index needs to be incremented
- index++;
const lineNumber = parent.startPosition.row + index;
+ console.log("line:\n" + codeLine);
// adjust delta
if (blockStatementsStartRows[n] === lineNumber) {
@@ -127,7 +138,7 @@ export class BlockFormater extends AFormatter implements IFormatter {
}
return this.getCodeEditsFromIndentationEdits(
- parent,
+ node,
fullText,
indentationEdits
);
@@ -145,6 +156,9 @@ export class BlockFormater extends AFormatter implements IFormatter {
fullText
);
+ console.log("oldText:\n" + text);
+ console.log("newBlockText:\n" + newText);
+
return this.getCodeEdit(node, text, newText, fullText);
}
@@ -197,7 +211,7 @@ export class BlockFormater extends AFormatter implements IFormatter {
node.parent?.type === SyntaxNodeType.CaseOtherwiseBranch)
) {
return node.parent;
- }else if (
+ } else if (
node.type === SyntaxNodeType.DoBlock &&
(node.parent?.type === SyntaxNodeType.ElseIfStatement ||
node.parent?.type === SyntaxNodeType.ElseStatement)
diff --git a/src/v2/formatters/for/ForFormatter.ts b/src/v2/formatters/for/ForFormatter.ts
index 14ca3b9d..df2aed75 100644
--- a/src/v2/formatters/for/ForFormatter.ts
+++ b/src/v2/formatters/for/ForFormatter.ts
@@ -66,6 +66,10 @@ export class ForFormatter extends AFormatter implements IFormatter {
if (child.type === SyntaxNodeType.Identifier) {
alignColumn = this.startColumn + resultString.length;
}
+ console.log("child: " + child.type);
+ console.log(
+ "childText: " + FormatterHelper.getCurrentText(child, fullText)
+ );
resultString = resultString.concat(
this.getForExpressionString(child, fullText, alignColumn)
);
From 8650ecd43e968be7e1c958fd9cdc6fc15f07dd5e Mon Sep 17 00:00:00 2001
From: gmickus
Date: Fri, 6 Sep 2024 13:41:43 +0300
Subject: [PATCH 11/79] Improve for and block formatting
---
src/v2/formatterFramework/FormatterHelper.ts | 9 +++++++
src/v2/formatters/block/BlockFormatter.ts | 27 +++++++++++++++++---
src/v2/formatters/for/ForFormatter.ts | 8 +++---
3 files changed, 36 insertions(+), 8 deletions(-)
diff --git a/src/v2/formatterFramework/FormatterHelper.ts b/src/v2/formatterFramework/FormatterHelper.ts
index 1874241d..6887a562 100644
--- a/src/v2/formatterFramework/FormatterHelper.ts
+++ b/src/v2/formatterFramework/FormatterHelper.ts
@@ -79,6 +79,15 @@ export class FormatterHelper {
return "";
}
+ public static getBodyText(
+ node: Readonly,
+ fullText: Readonly
+ ): string {
+ let text = this.getCurrentText(node, fullText);
+ let firstColonIndex = text.indexOf(":");
+ return text.substring(firstColonIndex + 1);
+ }
+
public static getCurrentTextMultilineAdjust(
node: Readonly,
fullText: Readonly,
diff --git a/src/v2/formatters/block/BlockFormatter.ts b/src/v2/formatters/block/BlockFormatter.ts
index 6867847e..9eabea7d 100644
--- a/src/v2/formatters/block/BlockFormatter.ts
+++ b/src/v2/formatters/block/BlockFormatter.ts
@@ -77,14 +77,19 @@ export class BlockFormater extends AFormatter implements IFormatter {
)
);
- const codeLines = FormatterHelper.getCurrentText(parent, fullText)
- .split(fullText.eolDelimiter)
- .slice(0, -1);
+ console.log(
+ "Body text:\n " + FormatterHelper.getBodyText(node, fullText)
+ );
+ console.log("blockStatement:\n" + blockStatementsStartRows);
+ const codeLines = FormatterHelper.getBodyText(node, fullText).split(
+ fullText.eolDelimiter
+ );
let n = 0;
let lineChangeDelta = 0;
codeLines.forEach((codeLine, index) => {
- const lineNumber = parent.startPosition.row + index;
+ const lineNumber = node.startPosition.row + index;
+ console.log("line nr " + lineNumber + " :\n" + codeLine);
// adjust delta
if (blockStatementsStartRows[n] === lineNumber) {
@@ -96,9 +101,23 @@ export class BlockFormater extends AFormatter implements IFormatter {
fullText
);
+ console.log(
+ "ind: " +
+ parentIndentation +
+ " " +
+ indentationStep +
+ " " +
+ FormatterHelper.getActualTextIndentation(
+ codeLine,
+ fullText
+ )
+ );
+
n++;
}
+ console.log("myDelta: " + lineChangeDelta);
+
if (lineChangeDelta !== 0) {
indentationEdits.push({
line: index,
diff --git a/src/v2/formatters/for/ForFormatter.ts b/src/v2/formatters/for/ForFormatter.ts
index df2aed75..7df95056 100644
--- a/src/v2/formatters/for/ForFormatter.ts
+++ b/src/v2/formatters/for/ForFormatter.ts
@@ -122,10 +122,10 @@ export class ForFormatter extends AFormatter implements IFormatter {
);
break;
case SyntaxNodeType.Body:
- newString =
- fullText.eolDelimiter +
- " ".repeat(this.startColumn + this.settings.tabSize()) +
- FormatterHelper.getCurrentText(node, fullText).trim();
+ newString = FormatterHelper.getCurrentText(
+ node,
+ fullText
+ ).trim();
break;
default:
const text = FormatterHelper.getCurrentText(
From e68add4ab7803cdaed6318143f98cb4d392a28b3 Mon Sep 17 00:00:00 2001
From: gmickus
Date: Fri, 6 Sep 2024 13:48:33 +0300
Subject: [PATCH 12/79] Update for tests
---
resources/functionalTests/for/2each-true/input.p | 4 ++--
resources/functionalTests/for/2each-true/target.p | 2 +-
resources/functionalTests/for/3each-each/target.p | 2 +-
resources/functionalTests/for/3each-where/target.p | 2 +-
resources/functionalTests/for/3first-by/input.p | 2 +-
resources/functionalTests/for/3first-by/target.p | 2 +-
6 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/resources/functionalTests/for/2each-true/input.p b/resources/functionalTests/for/2each-true/input.p
index 9e0bcf5c..018ffa2f 100644
--- a/resources/functionalTests/for/2each-true/input.p
+++ b/resources/functionalTests/for/2each-true/input.p
@@ -1,9 +1,9 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.blockFormatting": false,
+/* { "AblFormatter.blockFormatting": true,
"AblFormatter.forFormatting": true
}*/
-for
+for
each
Customer:
Customer.var += 1.
diff --git a/resources/functionalTests/for/2each-true/target.p b/resources/functionalTests/for/2each-true/target.p
index c17ee35d..dbbe3133 100644
--- a/resources/functionalTests/for/2each-true/target.p
+++ b/resources/functionalTests/for/2each-true/target.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.blockFormatting": false,
+/* { "AblFormatter.blockFormatting": true,
"AblFormatter.forFormatting": true
}*/
diff --git a/resources/functionalTests/for/3each-each/target.p b/resources/functionalTests/for/3each-each/target.p
index e1b14473..12005a10 100644
--- a/resources/functionalTests/for/3each-each/target.p
+++ b/resources/functionalTests/for/3each-each/target.p
@@ -1,6 +1,6 @@
/* formatterSettingsOverride */
/* { "AblFormatter.forFormatting": true,
-"AblFormatter.blockFormatting": false,
+"AblFormatter.blockFormatting": true,
"abl.completion.upperCase": true}*/
FOR EACH Customer NO-LOCK,
diff --git a/resources/functionalTests/for/3each-where/target.p b/resources/functionalTests/for/3each-where/target.p
index 241df442..a376627f 100644
--- a/resources/functionalTests/for/3each-where/target.p
+++ b/resources/functionalTests/for/3each-where/target.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.blockFormatting": false,
+/* { "AblFormatter.blockFormatting": true,
"AblFormatter.forFormatting": true
}*/
diff --git a/resources/functionalTests/for/3first-by/input.p b/resources/functionalTests/for/3first-by/input.p
index 34adf0a4..4a7983aa 100644
--- a/resources/functionalTests/for/3first-by/input.p
+++ b/resources/functionalTests/for/3first-by/input.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.blockFormatting": false,
+/* { "AblFormatter.blockFormatting": true,
"AblFormatter.forFormatting": true
}*/
diff --git a/resources/functionalTests/for/3first-by/target.p b/resources/functionalTests/for/3first-by/target.p
index bebe9df1..02ca12ed 100644
--- a/resources/functionalTests/for/3first-by/target.p
+++ b/resources/functionalTests/for/3first-by/target.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.blockFormatting": false,
+/* { "AblFormatter.blockFormatting": true,
"AblFormatter.forFormatting": true
}*/
From 3002e9df50c8257521ae1ef081385b5ceedf8769 Mon Sep 17 00:00:00 2001
From: gmickus
Date: Mon, 9 Sep 2024 12:11:34 +0300
Subject: [PATCH 13/79] Fix for support
---
.../input.p | 2 +-
.../target.p | 2 +-
.../input.p | 2 +-
.../target.p | 2 +-
.../input.p | 2 +-
.../target.p | 2 +-
.../block/45repeat-block-end1/input.p | 2 +-
.../functionalTests/emptyBlock/11for/input.p | 3 +-
.../functionalTests/emptyBlock/11for/target.p | 7 +-
.../functionalTests/for/2each-true/input.p | 2 +-
.../functionalTests/for/3each-each/input.p | 2 +-
.../functionalTests/for/3each-where/input.p | 11 +-
.../functionalTests/for/3each-where/target.p | 2 +
.../if/10-then-same-do-same-else-do/input.p | 10 +-
.../if/10-then-same-do-same-else-do/target.p | 1 -
.../ifFunction/11else-new-line-in-for/input.p | 16 ++
.../11else-new-line-in-for/target.p | 18 ++
.../enableFormatterDecorators.ts | 2 +-
src/v2/formatters/block/BlockFormatter.ts | 42 +--
.../emptyblock/EmptyBlockFormatter.ts | 271 ++++++++++++------
20 files changed, 262 insertions(+), 139 deletions(-)
rename resources/functionalTests/block/{12for-block-end2 => 12for-block-end2-disabled}/input.p (72%)
rename resources/functionalTests/block/{12for-block-end2 => 12for-block-end2-disabled}/target.p (72%)
rename resources/functionalTests/block/{15for-block-inner2 => 15for-block-inner2-disabled}/input.p (71%)
rename resources/functionalTests/block/{15for-block-inner2 => 15for-block-inner2-disabled}/target.p (71%)
rename resources/functionalTests/block/{17for-block-inner4 => 17for-block-inner4-disabled}/input.p (72%)
rename resources/functionalTests/block/{17for-block-inner4 => 17for-block-inner4-disabled}/target.p (72%)
create mode 100644 resources/functionalTests/ifFunction/11else-new-line-in-for/input.p
create mode 100644 resources/functionalTests/ifFunction/11else-new-line-in-for/target.p
diff --git a/resources/functionalTests/block/12for-block-end2/input.p b/resources/functionalTests/block/12for-block-end2-disabled/input.p
similarity index 72%
rename from resources/functionalTests/block/12for-block-end2/input.p
rename to resources/functionalTests/block/12for-block-end2-disabled/input.p
index 51b7eb73..fb0925bc 100644
--- a/resources/functionalTests/block/12for-block-end2/input.p
+++ b/resources/functionalTests/block/12for-block-end2-disabled/input.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.blockFormatting": false,
+/* { "AblFormatter.emptyBlockFormatting": false,
"AblFormatter.forFormatting": false}*/
for each Customer no-lock:
diff --git a/resources/functionalTests/block/12for-block-end2/target.p b/resources/functionalTests/block/12for-block-end2-disabled/target.p
similarity index 72%
rename from resources/functionalTests/block/12for-block-end2/target.p
rename to resources/functionalTests/block/12for-block-end2-disabled/target.p
index 51b7eb73..fb0925bc 100644
--- a/resources/functionalTests/block/12for-block-end2/target.p
+++ b/resources/functionalTests/block/12for-block-end2-disabled/target.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.blockFormatting": false,
+/* { "AblFormatter.emptyBlockFormatting": false,
"AblFormatter.forFormatting": false}*/
for each Customer no-lock:
diff --git a/resources/functionalTests/block/15for-block-inner2/input.p b/resources/functionalTests/block/15for-block-inner2-disabled/input.p
similarity index 71%
rename from resources/functionalTests/block/15for-block-inner2/input.p
rename to resources/functionalTests/block/15for-block-inner2-disabled/input.p
index b3ff775e..70700ee9 100644
--- a/resources/functionalTests/block/15for-block-inner2/input.p
+++ b/resources/functionalTests/block/15for-block-inner2-disabled/input.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.blockFormatting": false,
+/* { "AblFormatter.emptyBlockFormatting": false,
"AblFormatter.forFormatting": false}*/
for each Customer no-lock:
diff --git a/resources/functionalTests/block/15for-block-inner2/target.p b/resources/functionalTests/block/15for-block-inner2-disabled/target.p
similarity index 71%
rename from resources/functionalTests/block/15for-block-inner2/target.p
rename to resources/functionalTests/block/15for-block-inner2-disabled/target.p
index b3ff775e..70700ee9 100644
--- a/resources/functionalTests/block/15for-block-inner2/target.p
+++ b/resources/functionalTests/block/15for-block-inner2-disabled/target.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.blockFormatting": false,
+/* { "AblFormatter.emptyBlockFormatting": false,
"AblFormatter.forFormatting": false}*/
for each Customer no-lock:
diff --git a/resources/functionalTests/block/17for-block-inner4/input.p b/resources/functionalTests/block/17for-block-inner4-disabled/input.p
similarity index 72%
rename from resources/functionalTests/block/17for-block-inner4/input.p
rename to resources/functionalTests/block/17for-block-inner4-disabled/input.p
index e0218896..d0e8b53a 100644
--- a/resources/functionalTests/block/17for-block-inner4/input.p
+++ b/resources/functionalTests/block/17for-block-inner4-disabled/input.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.blockFormatting": false,
+/* { "AblFormatter.emptyBlockFormatting": false,
"AblFormatter.forFormatting": false}*/
for each Customer no-lock:
diff --git a/resources/functionalTests/block/17for-block-inner4/target.p b/resources/functionalTests/block/17for-block-inner4-disabled/target.p
similarity index 72%
rename from resources/functionalTests/block/17for-block-inner4/target.p
rename to resources/functionalTests/block/17for-block-inner4-disabled/target.p
index e0218896..d0e8b53a 100644
--- a/resources/functionalTests/block/17for-block-inner4/target.p
+++ b/resources/functionalTests/block/17for-block-inner4-disabled/target.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.blockFormatting": false,
+/* { "AblFormatter.emptyBlockFormatting": false,
"AblFormatter.forFormatting": false}*/
for each Customer no-lock:
diff --git a/resources/functionalTests/block/45repeat-block-end1/input.p b/resources/functionalTests/block/45repeat-block-end1/input.p
index 11fc3bd2..bac821e3 100644
--- a/resources/functionalTests/block/45repeat-block-end1/input.p
+++ b/resources/functionalTests/block/45repeat-block-end1/input.p
@@ -3,4 +3,4 @@
repeat:
define variable a as integer no-undo.
- end.
\ No newline at end of file
+ end.
\ No newline at end of file
diff --git a/resources/functionalTests/emptyBlock/11for/input.p b/resources/functionalTests/emptyBlock/11for/input.p
index bde39dc9..7d52f5d1 100644
--- a/resources/functionalTests/emptyBlock/11for/input.p
+++ b/resources/functionalTests/emptyBlock/11for/input.p
@@ -1,6 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.emptyBlockFormatting": true,
-"AblFormatter.forFormatting": false}*/
+/* { "AblFormatter.forFormatting": true}*/
for each Customer by Customer.CreditLimit by Customer.Name:
end.
diff --git a/resources/functionalTests/emptyBlock/11for/target.p b/resources/functionalTests/emptyBlock/11for/target.p
index c4e7b25e..f1b51da0 100644
--- a/resources/functionalTests/emptyBlock/11for/target.p
+++ b/resources/functionalTests/emptyBlock/11for/target.p
@@ -1,6 +1,7 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.emptyBlockFormatting": true,
-"AblFormatter.forFormatting": false}*/
+/* { "AblFormatter.forFormatting": true}*/
-for each Customer by Customer.CreditLimit by Customer.Name:
+for each Customer
+ by Customer.CreditLimit
+ by Customer.Name:
end.
diff --git a/resources/functionalTests/for/2each-true/input.p b/resources/functionalTests/for/2each-true/input.p
index 018ffa2f..b554fef5 100644
--- a/resources/functionalTests/for/2each-true/input.p
+++ b/resources/functionalTests/for/2each-true/input.p
@@ -6,5 +6,5 @@
for
each
Customer:
- Customer.var += 1.
+ Customer.var += 1.
end.
\ No newline at end of file
diff --git a/resources/functionalTests/for/3each-each/input.p b/resources/functionalTests/for/3each-each/input.p
index 6fd53d69..fe21641b 100644
--- a/resources/functionalTests/for/3each-each/input.p
+++ b/resources/functionalTests/for/3each-each/input.p
@@ -1,6 +1,6 @@
/* formatterSettingsOverride */
/* { "AblFormatter.forFormatting": true,
-"AblFormatter.blockFormatting": false,
+"AblFormatter.blockFormatting": true,
"abl.completion.upperCase": true}*/
FOR EACH Customer NO-LOCK, EACH Order OF Customer NO-LOCK, EACH OrderLine OF Order NO-LOCK BY Order.PromiseDate BY Customer.CustNum BY OrderLine.LineNum:
diff --git a/resources/functionalTests/for/3each-where/input.p b/resources/functionalTests/for/3each-where/input.p
index 89fdd870..3ea0e319 100644
--- a/resources/functionalTests/for/3each-where/input.p
+++ b/resources/functionalTests/for/3each-where/input.p
@@ -1,8 +1,11 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.blockFormatting": false,
+/* { "AblFormatter.blockFormatting": true,
"AblFormatter.forFormatting": true
}*/
-for each Customer where Customer.var = 1:
- Customer.var += 1.
-end.
\ No newline at end of file
+for each Customer where
+ Customer.var = 1:
+ Customer.var += 1.
+ Customer.var *= 2.
+ Customer.var /= 3.
+ end.
\ No newline at end of file
diff --git a/resources/functionalTests/for/3each-where/target.p b/resources/functionalTests/for/3each-where/target.p
index a376627f..4ce7747a 100644
--- a/resources/functionalTests/for/3each-where/target.p
+++ b/resources/functionalTests/for/3each-where/target.p
@@ -6,4 +6,6 @@
for each Customer where
Customer.var = 1:
Customer.var += 1.
+ Customer.var *= 2.
+ Customer.var /= 3.
end.
\ No newline at end of file
diff --git a/resources/functionalTests/if/10-then-same-do-same-else-do/input.p b/resources/functionalTests/if/10-then-same-do-same-else-do/input.p
index 39b38c11..b6570f16 100644
--- a/resources/functionalTests/if/10-then-same-do-same-else-do/input.p
+++ b/resources/functionalTests/if/10-then-same-do-same-else-do/input.p
@@ -1,14 +1,12 @@
/* formatterSettingsOverride */
/* { "AblFormatter.ifFormatting": true,
-"AblFormatter.blockFormatting": true,
"AblFormatter.ifFormattingThenLocation": "Same",
"AblFormatter.ifFormattingDoLocation": "Same"}*/
-if a = b then do:
+if a = b then do:
return a.
end.
-
- else do:
- return b.
- end.
+else do:
+ return b.
+ end.
diff --git a/resources/functionalTests/if/10-then-same-do-same-else-do/target.p b/resources/functionalTests/if/10-then-same-do-same-else-do/target.p
index 50d0f6cc..9b81c0fa 100644
--- a/resources/functionalTests/if/10-then-same-do-same-else-do/target.p
+++ b/resources/functionalTests/if/10-then-same-do-same-else-do/target.p
@@ -1,6 +1,5 @@
/* formatterSettingsOverride */
/* { "AblFormatter.ifFormatting": true,
-"AblFormatter.blockFormatting": true,
"AblFormatter.ifFormattingThenLocation": "Same",
"AblFormatter.ifFormattingDoLocation": "Same"}*/
diff --git a/resources/functionalTests/ifFunction/11else-new-line-in-for/input.p b/resources/functionalTests/ifFunction/11else-new-line-in-for/input.p
new file mode 100644
index 00000000..5ed62378
--- /dev/null
+++ b/resources/functionalTests/ifFunction/11else-new-line-in-for/input.p
@@ -0,0 +1,16 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.ifFunctionFormatting": true,
+ "AblFormatter.ifFunctionFormattingAddParentheses": "No",
+ "AblFormatter.ifFunctionFormattingElseLocation": "New"}*/
+
+FOR EACH Customer NO-LOCK
+BY IF Customer.Balance > 10000 THEN 1 ELSE
+ IF Customer.Balance > 5000 THEN 1.5 ELSE
+ IF Customer.Balance > 1000 THEN 2 ELSE
+ IF Customer.Balance > 500 THEN 2.5 ELSE 3
+ BY IF Customer.SalesRep = "John" THEN 1 ELSE
+ IF Customer.SalesRep = "Jane" THEN 2 ELSE
+ IF Customer.SalesRep = "Doe" THEN 3 ELSE 4:
+ DISPLAY Customer.SalesRep Customer.Balance Customer.Name.
+ END.
+
\ No newline at end of file
diff --git a/resources/functionalTests/ifFunction/11else-new-line-in-for/target.p b/resources/functionalTests/ifFunction/11else-new-line-in-for/target.p
new file mode 100644
index 00000000..c64cd6c9
--- /dev/null
+++ b/resources/functionalTests/ifFunction/11else-new-line-in-for/target.p
@@ -0,0 +1,18 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.ifFunctionFormatting": true,
+ "AblFormatter.ifFunctionFormattingAddParentheses": "No",
+ "AblFormatter.ifFunctionFormattingElseLocation": "New"}*/
+
+FOR EACH Customer NO-LOCK
+ BY IF Customer.Balance > 10000 THEN 1
+ ELSE IF Customer.Balance > 5000 THEN 1.5
+ ELSE IF Customer.Balance > 1000 THEN 2
+ ELSE IF Customer.Balance > 500 THEN 2.5
+ ELSE 3
+ BY IF Customer.SalesRep = "John" THEN 1
+ ELSE IF Customer.SalesRep = "Jane" THEN 2
+ ELSE IF Customer.SalesRep = "Doe" THEN 3
+ ELSE 4:
+ DISPLAY Customer.SalesRep Customer.Balance Customer.Name.
+END.
+
\ No newline at end of file
diff --git a/src/v2/formatterFramework/enableFormatterDecorators.ts b/src/v2/formatterFramework/enableFormatterDecorators.ts
index 41f9c034..1ef5bd57 100644
--- a/src/v2/formatterFramework/enableFormatterDecorators.ts
+++ b/src/v2/formatterFramework/enableFormatterDecorators.ts
@@ -13,13 +13,13 @@ import { PropertyFormatter } from "../formatters/property/PropertyFormatter";
// needed just for enabling decorators. Decorators does not work if there is no usage of a class in the reachable code
export function enableFormatterDecorators(): void {
AssignFormatter;
+ EmptyBlockFormatter;
BlockFormater;
IfFormatter;
DefineFormatter;
UsingFormatter;
CaseFormatter;
ForFormatter;
- EmptyBlockFormatter;
TempTableFormatter;
PropertyFormatter;
IfFunctionFormatter;
diff --git a/src/v2/formatters/block/BlockFormatter.ts b/src/v2/formatters/block/BlockFormatter.ts
index 9eabea7d..8e8ca68f 100644
--- a/src/v2/formatters/block/BlockFormatter.ts
+++ b/src/v2/formatters/block/BlockFormatter.ts
@@ -22,14 +22,17 @@ export class BlockFormater extends AFormatter implements IFormatter {
this.settings = new BlockSettings(configurationManager);
}
- public match(node: Readonly): boolean {
- let found: boolean = false;
+ match(node: Readonly): boolean {
+ if (!bodyBlockKeywords.hasFancy(node.type, "")) {
+ return false;
+ }
- if (bodyBlockKeywords.hasFancy(node.type, "")) {
- found = true;
+ let parent = node.parent;
+ if (parent === null || parent.type === SyntaxNodeType.ForStatement) {
+ return false;
}
- return found;
+ return true;
}
public parse(
node: Readonly,
@@ -77,19 +80,14 @@ export class BlockFormater extends AFormatter implements IFormatter {
)
);
- console.log(
- "Body text:\n " + FormatterHelper.getBodyText(node, fullText)
- );
- console.log("blockStatement:\n" + blockStatementsStartRows);
- const codeLines = FormatterHelper.getBodyText(node, fullText).split(
- fullText.eolDelimiter
- );
+ const codeLines = FormatterHelper.getCurrentText(parent, fullText)
+ .split(fullText.eolDelimiter)
+ .slice(0, -1);
let n = 0;
let lineChangeDelta = 0;
codeLines.forEach((codeLine, index) => {
- const lineNumber = node.startPosition.row + index;
- console.log("line nr " + lineNumber + " :\n" + codeLine);
+ const lineNumber = parent.startPosition.row + index;
// adjust delta
if (blockStatementsStartRows[n] === lineNumber) {
@@ -101,23 +99,9 @@ export class BlockFormater extends AFormatter implements IFormatter {
fullText
);
- console.log(
- "ind: " +
- parentIndentation +
- " " +
- indentationStep +
- " " +
- FormatterHelper.getActualTextIndentation(
- codeLine,
- fullText
- )
- );
-
n++;
}
- console.log("myDelta: " + lineChangeDelta);
-
if (lineChangeDelta !== 0) {
indentationEdits.push({
line: index,
@@ -154,7 +138,7 @@ export class BlockFormater extends AFormatter implements IFormatter {
}
return this.getCodeEditsFromIndentationEdits(
- node,
+ parent,
fullText,
indentationEdits
);
diff --git a/src/v2/formatters/emptyblock/EmptyBlockFormatter.ts b/src/v2/formatters/emptyblock/EmptyBlockFormatter.ts
index 15575918..898bab4d 100644
--- a/src/v2/formatters/emptyblock/EmptyBlockFormatter.ts
+++ b/src/v2/formatters/emptyblock/EmptyBlockFormatter.ts
@@ -6,7 +6,10 @@ import { FullText } from "../../model/FullText";
import { AFormatter } from "../AFormatter";
import { EmptyBlockSettings } from "./EmptyBlockSettings";
import { IConfigurationManager } from "../../../utils/IConfigurationManager";
-import { SyntaxNodeType } from "../../../model/SyntaxNodeType";
+import {
+ bodyBlockKeywords,
+ SyntaxNodeType,
+} from "../../../model/SyntaxNodeType";
import { FormatterHelper } from "../../formatterFramework/FormatterHelper";
@RegisterFormatter
@@ -19,129 +22,229 @@ export class EmptyBlockFormatter extends AFormatter implements IFormatter {
this.settings = new EmptyBlockSettings(configurationManager);
}
- match(node: Readonly): boolean {
- // Special case for ON DO block
- if (node.type === SyntaxNodeType.DoBlock) {
- if (
- node.parent !== null &&
- node.parent.type === SyntaxNodeType.OnStatement
- ) {
- return false;
- }
+ public match(node: Readonly): boolean {
+ if (!bodyBlockKeywords.hasFancy(node.type, "")) {
+ return false;
}
- // If the node is not a block type, do not match
- if (
- node.type !== SyntaxNodeType.DoBlock &&
- node.type !== SyntaxNodeType.ClassStatement &&
- node.type !== SyntaxNodeType.CatchStatement &&
- node.type !== SyntaxNodeType.ConstructorDefinition &&
- node.type !== SyntaxNodeType.DestructorDefinition &&
- node.type !== SyntaxNodeType.ForStatement &&
- node.type !== SyntaxNodeType.FinallyStatement &&
- node.type !== SyntaxNodeType.OnStatement &&
- node.type !== SyntaxNodeType.RepeatStatement &&
- node.type !== SyntaxNodeType.MethodDefinition &&
- node.type !== SyntaxNodeType.FunctionStatement &&
- node.type !== SyntaxNodeType.ProcedureStatement &&
- node.type !== SyntaxNodeType.Getter &&
- node.type !== SyntaxNodeType.Setter
- ) {
+ let parent = node.parent;
+ if (parent === null || parent.type !== SyntaxNodeType.ForStatement) {
return false;
}
- // Do not match if there is a body inside the block
- for (let child of node.children) {
- if (
- child.type === SyntaxNodeType.Body ||
- child.type === SyntaxNodeType.CaseBody ||
- child.type === SyntaxNodeType.ClassBody
- ) {
- return false;
- }
- }
return true;
}
- parse(
+ public parse(
node: Readonly,
fullText: Readonly
): CodeEdit | CodeEdit[] | undefined {
- const text = FormatterHelper.getCurrentText(node, fullText);
+ let indentationEdits: IndentationEdits[] = [];
- const statementIndentation =
- FormatterHelper.getActualStatementIndentation(node, fullText);
+ let parent = node.parent;
- const lastLine = FormatterHelper.getCurrentText(node, fullText)
- .split(fullText.eolDelimiter)
- .slice(-1)[0];
+ if (parent === null) {
+ return undefined;
+ }
let formattingOnStatement = false;
- // Special case for ON DO block: to find the end keyword, we need to search for it from the start of the DO block
- if (node.type === SyntaxNodeType.OnStatement) {
- const doNode = node.children.find(
- (child) => child.type === SyntaxNodeType.DoBlock
- );
- if (doNode === undefined) {
- return undefined;
+ if (parent.type === SyntaxNodeType.DoBlock) {
+ const grandParent = parent.parent;
+ if (
+ grandParent !== null &&
+ grandParent.type === SyntaxNodeType.OnStatement
+ ) {
+ parent = grandParent;
+ formattingOnStatement = true;
}
- node = doNode;
- formattingOnStatement = true;
}
- const endNode = node.children.find(
- (child) => child.type === SyntaxNodeType.EndKeyword
+ const parentIndentation = FormatterHelper.getActualStatementIndentation(
+ this.getParentIndentationSourceNode(parent),
+ fullText
);
- if (endNode === undefined) {
- return undefined;
- }
+ const indentationStep = this.settings.tabSize();
+ const blockStatementsStartRows = node.children
+ .filter((child) => {
+ if (child.type === ":") {
+ return false;
+ }
+ return true;
+ })
+ .map(
+ (child) =>
+ child.startPosition.row +
+ FormatterHelper.getActualTextRow(
+ FormatterHelper.getCurrentText(child, fullText),
+ fullText
+ )
+ );
+
+ console.log(
+ "Body text:\n " + FormatterHelper.getBodyText(node, fullText)
+ );
+ console.log("blockStatement:\n" + blockStatementsStartRows);
+ const codeLines = FormatterHelper.getBodyText(node, fullText).split(
+ fullText.eolDelimiter
+ );
- if (formattingOnStatement) {
- // REturn back to ON statement from the DO block
- if (node.parent === null) {
- return undefined;
+ let n = 0;
+ let lineChangeDelta = 0;
+ codeLines.forEach((codeLine, index) => {
+ const lineNumber = node.startPosition.row + index;
+ console.log("line nr " + lineNumber + " :\n" + codeLine);
+
+ // adjust delta
+ if (blockStatementsStartRows[n] === lineNumber) {
+ lineChangeDelta =
+ parentIndentation +
+ indentationStep -
+ FormatterHelper.getActualTextIndentation(
+ codeLine,
+ fullText
+ );
+
+ console.log(
+ "ind: " +
+ parentIndentation +
+ " " +
+ indentationStep +
+ " " +
+ FormatterHelper.getActualTextIndentation(
+ codeLine,
+ fullText
+ )
+ );
+
+ n++;
}
- node = node.parent;
- }
- const endRowDelta =
- statementIndentation -
- FormatterHelper.getActualTextIndentation(lastLine, fullText);
+ console.log("myDelta: " + lineChangeDelta);
- const indentationEdit: IndentationEdits = {
- line: node.endPosition.row - node.startPosition.row,
- lineChangeDelta: endRowDelta,
- };
+ if (lineChangeDelta !== 0) {
+ indentationEdits.push({
+ line: index,
+ lineChangeDelta: lineChangeDelta,
+ });
+ }
+ });
- const newText = this.applyIndentationEdit(
+ const lastLine = FormatterHelper.getCurrentText(parent, fullText)
+ .split(fullText.eolDelimiter)
+ .slice(-1)[0];
+
+ const parentOfEndNode = formattingOnStatement ? node.parent : parent;
+ if (parentOfEndNode !== null) {
+ const endNode = parentOfEndNode.children.find(
+ (node) => node.type === SyntaxNodeType.EndKeyword
+ );
+
+ if (endNode !== undefined) {
+ const endRowDelta =
+ parentIndentation -
+ FormatterHelper.getActualTextIndentation(
+ lastLine,
+ fullText
+ );
+
+ console.log("endDelta: " + endRowDelta);
+
+ if (endRowDelta !== 0) {
+ indentationEdits.push({
+ line: parent.endPosition.row - parent.startPosition.row,
+ lineChangeDelta: endRowDelta,
+ });
+ }
+ }
+ }
+
+ return this.getCodeEditsFromIndentationEdits(
+ node,
+ fullText,
+ indentationEdits
+ );
+ }
+
+ private getCodeEditsFromIndentationEdits(
+ node: SyntaxNode,
+ fullText: FullText,
+ indentationEdits: IndentationEdits[]
+ ): CodeEdit | CodeEdit[] | undefined {
+ const text = FormatterHelper.getCurrentText(node, fullText);
+ const newText = this.applyIndentationEdits(
text,
- indentationEdit,
+ indentationEdits,
fullText
);
+ console.log("oldText:\n" + text);
+ console.log("text:\n" + newText);
+
return this.getCodeEdit(node, text, newText, fullText);
}
- private applyIndentationEdit(
+ private applyIndentationEdits(
code: string,
- indentationEdit: IndentationEdits,
+ edits: IndentationEdits[],
fullText: FullText
): string {
+ // Split the code into lines
const lines = code.split(fullText.eolDelimiter);
- const currentLeadingSpaces =
- RegExp(/^\s*/).exec(lines[indentationEdit.line])?.[0].length || 0;
- const newLeadingSpaces = Math.max(
- 0,
- currentLeadingSpaces + indentationEdit.lineChangeDelta
- );
+ // Apply each edit
+ edits.forEach((edit) => {
+ const { line, lineChangeDelta } = edit;
- lines[indentationEdit.line] =
- " ".repeat(newLeadingSpaces) +
- lines[indentationEdit.line].trimStart();
+ // Ensure the line number is within the range
+ if (line >= 0 && line < lines.length) {
+ const currentLine = lines[line];
+ // Count current leading spaces
+ const currentLeadingSpaces =
+ RegExp(/^\s*/).exec(currentLine)?.[0].length || 0;
+ // Calculate new indentation
+ const newLeadingSpaces = Math.max(
+ 0,
+ currentLeadingSpaces + lineChangeDelta
+ );
+
+ // Update the line with the new indentation
+
+ lines[line] =
+ " ".repeat(newLeadingSpaces) + currentLine.trimStart();
+ }
+ });
+
+ // Join the lines back into a single string
return lines.join(fullText.eolDelimiter);
}
+
+ //refactor
+ private getParentIndentationSourceNode(node: SyntaxNode): SyntaxNode {
+ if (
+ node.type === SyntaxNodeType.DoBlock &&
+ node.parent?.type === SyntaxNodeType.IfStatement
+ ) {
+ return node.parent;
+ } else if (
+ node.type === SyntaxNodeType.DoBlock &&
+ (node.parent?.type === SyntaxNodeType.CaseWhenBranch ||
+ node.parent?.type === SyntaxNodeType.CaseOtherwiseBranch)
+ ) {
+ return node.parent;
+ } else if (
+ node.type === SyntaxNodeType.DoBlock &&
+ (node.parent?.type === SyntaxNodeType.ElseIfStatement ||
+ node.parent?.type === SyntaxNodeType.ElseStatement)
+ ) {
+ if (node.parent.parent === null) {
+ return node.parent;
+ }
+
+ return node.parent.parent;
+ }
+ return node;
+ }
}
interface IndentationEdits {
From cbecc7068b23a6e8c44289ec89d2e936c351d6b4 Mon Sep 17 00:00:00 2001
From: gmickus
Date: Mon, 9 Sep 2024 12:46:08 +0300
Subject: [PATCH 14/79] Remove comments ; update package.json
---
package.json | 2 +-
.../emptyblock/EmptyBlockFormatter.ts | 24 -------------------
2 files changed, 1 insertion(+), 25 deletions(-)
diff --git a/package.json b/package.json
index ffa4d8e7..f904192a 100644
--- a/package.json
+++ b/package.json
@@ -201,7 +201,7 @@
"AblFormatter.ifFunctionFormattingAddParentheses": {
"order": 1201,
"type": "string",
- "default": "Yes",
+ "default": "No",
"enum": [
"Yes",
"No"
diff --git a/src/v2/formatters/emptyblock/EmptyBlockFormatter.ts b/src/v2/formatters/emptyblock/EmptyBlockFormatter.ts
index 898bab4d..b134dcc2 100644
--- a/src/v2/formatters/emptyblock/EmptyBlockFormatter.ts
+++ b/src/v2/formatters/emptyblock/EmptyBlockFormatter.ts
@@ -80,10 +80,6 @@ export class EmptyBlockFormatter extends AFormatter implements IFormatter {
)
);
- console.log(
- "Body text:\n " + FormatterHelper.getBodyText(node, fullText)
- );
- console.log("blockStatement:\n" + blockStatementsStartRows);
const codeLines = FormatterHelper.getBodyText(node, fullText).split(
fullText.eolDelimiter
);
@@ -92,7 +88,6 @@ export class EmptyBlockFormatter extends AFormatter implements IFormatter {
let lineChangeDelta = 0;
codeLines.forEach((codeLine, index) => {
const lineNumber = node.startPosition.row + index;
- console.log("line nr " + lineNumber + " :\n" + codeLine);
// adjust delta
if (blockStatementsStartRows[n] === lineNumber) {
@@ -104,23 +99,9 @@ export class EmptyBlockFormatter extends AFormatter implements IFormatter {
fullText
);
- console.log(
- "ind: " +
- parentIndentation +
- " " +
- indentationStep +
- " " +
- FormatterHelper.getActualTextIndentation(
- codeLine,
- fullText
- )
- );
-
n++;
}
- console.log("myDelta: " + lineChangeDelta);
-
if (lineChangeDelta !== 0) {
indentationEdits.push({
line: index,
@@ -147,8 +128,6 @@ export class EmptyBlockFormatter extends AFormatter implements IFormatter {
fullText
);
- console.log("endDelta: " + endRowDelta);
-
if (endRowDelta !== 0) {
indentationEdits.push({
line: parent.endPosition.row - parent.startPosition.row,
@@ -177,9 +156,6 @@ export class EmptyBlockFormatter extends AFormatter implements IFormatter {
fullText
);
- console.log("oldText:\n" + text);
- console.log("text:\n" + newText);
-
return this.getCodeEdit(node, text, newText, fullText);
}
From fe4f6ac231f314313780eb3af2c4ba4d1afc4ed9 Mon Sep 17 00:00:00 2001
From: gmickus
Date: Mon, 9 Sep 2024 14:27:57 +0300
Subject: [PATCH 15/79] Improve for formatting
---
.../functionalTests/for/3each-each/input.p | 2 +-
.../ifFunction/10else-new-line-in-for/input.p | 1 +
.../10else-new-line-in-for/target.p | 9 +-
.../ifFunction/11else-new-line-in-for/input.p | 2 +-
.../11else-new-line-in-for/target.p | 20 ++--
.../ifFunction/12else-new-line-in-for/input.p | 16 ++++
.../12else-new-line-in-for/target.p | 18 ++++
.../target.p | 8 +-
src/model/SyntaxNodeType.ts | 2 +
src/v2/formatters/for/ForFormatter.ts | 93 ++++++++++++++++++-
10 files changed, 149 insertions(+), 22 deletions(-)
create mode 100644 resources/functionalTests/ifFunction/12else-new-line-in-for/input.p
create mode 100644 resources/functionalTests/ifFunction/12else-new-line-in-for/target.p
diff --git a/resources/functionalTests/for/3each-each/input.p b/resources/functionalTests/for/3each-each/input.p
index fe21641b..b16ddb77 100644
--- a/resources/functionalTests/for/3each-each/input.p
+++ b/resources/functionalTests/for/3each-each/input.p
@@ -4,5 +4,5 @@
"abl.completion.upperCase": true}*/
FOR EACH Customer NO-LOCK, EACH Order OF Customer NO-LOCK, EACH OrderLine OF Order NO-LOCK BY Order.PromiseDate BY Customer.CustNum BY OrderLine.LineNum:
- DISPLAY Order.PromiseDate.
+DISPLAY Order.PromiseDate.
END.
\ No newline at end of file
diff --git a/resources/functionalTests/ifFunction/10else-new-line-in-for/input.p b/resources/functionalTests/ifFunction/10else-new-line-in-for/input.p
index 1a825bbd..0642d9cc 100644
--- a/resources/functionalTests/ifFunction/10else-new-line-in-for/input.p
+++ b/resources/functionalTests/ifFunction/10else-new-line-in-for/input.p
@@ -1,5 +1,6 @@
/* formatterSettingsOverride */
/* { "AblFormatter.ifFunctionFormatting": true,
+ "AblFormatter.forFormatting": true,
"AblFormatter.ifFunctionFormattingAddParentheses": "No",
"AblFormatter.ifFunctionFormattingElseLocation": "New"}*/
diff --git a/resources/functionalTests/ifFunction/10else-new-line-in-for/target.p b/resources/functionalTests/ifFunction/10else-new-line-in-for/target.p
index 2830c709..a617cd75 100644
--- a/resources/functionalTests/ifFunction/10else-new-line-in-for/target.p
+++ b/resources/functionalTests/ifFunction/10else-new-line-in-for/target.p
@@ -1,10 +1,13 @@
/* formatterSettingsOverride */
/* { "AblFormatter.ifFunctionFormatting": true,
+ "AblFormatter.forFormatting": true,
"AblFormatter.ifFunctionFormattingAddParentheses": "No",
"AblFormatter.ifFunctionFormattingElseLocation": "New"}*/
-FOR EACH Customer NO-LOCK BY IF Customer.Balance > 10000 THEN 1
- ELSE (IF Customer.Balance > 1000 THEN 2
- ELSE 3) BY Customer.SalesRep:
+FOR EACH Customer NO-LOCK
+ BY IF Customer.Balance > 10000 THEN 1
+ ELSE (IF Customer.Balance > 1000 THEN 2
+ ELSE 3)
+ BY Customer.SalesRep:
DISPLAY Customer.SalesRep Customer.Balance Customer.Name.
END.
\ No newline at end of file
diff --git a/resources/functionalTests/ifFunction/11else-new-line-in-for/input.p b/resources/functionalTests/ifFunction/11else-new-line-in-for/input.p
index 5ed62378..a264da09 100644
--- a/resources/functionalTests/ifFunction/11else-new-line-in-for/input.p
+++ b/resources/functionalTests/ifFunction/11else-new-line-in-for/input.p
@@ -1,6 +1,6 @@
/* formatterSettingsOverride */
/* { "AblFormatter.ifFunctionFormatting": true,
- "AblFormatter.ifFunctionFormattingAddParentheses": "No",
+ "AblFormatter.ifFunctionFormattingAddParentheses": "Yes",
"AblFormatter.ifFunctionFormattingElseLocation": "New"}*/
FOR EACH Customer NO-LOCK
diff --git a/resources/functionalTests/ifFunction/11else-new-line-in-for/target.p b/resources/functionalTests/ifFunction/11else-new-line-in-for/target.p
index c64cd6c9..0e156bf1 100644
--- a/resources/functionalTests/ifFunction/11else-new-line-in-for/target.p
+++ b/resources/functionalTests/ifFunction/11else-new-line-in-for/target.p
@@ -1,18 +1,18 @@
/* formatterSettingsOverride */
/* { "AblFormatter.ifFunctionFormatting": true,
- "AblFormatter.ifFunctionFormattingAddParentheses": "No",
+ "AblFormatter.ifFunctionFormattingAddParentheses": "Yes",
"AblFormatter.ifFunctionFormattingElseLocation": "New"}*/
FOR EACH Customer NO-LOCK
- BY IF Customer.Balance > 10000 THEN 1
- ELSE IF Customer.Balance > 5000 THEN 1.5
- ELSE IF Customer.Balance > 1000 THEN 2
- ELSE IF Customer.Balance > 500 THEN 2.5
- ELSE 3
- BY IF Customer.SalesRep = "John" THEN 1
- ELSE IF Customer.SalesRep = "Jane" THEN 2
- ELSE IF Customer.SalesRep = "Doe" THEN 3
- ELSE 4:
+ BY (IF Customer.Balance > 10000 THEN 1
+ ELSE (IF Customer.Balance > 5000 THEN 1.5
+ ELSE (IF Customer.Balance > 1000 THEN 2
+ ELSE (IF Customer.Balance > 500 THEN 2.5
+ ELSE 3))))
+ BY (IF Customer.SalesRep = "John" THEN 1
+ ELSE (IF Customer.SalesRep = "Jane" THEN 2
+ ELSE (IF Customer.SalesRep = "Doe" THEN 3
+ ELSE 4))):
DISPLAY Customer.SalesRep Customer.Balance Customer.Name.
END.
\ No newline at end of file
diff --git a/resources/functionalTests/ifFunction/12else-new-line-in-for/input.p b/resources/functionalTests/ifFunction/12else-new-line-in-for/input.p
new file mode 100644
index 00000000..a9cdd45b
--- /dev/null
+++ b/resources/functionalTests/ifFunction/12else-new-line-in-for/input.p
@@ -0,0 +1,16 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.ifFunctionFormatting": true,
+ "AblFormatter.ifFunctionFormattingAddParentheses": "No",
+ "AblFormatter.ifFunctionFormattingElseLocation": "New"}*/
+
+FOR EACH Customer
+BY IF Customer.Balance > 10000 THEN 1 ELSE
+ IF Customer.Balance > 5000 THEN 1.5 ELSE
+ IF Customer.Balance > 1000 THEN 2 ELSE
+ IF Customer.Balance > 500 THEN 2.5 ELSE 3
+ BY IF Customer.SalesRep = "John" THEN 1 ELSE
+ IF Customer.SalesRep = "Jane" THEN 2 ELSE
+ IF Customer.SalesRep = "Doe" THEN 3 ELSE 4 NO-LOCK:
+ DISPLAY Customer.SalesRep Customer.Balance Customer.Name.
+ END.
+
\ No newline at end of file
diff --git a/resources/functionalTests/ifFunction/12else-new-line-in-for/target.p b/resources/functionalTests/ifFunction/12else-new-line-in-for/target.p
new file mode 100644
index 00000000..8874b169
--- /dev/null
+++ b/resources/functionalTests/ifFunction/12else-new-line-in-for/target.p
@@ -0,0 +1,18 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.ifFunctionFormatting": true,
+ "AblFormatter.ifFunctionFormattingAddParentheses": "No",
+ "AblFormatter.ifFunctionFormattingElseLocation": "New"}*/
+
+FOR EACH Customer
+ BY IF Customer.Balance > 10000 THEN 1
+ ELSE IF Customer.Balance > 5000 THEN 1.5
+ ELSE IF Customer.Balance > 1000 THEN 2
+ ELSE IF Customer.Balance > 500 THEN 2.5
+ ELSE 3
+ BY IF Customer.SalesRep = "John" THEN 1
+ ELSE IF Customer.SalesRep = "Jane" THEN 2
+ ELSE IF Customer.SalesRep = "Doe" THEN 3
+ ELSE 4 NO-LOCK:
+ DISPLAY Customer.SalesRep Customer.Balance Customer.Name.
+END.
+
\ No newline at end of file
diff --git a/resources/functionalTests/ifFunction/7parentheses-else-new-line-in-for/target.p b/resources/functionalTests/ifFunction/7parentheses-else-new-line-in-for/target.p
index 44acdd9c..c3afc5d4 100644
--- a/resources/functionalTests/ifFunction/7parentheses-else-new-line-in-for/target.p
+++ b/resources/functionalTests/ifFunction/7parentheses-else-new-line-in-for/target.p
@@ -3,8 +3,10 @@
"AblFormatter.ifFunctionFormattingAddParentheses": "Yes",
"AblFormatter.ifFunctionFormattingElseLocation": "New"}*/
-FOR EACH Customer NO-LOCK BY (IF Customer.Balance > 10000 THEN 1
- ELSE (IF Customer.Balance > 1000 THEN 2
- ELSE 3)) BY Customer.SalesRep:
+FOR EACH Customer NO-LOCK
+ BY (IF Customer.Balance > 10000 THEN 1
+ ELSE (IF Customer.Balance > 1000 THEN 2
+ ELSE 3))
+ BY Customer.SalesRep:
DISPLAY Customer.SalesRep Customer.Balance Customer.Name.
END.
\ No newline at end of file
diff --git a/src/model/SyntaxNodeType.ts b/src/model/SyntaxNodeType.ts
index d9bce303..c67cd04e 100644
--- a/src/model/SyntaxNodeType.ts
+++ b/src/model/SyntaxNodeType.ts
@@ -37,6 +37,7 @@ export enum SyntaxNodeType {
ForStatement = "for_statement",
QueryTuning = "query_tuning",
SortClause = "sort_clause",
+ SortColumn = "sort_column",
ComparisonExpression = "comparison_expression",
TernaryExpression = "ternary_expression",
ParenthesizedExpression = "parenthesized_expression",
@@ -59,6 +60,7 @@ export enum SyntaxNodeType {
// keywords
WhenKeyword = "WHEN",
+ ByKeyword = "BY",
ThenKeyword = "THEN",
ElseKeyword = "ELSE",
AndKeyword = "AND",
diff --git a/src/v2/formatters/for/ForFormatter.ts b/src/v2/formatters/for/ForFormatter.ts
index 7df95056..d50efe2b 100644
--- a/src/v2/formatters/for/ForFormatter.ts
+++ b/src/v2/formatters/for/ForFormatter.ts
@@ -111,8 +111,8 @@ export class ForFormatter extends AFormatter implements IFormatter {
case SyntaxNodeType.SortClause:
newString =
fullText.eolDelimiter +
- " ".repeat(alignColumn + 1) +
- FormatterHelper.getCurrentText(node, fullText).trim();
+ " ".repeat(alignColumn) +
+ this.getSortClauseText(node, fullText, alignColumn);
break;
case SyntaxNodeType.ForPhrase:
newString = this.getSortClauseBlock(
@@ -171,6 +171,91 @@ export class ForFormatter extends AFormatter implements IFormatter {
return resultString;
}
+ private getSortClauseText(
+ node: SyntaxNode,
+ fullText: Readonly,
+ alignColumn: number
+ ): string {
+ let resultString = "";
+
+ node.children.forEach((child) => {
+ resultString = resultString.concat(
+ this.getSortClauseChildText(child, fullText, alignColumn)
+ );
+ });
+
+ console.log("sortClauseText:\n" + resultString);
+ console.log(
+ "sortClauseNode:\n" + FormatterHelper.getCurrentText(node, fullText)
+ );
+ return resultString;
+ }
+
+ private getSortClauseChildText(
+ node: SyntaxNode,
+ fullText: Readonly,
+ alignColumn: number
+ ): string {
+ let newString = "";
+
+ switch (node.type) {
+ case SyntaxNodeType.SortColumn:
+ newString = "";
+ node.children.forEach((child) => {
+ newString = newString.concat(
+ this.getSortColumnChildText(
+ child,
+ fullText,
+ alignColumn
+ )
+ );
+ });
+ break;
+ default:
+ const text = FormatterHelper.getCurrentText(
+ node,
+ fullText
+ ).trim();
+ newString = text.length === 0 ? "" : " " + text;
+ break;
+ }
+
+ console.log("sortClauseType:\n" + node.type);
+ console.log("sortClausePart:\n" + newString);
+ return newString;
+ }
+
+ private getSortColumnChildText(
+ node: SyntaxNode,
+ fullText: Readonly,
+ alignColumn: number
+ ): string {
+ let newString = "";
+
+ switch (node.type) {
+ case SyntaxNodeType.TernaryExpression:
+ newString =
+ " " +
+ FormatterHelper.addIndentation(
+ FormatterHelper.getCurrentText(node, fullText).trim(),
+ -node.startPosition.column + alignColumn + 3, // this assumes that if the sort column contains a ternary expression, then it does not contain anything else
+ fullText.eolDelimiter
+ ).trim();
+ break;
+ default:
+ const text = FormatterHelper.getCurrentText(
+ node,
+ fullText
+ ).trim();
+ newString = text.length === 0 ? "" : " " + text;
+ break;
+ }
+
+ console.log("sortColumnType:\n" + node.type);
+ console.log("sortColumnPart:\n" + newString);
+ return newString;
+ }
+
private getSortClauseBlock(
node: SyntaxNode,
fullText: Readonly,
@@ -190,8 +275,8 @@ export class ForFormatter extends AFormatter implements IFormatter {
case SyntaxNodeType.SortClause:
resultString = resultString.concat(
fullText.eolDelimiter,
- " ".repeat(alignColumn + 1),
- FormatterHelper.getCurrentText(child, fullText).trim()
+ " ".repeat(alignColumn),
+ this.getSortClauseText(child, fullText, alignColumn)
);
break;
default:
From 92baa5a56855e98dd3c1443b29933b6b66ac8004 Mon Sep 17 00:00:00 2001
From: gmickus
Date: Mon, 9 Sep 2024 17:04:34 +0300
Subject: [PATCH 16/79] Refactor empty block formatter to body formatter
---
package.json | 4 ++--
.../block/12for-block-end2-disabled/input.p | 2 +-
.../block/12for-block-end2-disabled/target.p | 2 +-
.../block/15for-block-inner2-disabled/input.p | 2 +-
.../15for-block-inner2-disabled/target.p | 2 +-
.../block/17for-block-inner4-disabled/input.p | 2 +-
.../17for-block-inner4-disabled/target.p | 2 +-
.../emptyBlock/10finally/input.p | 2 +-
.../emptyBlock/10finally/target.p | 2 +-
.../emptyBlock/12function/input.p | 2 +-
.../emptyBlock/12function/target.p | 2 +-
.../emptyBlock/13method/input.p | 2 +-
.../emptyBlock/13method/target.p | 2 +-
.../emptyBlock/14on_do/input.p | 2 +-
.../emptyBlock/14on_do/target.p | 2 +-
.../functionalTests/emptyBlock/15on1/input.p | 2 +-
.../functionalTests/emptyBlock/15on1/target.p | 2 +-
.../emptyBlock/16procedure/input.p | 2 +-
.../emptyBlock/16procedure/target.p | 2 +-
.../emptyBlock/17repeat/input.p | 2 +-
.../emptyBlock/17repeat/target.p | 2 +-
.../functionalTests/emptyBlock/1catch/input.p | 2 +-
.../emptyBlock/1catch/target.p | 2 +-
.../functionalTests/emptyBlock/2class/input.p | 2 +-
.../emptyBlock/2class/target.p | 2 +-
.../emptyBlock/3constructor/input.p | 2 +-
.../emptyBlock/3constructor/target.p | 2 +-
.../emptyBlock/4destructor/input.p | 2 +-
.../emptyBlock/4destructor/target.p | 2 +-
.../functionalTests/emptyBlock/5do/input.p | 2 +-
.../functionalTests/emptyBlock/5do/target.p | 2 +-
.../functionalTests/emptyBlock/6do_on/input.p | 2 +-
.../emptyBlock/6do_on/target.p | 2 +-
.../functionalTests/emptyBlock/7do_to/input.p | 2 +-
.../emptyBlock/7do_to/target.p | 2 +-
.../emptyBlock/8do_transaction/input.p | 2 +-
.../emptyBlock/8do_transaction/target.p | 2 +-
.../emptyBlock/9do_while/input.p | 2 +-
.../emptyBlock/9do_while/target.p | 2 +-
.../functionalTests/for/3each-where/input.p | 4 +---
.../functionalTests/for/3each-where/target.p | 4 +---
.../functionalTests/for/3first-by/input.p | 4 +---
.../functionalTests/for/3first-by/target.p | 4 +---
.../for/5each-break-by/input.p | 6 ++++++
.../for/5each-break-by/target.p | 8 ++++++++
.../functionalTests/for/6each-nested/input.p | 15 ++++++++++++++
.../functionalTests/for/6each-nested/target.p | 18 +++++++++++++++++
.../functionalTests/for/7each-complex/input.p | 20 +++++++++++++++++++
.../for/7each-complex/target.p | 20 +++++++++++++++++++
.../enableFormatterDecorators.ts | 4 ++--
.../BodyFormatter.ts} | 10 +++++-----
src/v2/formatters/body/BodySettings.ts | 8 ++++++++
.../emptyblock/EmptyBlockSettings.ts | 8 --------
src/v2/formatters/for/ForFormatter.ts | 12 -----------
54 files changed, 146 insertions(+), 79 deletions(-)
create mode 100644 resources/functionalTests/for/5each-break-by/input.p
create mode 100644 resources/functionalTests/for/5each-break-by/target.p
create mode 100644 resources/functionalTests/for/6each-nested/input.p
create mode 100644 resources/functionalTests/for/6each-nested/target.p
create mode 100644 resources/functionalTests/for/7each-complex/input.p
create mode 100644 resources/functionalTests/for/7each-complex/target.p
rename src/v2/formatters/{emptyblock/EmptyBlockFormatter.ts => body/BodyFormatter.ts} (92%)
create mode 100644 src/v2/formatters/body/BodySettings.ts
delete mode 100644 src/v2/formatters/emptyblock/EmptyBlockSettings.ts
diff --git a/package.json b/package.json
index f904192a..e4a5f508 100644
--- a/package.json
+++ b/package.json
@@ -180,11 +180,11 @@
"default": "true",
"description": "Enable USING formatting"
},
- "AblFormatter.emptyBlockFormatting": {
+ "AblFormatter.bodyFormatting": {
"order": 1000,
"type": "boolean",
"default": "true",
- "description": "Enable EMPTY BLOCK formatting"
+ "description": "Enable BODY formatting"
},
"AblFormatter.propertyFormatting": {
"order": 1100,
diff --git a/resources/functionalTests/block/12for-block-end2-disabled/input.p b/resources/functionalTests/block/12for-block-end2-disabled/input.p
index fb0925bc..37f0082c 100644
--- a/resources/functionalTests/block/12for-block-end2-disabled/input.p
+++ b/resources/functionalTests/block/12for-block-end2-disabled/input.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.emptyBlockFormatting": false,
+/* { "AblFormatter.bodyFormatting": false,
"AblFormatter.forFormatting": false}*/
for each Customer no-lock:
diff --git a/resources/functionalTests/block/12for-block-end2-disabled/target.p b/resources/functionalTests/block/12for-block-end2-disabled/target.p
index fb0925bc..37f0082c 100644
--- a/resources/functionalTests/block/12for-block-end2-disabled/target.p
+++ b/resources/functionalTests/block/12for-block-end2-disabled/target.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.emptyBlockFormatting": false,
+/* { "AblFormatter.bodyFormatting": false,
"AblFormatter.forFormatting": false}*/
for each Customer no-lock:
diff --git a/resources/functionalTests/block/15for-block-inner2-disabled/input.p b/resources/functionalTests/block/15for-block-inner2-disabled/input.p
index 70700ee9..cc20aadb 100644
--- a/resources/functionalTests/block/15for-block-inner2-disabled/input.p
+++ b/resources/functionalTests/block/15for-block-inner2-disabled/input.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.emptyBlockFormatting": false,
+/* { "AblFormatter.bodyFormatting": false,
"AblFormatter.forFormatting": false}*/
for each Customer no-lock:
diff --git a/resources/functionalTests/block/15for-block-inner2-disabled/target.p b/resources/functionalTests/block/15for-block-inner2-disabled/target.p
index 70700ee9..cc20aadb 100644
--- a/resources/functionalTests/block/15for-block-inner2-disabled/target.p
+++ b/resources/functionalTests/block/15for-block-inner2-disabled/target.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.emptyBlockFormatting": false,
+/* { "AblFormatter.bodyFormatting": false,
"AblFormatter.forFormatting": false}*/
for each Customer no-lock:
diff --git a/resources/functionalTests/block/17for-block-inner4-disabled/input.p b/resources/functionalTests/block/17for-block-inner4-disabled/input.p
index d0e8b53a..28b0aeed 100644
--- a/resources/functionalTests/block/17for-block-inner4-disabled/input.p
+++ b/resources/functionalTests/block/17for-block-inner4-disabled/input.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.emptyBlockFormatting": false,
+/* { "AblFormatter.bodyFormatting": false,
"AblFormatter.forFormatting": false}*/
for each Customer no-lock:
diff --git a/resources/functionalTests/block/17for-block-inner4-disabled/target.p b/resources/functionalTests/block/17for-block-inner4-disabled/target.p
index d0e8b53a..28b0aeed 100644
--- a/resources/functionalTests/block/17for-block-inner4-disabled/target.p
+++ b/resources/functionalTests/block/17for-block-inner4-disabled/target.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.emptyBlockFormatting": false,
+/* { "AblFormatter.bodyFormatting": false,
"AblFormatter.forFormatting": false}*/
for each Customer no-lock:
diff --git a/resources/functionalTests/emptyBlock/10finally/input.p b/resources/functionalTests/emptyBlock/10finally/input.p
index 64c14495..325f8718 100644
--- a/resources/functionalTests/emptyBlock/10finally/input.p
+++ b/resources/functionalTests/emptyBlock/10finally/input.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.emptyBlockFormatting": true}*/
+/* { "AblFormatter.blockFormatting": true}*/
finally:
end finally.
\ No newline at end of file
diff --git a/resources/functionalTests/emptyBlock/10finally/target.p b/resources/functionalTests/emptyBlock/10finally/target.p
index c7ec4594..2e4fe78e 100644
--- a/resources/functionalTests/emptyBlock/10finally/target.p
+++ b/resources/functionalTests/emptyBlock/10finally/target.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.emptyBlockFormatting": true}*/
+/* { "AblFormatter.blockFormatting": true}*/
finally:
end finally.
\ No newline at end of file
diff --git a/resources/functionalTests/emptyBlock/12function/input.p b/resources/functionalTests/emptyBlock/12function/input.p
index 2ffe1fd1..f00916fa 100644
--- a/resources/functionalTests/emptyBlock/12function/input.p
+++ b/resources/functionalTests/emptyBlock/12function/input.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.emptyBlockFormatting": true}*/
+/* { "AblFormatter.blockFormatting": true}*/
function fun returns integer ():
diff --git a/resources/functionalTests/emptyBlock/12function/target.p b/resources/functionalTests/emptyBlock/12function/target.p
index 499c361e..604749c4 100644
--- a/resources/functionalTests/emptyBlock/12function/target.p
+++ b/resources/functionalTests/emptyBlock/12function/target.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.emptyBlockFormatting": true}*/
+/* { "AblFormatter.blockFormatting": true}*/
function fun returns integer ():
diff --git a/resources/functionalTests/emptyBlock/13method/input.p b/resources/functionalTests/emptyBlock/13method/input.p
index 90f78bde..220ad1a3 100644
--- a/resources/functionalTests/emptyBlock/13method/input.p
+++ b/resources/functionalTests/emptyBlock/13method/input.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.emptyBlockFormatting": true}*/
+/* { "AblFormatter.blockFormatting": true}*/
class Class final:
method public void mt():
diff --git a/resources/functionalTests/emptyBlock/13method/target.p b/resources/functionalTests/emptyBlock/13method/target.p
index 7f8170ce..35f1604f 100644
--- a/resources/functionalTests/emptyBlock/13method/target.p
+++ b/resources/functionalTests/emptyBlock/13method/target.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.emptyBlockFormatting": true}*/
+/* { "AblFormatter.blockFormatting": true}*/
class Class final:
method public void mt():
diff --git a/resources/functionalTests/emptyBlock/14on_do/input.p b/resources/functionalTests/emptyBlock/14on_do/input.p
index ba76ea1f..50709d3e 100644
--- a/resources/functionalTests/emptyBlock/14on_do/input.p
+++ b/resources/functionalTests/emptyBlock/14on_do/input.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.emptyBlockFormatting": true}*/
+/* { "AblFormatter.blockFormatting": true}*/
on choose of b_next, b_prev do:
end.
\ No newline at end of file
diff --git a/resources/functionalTests/emptyBlock/14on_do/target.p b/resources/functionalTests/emptyBlock/14on_do/target.p
index 218d2f00..b59acec2 100644
--- a/resources/functionalTests/emptyBlock/14on_do/target.p
+++ b/resources/functionalTests/emptyBlock/14on_do/target.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.emptyBlockFormatting": true}*/
+/* { "AblFormatter.blockFormatting": true}*/
on choose of b_next, b_prev do:
end.
\ No newline at end of file
diff --git a/resources/functionalTests/emptyBlock/15on1/input.p b/resources/functionalTests/emptyBlock/15on1/input.p
index d111088b..84fd9cff 100644
--- a/resources/functionalTests/emptyBlock/15on1/input.p
+++ b/resources/functionalTests/emptyBlock/15on1/input.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.emptyBlockFormatting": true}*/
+/* { "AblFormatter.blockFormatting": true}*/
ON F1 GO. /* F1 will now perform the GO function */
ON F2 HELP. /* F2 will now perform the HELP function */
diff --git a/resources/functionalTests/emptyBlock/15on1/target.p b/resources/functionalTests/emptyBlock/15on1/target.p
index d111088b..84fd9cff 100644
--- a/resources/functionalTests/emptyBlock/15on1/target.p
+++ b/resources/functionalTests/emptyBlock/15on1/target.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.emptyBlockFormatting": true}*/
+/* { "AblFormatter.blockFormatting": true}*/
ON F1 GO. /* F1 will now perform the GO function */
ON F2 HELP. /* F2 will now perform the HELP function */
diff --git a/resources/functionalTests/emptyBlock/16procedure/input.p b/resources/functionalTests/emptyBlock/16procedure/input.p
index 5cd9706d..6da2b3a9 100644
--- a/resources/functionalTests/emptyBlock/16procedure/input.p
+++ b/resources/functionalTests/emptyBlock/16procedure/input.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.emptyBlockFormatting": true}*/
+/* { "AblFormatter.blockFormatting": true}*/
procedure proc:
end procedure.
\ No newline at end of file
diff --git a/resources/functionalTests/emptyBlock/16procedure/target.p b/resources/functionalTests/emptyBlock/16procedure/target.p
index ccf684db..f7f199e3 100644
--- a/resources/functionalTests/emptyBlock/16procedure/target.p
+++ b/resources/functionalTests/emptyBlock/16procedure/target.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.emptyBlockFormatting": true}*/
+/* { "AblFormatter.blockFormatting": true}*/
procedure proc:
end procedure.
\ No newline at end of file
diff --git a/resources/functionalTests/emptyBlock/17repeat/input.p b/resources/functionalTests/emptyBlock/17repeat/input.p
index 0fa97683..dc8e954a 100644
--- a/resources/functionalTests/emptyBlock/17repeat/input.p
+++ b/resources/functionalTests/emptyBlock/17repeat/input.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.emptyBlockFormatting": true}*/
+/* { "AblFormatter.blockFormatting": true}*/
repeat:
end.
\ No newline at end of file
diff --git a/resources/functionalTests/emptyBlock/17repeat/target.p b/resources/functionalTests/emptyBlock/17repeat/target.p
index 4bdeeea2..fdd94d5c 100644
--- a/resources/functionalTests/emptyBlock/17repeat/target.p
+++ b/resources/functionalTests/emptyBlock/17repeat/target.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.emptyBlockFormatting": true}*/
+/* { "AblFormatter.blockFormatting": true}*/
repeat:
end.
\ No newline at end of file
diff --git a/resources/functionalTests/emptyBlock/1catch/input.p b/resources/functionalTests/emptyBlock/1catch/input.p
index f091a4bf..13fce1ce 100644
--- a/resources/functionalTests/emptyBlock/1catch/input.p
+++ b/resources/functionalTests/emptyBlock/1catch/input.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.emptyBlockFormatting": true}*/
+/* { "AblFormatter.blockFormatting": true}*/
catch oErr as MyErrorType:
end catch.
\ No newline at end of file
diff --git a/resources/functionalTests/emptyBlock/1catch/target.p b/resources/functionalTests/emptyBlock/1catch/target.p
index 7e7fe38e..547d1ac9 100644
--- a/resources/functionalTests/emptyBlock/1catch/target.p
+++ b/resources/functionalTests/emptyBlock/1catch/target.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.emptyBlockFormatting": true}*/
+/* { "AblFormatter.blockFormatting": true}*/
catch oErr as MyErrorType:
end catch.
\ No newline at end of file
diff --git a/resources/functionalTests/emptyBlock/2class/input.p b/resources/functionalTests/emptyBlock/2class/input.p
index 4088a4f4..760088cc 100644
--- a/resources/functionalTests/emptyBlock/2class/input.p
+++ b/resources/functionalTests/emptyBlock/2class/input.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.emptyBlockFormatting": true}*/
+/* { "AblFormatter.blockFormatting": true}*/
class A inherits B:
end class.
\ No newline at end of file
diff --git a/resources/functionalTests/emptyBlock/2class/target.p b/resources/functionalTests/emptyBlock/2class/target.p
index 5ca6f69a..a8a4fa65 100644
--- a/resources/functionalTests/emptyBlock/2class/target.p
+++ b/resources/functionalTests/emptyBlock/2class/target.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.emptyBlockFormatting": true}*/
+/* { "AblFormatter.blockFormatting": true}*/
class A inherits B:
end class.
\ No newline at end of file
diff --git a/resources/functionalTests/emptyBlock/3constructor/input.p b/resources/functionalTests/emptyBlock/3constructor/input.p
index a74777cd..bf298b2d 100644
--- a/resources/functionalTests/emptyBlock/3constructor/input.p
+++ b/resources/functionalTests/emptyBlock/3constructor/input.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.emptyBlockFormatting": true}*/
+/* { "AblFormatter.blockFormatting": true}*/
class A inherits B:
constructor private A():
diff --git a/resources/functionalTests/emptyBlock/3constructor/target.p b/resources/functionalTests/emptyBlock/3constructor/target.p
index b91843f5..b1217a06 100644
--- a/resources/functionalTests/emptyBlock/3constructor/target.p
+++ b/resources/functionalTests/emptyBlock/3constructor/target.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.emptyBlockFormatting": true}*/
+/* { "AblFormatter.blockFormatting": true}*/
class A inherits B:
constructor private A():
diff --git a/resources/functionalTests/emptyBlock/4destructor/input.p b/resources/functionalTests/emptyBlock/4destructor/input.p
index a0af7910..1f94d8ed 100644
--- a/resources/functionalTests/emptyBlock/4destructor/input.p
+++ b/resources/functionalTests/emptyBlock/4destructor/input.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.emptyBlockFormatting": true}*/
+/* { "AblFormatter.blockFormatting": true}*/
class A inherits B:
destructor public A():
diff --git a/resources/functionalTests/emptyBlock/4destructor/target.p b/resources/functionalTests/emptyBlock/4destructor/target.p
index 521236e0..5429d8ee 100644
--- a/resources/functionalTests/emptyBlock/4destructor/target.p
+++ b/resources/functionalTests/emptyBlock/4destructor/target.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.emptyBlockFormatting": true}*/
+/* { "AblFormatter.blockFormatting": true}*/
class A inherits B:
destructor public A():
diff --git a/resources/functionalTests/emptyBlock/5do/input.p b/resources/functionalTests/emptyBlock/5do/input.p
index 51fdf744..1325d311 100644
--- a/resources/functionalTests/emptyBlock/5do/input.p
+++ b/resources/functionalTests/emptyBlock/5do/input.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.emptyBlockFormatting": true}*/
+/* { "AblFormatter.blockFormatting": true}*/
do:
end.
\ No newline at end of file
diff --git a/resources/functionalTests/emptyBlock/5do/target.p b/resources/functionalTests/emptyBlock/5do/target.p
index 513adc04..823c9643 100644
--- a/resources/functionalTests/emptyBlock/5do/target.p
+++ b/resources/functionalTests/emptyBlock/5do/target.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.emptyBlockFormatting": true}*/
+/* { "AblFormatter.blockFormatting": true}*/
do:
end.
\ No newline at end of file
diff --git a/resources/functionalTests/emptyBlock/6do_on/input.p b/resources/functionalTests/emptyBlock/6do_on/input.p
index 969ec08e..f2542a48 100644
--- a/resources/functionalTests/emptyBlock/6do_on/input.p
+++ b/resources/functionalTests/emptyBlock/6do_on/input.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.emptyBlockFormatting": true}*/
+/* { "AblFormatter.blockFormatting": true}*/
do on error undo, throw:
diff --git a/resources/functionalTests/emptyBlock/6do_on/target.p b/resources/functionalTests/emptyBlock/6do_on/target.p
index 177b1b4f..6dc86271 100644
--- a/resources/functionalTests/emptyBlock/6do_on/target.p
+++ b/resources/functionalTests/emptyBlock/6do_on/target.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.emptyBlockFormatting": true}*/
+/* { "AblFormatter.blockFormatting": true}*/
do on error undo, throw:
diff --git a/resources/functionalTests/emptyBlock/7do_to/input.p b/resources/functionalTests/emptyBlock/7do_to/input.p
index b4b5ae72..c6379243 100644
--- a/resources/functionalTests/emptyBlock/7do_to/input.p
+++ b/resources/functionalTests/emptyBlock/7do_to/input.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.emptyBlockFormatting": true}*/
+/* { "AblFormatter.blockFormatting": true}*/
do iCount = iTotal to 5:
end.
\ No newline at end of file
diff --git a/resources/functionalTests/emptyBlock/7do_to/target.p b/resources/functionalTests/emptyBlock/7do_to/target.p
index 835282d2..285b1236 100644
--- a/resources/functionalTests/emptyBlock/7do_to/target.p
+++ b/resources/functionalTests/emptyBlock/7do_to/target.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.emptyBlockFormatting": true}*/
+/* { "AblFormatter.blockFormatting": true}*/
do iCount = iTotal to 5:
end.
\ No newline at end of file
diff --git a/resources/functionalTests/emptyBlock/8do_transaction/input.p b/resources/functionalTests/emptyBlock/8do_transaction/input.p
index e63b26fe..0bc58ece 100644
--- a/resources/functionalTests/emptyBlock/8do_transaction/input.p
+++ b/resources/functionalTests/emptyBlock/8do_transaction/input.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.emptyBlockFormatting": true}*/
+/* { "AblFormatter.blockFormatting": true}*/
do transaction:
end.
\ No newline at end of file
diff --git a/resources/functionalTests/emptyBlock/8do_transaction/target.p b/resources/functionalTests/emptyBlock/8do_transaction/target.p
index 8210da35..84706a53 100644
--- a/resources/functionalTests/emptyBlock/8do_transaction/target.p
+++ b/resources/functionalTests/emptyBlock/8do_transaction/target.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.emptyBlockFormatting": true}*/
+/* { "AblFormatter.blockFormatting": true}*/
do transaction:
end.
\ No newline at end of file
diff --git a/resources/functionalTests/emptyBlock/9do_while/input.p b/resources/functionalTests/emptyBlock/9do_while/input.p
index fef9498b..c3d09d38 100644
--- a/resources/functionalTests/emptyBlock/9do_while/input.p
+++ b/resources/functionalTests/emptyBlock/9do_while/input.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.emptyBlockFormatting": true}*/
+/* { "AblFormatter.blockFormatting": true}*/
do while i < 5:
end.
\ No newline at end of file
diff --git a/resources/functionalTests/emptyBlock/9do_while/target.p b/resources/functionalTests/emptyBlock/9do_while/target.p
index d13a0966..1e328214 100644
--- a/resources/functionalTests/emptyBlock/9do_while/target.p
+++ b/resources/functionalTests/emptyBlock/9do_while/target.p
@@ -1,5 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.emptyBlockFormatting": true}*/
+/* { "AblFormatter.blockFormatting": true}*/
do while i < 5:
end.
\ No newline at end of file
diff --git a/resources/functionalTests/for/3each-where/input.p b/resources/functionalTests/for/3each-where/input.p
index 3ea0e319..7ddeb592 100644
--- a/resources/functionalTests/for/3each-where/input.p
+++ b/resources/functionalTests/for/3each-where/input.p
@@ -1,7 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.blockFormatting": true,
-"AblFormatter.forFormatting": true
-}*/
+/* { "AblFormatter.forFormatting": true}*/
for each Customer where
Customer.var = 1:
diff --git a/resources/functionalTests/for/3each-where/target.p b/resources/functionalTests/for/3each-where/target.p
index 4ce7747a..e46f0b5f 100644
--- a/resources/functionalTests/for/3each-where/target.p
+++ b/resources/functionalTests/for/3each-where/target.p
@@ -1,7 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.blockFormatting": true,
-"AblFormatter.forFormatting": true
-}*/
+/* { "AblFormatter.forFormatting": true}*/
for each Customer where
Customer.var = 1:
diff --git a/resources/functionalTests/for/3first-by/input.p b/resources/functionalTests/for/3first-by/input.p
index 4a7983aa..06702dee 100644
--- a/resources/functionalTests/for/3first-by/input.p
+++ b/resources/functionalTests/for/3first-by/input.p
@@ -1,7 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.blockFormatting": true,
-"AblFormatter.forFormatting": true
-}*/
+/* { "AblFormatter.forFormatting": true}*/
FOR FIRST Customer NO-LOCK
BY Customer.CreditLimit:
diff --git a/resources/functionalTests/for/3first-by/target.p b/resources/functionalTests/for/3first-by/target.p
index 02ca12ed..4b15a9bb 100644
--- a/resources/functionalTests/for/3first-by/target.p
+++ b/resources/functionalTests/for/3first-by/target.p
@@ -1,7 +1,5 @@
/* formatterSettingsOverride */
-/* { "AblFormatter.blockFormatting": true,
-"AblFormatter.forFormatting": true
-}*/
+/* { "AblFormatter.forFormatting": true}*/
FOR FIRST Customer NO-LOCK
BY Customer.CreditLimit:
diff --git a/resources/functionalTests/for/5each-break-by/input.p b/resources/functionalTests/for/5each-break-by/input.p
new file mode 100644
index 00000000..90dbf9bd
--- /dev/null
+++ b/resources/functionalTests/for/5each-break-by/input.p
@@ -0,0 +1,6 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.forFormatting": true}*/
+
+FOR EACH Employee NO-LOCK WHERE Employee.Salary > 50000 BREAK BY Employee.Department:
+ DISPLAY Employee.Department Employee.Name Employee.Salary.
+END.
diff --git a/resources/functionalTests/for/5each-break-by/target.p b/resources/functionalTests/for/5each-break-by/target.p
new file mode 100644
index 00000000..2fcf9b27
--- /dev/null
+++ b/resources/functionalTests/for/5each-break-by/target.p
@@ -0,0 +1,8 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.forFormatting": true}*/
+
+FOR EACH Employee NO-LOCK WHERE
+ Employee.Salary > 50000
+ BREAK BY Employee.Department:
+ DISPLAY Employee.Department Employee.Name Employee.Salary.
+END.
diff --git a/resources/functionalTests/for/6each-nested/input.p b/resources/functionalTests/for/6each-nested/input.p
new file mode 100644
index 00000000..a0d2d32d
--- /dev/null
+++ b/resources/functionalTests/for/6each-nested/input.p
@@ -0,0 +1,15 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.forFormatting": true}*/
+
+FOR EACH Department NO-LOCK:
+ DISPLAY Department.Name.
+
+ FOR EACH Employee NO-LOCK WHERE Employee.Department = Department.DepartmentID BREAK BY Employee.JobTitle:
+ DISPLAY Employee.JobTitle Employee.Name Employee.Salary.
+
+ FOR EACH Project NO-LOCK WHERE Project.EmployeeID = Employee.EmployeeID:
+ DISPLAY Project.ProjectName Project.StartDate Project.EndDate.
+ END.
+ END.
+END.
+
diff --git a/resources/functionalTests/for/6each-nested/target.p b/resources/functionalTests/for/6each-nested/target.p
new file mode 100644
index 00000000..ca266822
--- /dev/null
+++ b/resources/functionalTests/for/6each-nested/target.p
@@ -0,0 +1,18 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.forFormatting": true}*/
+
+FOR EACH Department NO-LOCK:
+ DISPLAY Department.Name.
+
+ FOR EACH Employee NO-LOCK WHERE
+ Employee.Department = Department.DepartmentID
+ BREAK BY Employee.JobTitle:
+ DISPLAY Employee.JobTitle Employee.Name Employee.Salary.
+
+ FOR EACH Project NO-LOCK WHERE
+ Project.EmployeeID = Employee.EmployeeID:
+ DISPLAY Project.ProjectName Project.StartDate Project.EndDate.
+ END.
+ END.
+END.
+
diff --git a/resources/functionalTests/for/7each-complex/input.p b/resources/functionalTests/for/7each-complex/input.p
new file mode 100644
index 00000000..1cacc72a
--- /dev/null
+++ b/resources/functionalTests/for/7each-complex/input.p
@@ -0,0 +1,20 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.forFormatting": true}*/
+
+FOR EACH Customer NO-LOCK
+ WHERE (Customer.Balance > 10000 AND Customer.Region = "North") OR (Customer.Region = "South" AND Customer.Status = "Active")
+ BY Customer.LastName
+ BY Customer.FirstName
+ BREAK BY Customer.City
+ BY Customer.State:
+ DISPLAY Customer.CustomerID
+ Customer.Name
+ Customer.Balance
+ Customer.Region
+ Customer.Status
+ Customer.City
+ Customer.State
+ Customer.LastOrderDate
+ Customer.CreditLimit
+ Customer.SalesRep.
+END.
diff --git a/resources/functionalTests/for/7each-complex/target.p b/resources/functionalTests/for/7each-complex/target.p
new file mode 100644
index 00000000..b296aa14
--- /dev/null
+++ b/resources/functionalTests/for/7each-complex/target.p
@@ -0,0 +1,20 @@
+/* formatterSettingsOverride */
+/* { "AblFormatter.forFormatting": true}*/
+
+FOR EACH Customer NO-LOCK WHERE
+ (Customer.Balance > 10000 AND Customer.Region = "North") OR (Customer.Region = "South" AND Customer.Status = "Active")
+ BY Customer.LastName
+ BY Customer.FirstName
+ BREAK BY Customer.City
+ BY Customer.State:
+ DISPLAY Customer.CustomerID
+ Customer.Name
+ Customer.Balance
+ Customer.Region
+ Customer.Status
+ Customer.City
+ Customer.State
+ Customer.LastOrderDate
+ Customer.CreditLimit
+ Customer.SalesRep.
+END.
diff --git a/src/v2/formatterFramework/enableFormatterDecorators.ts b/src/v2/formatterFramework/enableFormatterDecorators.ts
index 1ef5bd57..65a36d9b 100644
--- a/src/v2/formatterFramework/enableFormatterDecorators.ts
+++ b/src/v2/formatterFramework/enableFormatterDecorators.ts
@@ -6,15 +6,15 @@ import { UsingFormatter } from "../formatters/using/UsingFormatter";
import { CaseFormatter } from "../formatters/case/CaseFormatter";
import { ForFormatter } from "../formatters/for/ForFormatter";
import { IfFunctionFormatter } from "../formatters/ifFunction/IfFunctionFormatter";
-import { EmptyBlockFormatter } from "../formatters/emptyblock/EmptyBlockFormatter";
import { TempTableFormatter } from "../formatters/tempTable/TempTableFormatter";
import { PropertyFormatter } from "../formatters/property/PropertyFormatter";
+import { BodyFormatter } from "../formatters/body/BodyFormatter";
// needed just for enabling decorators. Decorators does not work if there is no usage of a class in the reachable code
export function enableFormatterDecorators(): void {
AssignFormatter;
- EmptyBlockFormatter;
BlockFormater;
+ BodyFormatter;
IfFormatter;
DefineFormatter;
UsingFormatter;
diff --git a/src/v2/formatters/emptyblock/EmptyBlockFormatter.ts b/src/v2/formatters/body/BodyFormatter.ts
similarity index 92%
rename from src/v2/formatters/emptyblock/EmptyBlockFormatter.ts
rename to src/v2/formatters/body/BodyFormatter.ts
index b134dcc2..7a13bc23 100644
--- a/src/v2/formatters/emptyblock/EmptyBlockFormatter.ts
+++ b/src/v2/formatters/body/BodyFormatter.ts
@@ -4,7 +4,7 @@ import { IFormatter } from "../../formatterFramework/IFormatter";
import { CodeEdit } from "../../model/CodeEdit";
import { FullText } from "../../model/FullText";
import { AFormatter } from "../AFormatter";
-import { EmptyBlockSettings } from "./EmptyBlockSettings";
+import { BodySettings } from "./BodySettings";
import { IConfigurationManager } from "../../../utils/IConfigurationManager";
import {
bodyBlockKeywords,
@@ -13,13 +13,13 @@ import {
import { FormatterHelper } from "../../formatterFramework/FormatterHelper";
@RegisterFormatter
-export class EmptyBlockFormatter extends AFormatter implements IFormatter {
- public static readonly formatterLabel = "emptyBlockFormatting";
- private readonly settings: EmptyBlockSettings;
+export class BodyFormatter extends AFormatter implements IFormatter {
+ public static readonly formatterLabel = "bodyFormatting";
+ private readonly settings: BodySettings;
public constructor(configurationManager: IConfigurationManager) {
super(configurationManager);
- this.settings = new EmptyBlockSettings(configurationManager);
+ this.settings = new BodySettings(configurationManager);
}
public match(node: Readonly): boolean {
diff --git a/src/v2/formatters/body/BodySettings.ts b/src/v2/formatters/body/BodySettings.ts
new file mode 100644
index 00000000..4423a0c8
--- /dev/null
+++ b/src/v2/formatters/body/BodySettings.ts
@@ -0,0 +1,8 @@
+import { ASettings } from "../ASettings";
+
+export class BodySettings extends ASettings {
+ //empty block settings
+ public BodyFormatting() {
+ return !!this.configurationManager.get("bodyFormatting");
+ }
+}
diff --git a/src/v2/formatters/emptyblock/EmptyBlockSettings.ts b/src/v2/formatters/emptyblock/EmptyBlockSettings.ts
deleted file mode 100644
index 4d8b3b62..00000000
--- a/src/v2/formatters/emptyblock/EmptyBlockSettings.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import { ASettings } from "../ASettings";
-
-export class EmptyBlockSettings extends ASettings {
- //empty block settings
- public emptyBlockFormatting() {
- return !!this.configurationManager.get("emptyBlockFormatting");
- }
-}
diff --git a/src/v2/formatters/for/ForFormatter.ts b/src/v2/formatters/for/ForFormatter.ts
index d50efe2b..9b5346ab 100644
--- a/src/v2/formatters/for/ForFormatter.ts
+++ b/src/v2/formatters/for/ForFormatter.ts
@@ -66,10 +66,6 @@ export class ForFormatter extends AFormatter implements IFormatter {
if (child.type === SyntaxNodeType.Identifier) {
alignColumn = this.startColumn + resultString.length;
}
- console.log("child: " + child.type);
- console.log(
- "childText: " + FormatterHelper.getCurrentText(child, fullText)
- );
resultString = resultString.concat(
this.getForExpressionString(child, fullText, alignColumn)
);
@@ -184,10 +180,6 @@ export class ForFormatter extends AFormatter implements IFormatter {
);
});
- console.log("sortClauseText:\n" + resultString);
- console.log(
- "sortClauseNode:\n" + FormatterHelper.getCurrentText(node, fullText)
- );
return resultString;
}
@@ -220,8 +212,6 @@ export class ForFormatter extends AFormatter implements IFormatter {
break;
}
- console.log("sortClauseType:\n" + node.type);
- console.log("sortClausePart:\n" + newString);
return newString;
}
@@ -251,8 +241,6 @@ export class ForFormatter extends AFormatter implements IFormatter {
break;
}
- console.log("sortColumnType:\n" + node.type);
- console.log("sortColumnPart:\n" + newString);
return newString;
}
From 66a8369b2a7ecf7123929548da56a5b3ab8cfcc8 Mon Sep 17 00:00:00 2001
From: ekazbaraite
Date: Wed, 11 Sep 2024 09:41:19 +0300
Subject: [PATCH 17/79] Added logo
---
package.json | 1 +
resources/Formatter_LOGO.png | Bin 0 -> 163886 bytes
2 files changed, 1 insertion(+)
create mode 100644 resources/Formatter_LOGO.png
diff --git a/package.json b/package.json
index e5e6d48c..d5f31625 100644
--- a/package.json
+++ b/package.json
@@ -3,6 +3,7 @@
"displayName": "AblFormatter",
"description": "TODO",
"version": "0.0.1",
+ "icon": "resources/Formatter_LOGO.png",
"repository": {},
"engines": {
"vscode": "^1.84.0"
diff --git a/resources/Formatter_LOGO.png b/resources/Formatter_LOGO.png
new file mode 100644
index 0000000000000000000000000000000000000000..95b639792def12930c0cca9ba7283dea827b5112
GIT binary patch
literal 163886
zcmX_nWl$YWur|)YEx0?u-4E^_2<{%7;O_43?gWS6?(XjH4hOfJ_kMN1s@>Y%`Li`s
zJ>8G=gexgXBEjRqgMon|NlS?-gMopA{<{G%|3=1_wj=&Mz#Ww(MZl`32u{JkNWi4U
zgnzo}U39`GQ7*d^J*)cU?+4{%`GLa(3X=&dK}p9Mpcm5o_*QJ}PDwZjq?281#Iz>%
z9BgE$iEX@F+af7AT!|bqW$We0chL>QdjFheQkk
z0D-F9(Oe&GdYyl?o3EZiufKd?AJk%nfDjLW1#+eTUa&s^+}IzO3)uhr_5X*Blc7@g>>~{M$djr9sTV%+M=|f#HEYukCprxpv(>jgB2M
zfSsi0GWu2T^K_!`bbI>E$E(94&}^{TXYF6cFV%5NV|9>l6N1m*-`}%UIJKP3|B>8D
zAojfvJ)o_
zlMmOcuZ*3Bvblp$MbiSbjN#`MVDY($FC}*0^Xw>k-G2b+)RQYgzEXOgpCbrvqph?#
zTUG3~r7}Hw)SOa}@*QDg+1~aWn5UHBJ(ZYWxEr|f%cF}K264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