Skip to content

Commit

Permalink
Update formatting for dataset, dataset-handle
Browse files Browse the repository at this point in the history
  • Loading branch information
gmickus committed Nov 29, 2024
1 parent 5ab2fb6 commit 77786f4
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 45 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/* formatterSettingsOverride */
/* { "AblFormatter.blockFormatting": true}*/

function fun returns integer (input p1 as integer,
input-output p2 as logical,
output p3 as character):
return p1.
function GetDLC returns character
():
define variable cValue as character no-undo.
end function.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* formatterSettingsOverride */
/* { "AblFormatter.blockFormatting": true}*/

function fun returns integer (input p1 as integer,
function fun returns integer (input p1 as integer,
input-output p2 as logical,
output p3 as character):
output p3 as character):
return p1.
end function.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,4 @@ class FunkyWorld.Util.KittyLogHelper:
method private void SnuggleDataset(dataset-handle dsCuddlePuddle bind):
/* PURR */
end method.
end class.


end class.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@
/* { "AblFormatter.functionParameterFormatting": true,
"AblFormatter.functionParameterFormattingAlignParameterTypes": "Yes"}*/

class MyEntityClass:
method public void Fetch(input-output dataset dsMyDataset,
poParameter2 as integer,
piParameterInteger as myParameter):

class FunkyWorld.Util.KittyLogHelper:
method private void SnuggleDataset(dataset-handle dsCuddlePuddle bind):
/* PURR */
end method.
end class.

end class.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"AblFormatter.functionParameterFormattingAlignParameterTypes": "Yes"}*/

class Olympus.Util.HermesHelper:
method public static void ExecuteOracleQuery (pcOracleString as character,
method public static void ExecuteOracleQuery(pcOracleString as character,
pcOlympianFields as character,
piNumProphecies as integer,
output table-handle phOracleTable):
Expand All @@ -13,5 +13,4 @@ class Olympus.Util.HermesHelper:

end method.

end class.

end class.
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ class Olympus.Util.HermesHelper:

end method.

end class.

end class.
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@

function finalShot returns character (input myDribbleShot as character, output tipOffAll as TipOff):

end function.

end function.
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@
function finalShot returns character (input myDribbleShot as character,
output tipOffAll as TipOff):

end function.

end function.
11 changes: 11 additions & 0 deletions src/model/SyntaxNodeType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ export enum SyntaxNodeType {
ReturnKeyword = "RETURN",
ParameterKeyword = "PARAMETER",
VariableKeyword = "VARIABLE",
TableKeyword = "TABLE",
TableHandleKeyword = "TABLE-HANDLE",
DatasetKeyword = "DATASET",
DatasetHandleKeyword = "DATASET-HANDLE",
}

export const afterThenStatements = new MyFancySet<string>([
Expand All @@ -127,6 +131,13 @@ export const definitionKeywords = new MyFancySet<string>([
SyntaxNodeType.DefKeyword,
]);

export const dataStructureKeywords = new MyFancySet<string>([
SyntaxNodeType.TableKeyword,
SyntaxNodeType.TableHandleKeyword,
SyntaxNodeType.DatasetKeyword,
SyntaxNodeType.DatasetHandleKeyword,
]);

export const bodyBlockKeywords = new MyFancySet<string>([
SyntaxNodeType.Body,
SyntaxNodeType.CaseBody,
Expand Down
14 changes: 14 additions & 0 deletions src/v2/formatters/functionParameter/FunctionParameterFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { CodeEdit } from "../../model/CodeEdit";
import { FullText } from "../../model/FullText";
import { AFormatter } from "../AFormatter";
import {
dataStructureKeywords,
definitionKeywords,
parameterTypes,
parentheses,
Expand All @@ -26,6 +27,7 @@ export class FunctionParameterFormatter
private alignParameterMode = 0;
private alignParameters = 0;
private typeTuningInCurrentParameter = false;
private parameterModeInCurrentParameter = false;

public constructor(configurationManager: IConfigurationManager) {
super(configurationManager);
Expand Down Expand Up @@ -173,6 +175,9 @@ export class FunctionParameterFormatter
this.typeTuningInCurrentParameter = node.children.some(
(child) => child.type === SyntaxNodeType.TypeTuning
);
this.parameterModeInCurrentParameter = node.children.some(
(child) => child.type === SyntaxNodeType.FunctionParameterMode
);

let resultString = "";
node.children.forEach((child) => {
Expand All @@ -189,6 +194,15 @@ export class FunctionParameterFormatter
): string {
let newString = "";
switch (node.type) {
case dataStructureKeywords.hasFancy(node.type, ""):
newString = FormatterHelper.getCurrentText(
node,
fullText
).trim();
if (this.parameterModeInCurrentParameter) {
newString = " " + newString;
}
break;
case SyntaxNodeType.FunctionParameterMode:
const text = FormatterHelper.getCurrentText(
node,
Expand Down

0 comments on commit 77786f4

Please sign in to comment.