Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

209 Property Setter and Getter method do not indent correctly #244

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions resources/functionalTests/property/5blocks/input.p
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* formatterSettingsOverride */
/* { "AblFormatter.blockFormatting": true,
"AblFormatter.propertyFormatting": true }*/
class AClass:
define private property m_Total as integer no-undo
get.
set.

define PUBLIC PROPERTY propertyWidthGetterAndSetter AS SomeClass NO-UNDO
GET:
RETURN ?.
END GET.
SET(INPUT pValue AS SomeClass):
DO:
pValue:CallMethod().
END.
END SET.

define PRIVATE VARIABLE propertyWidthGetter_ AS SomeClass NO-UNDO.
define PROTECTED PROPERTY propertyWidthGetter AS SomeClass NO-UNDO
GET():

RETURN propertyWidthGetter_.
END GET.
end class.
25 changes: 25 additions & 0 deletions resources/functionalTests/property/5blocks/target.p
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* formatterSettingsOverride */
/* { "AblFormatter.blockFormatting": true,
"AblFormatter.propertyFormatting": true }*/
class AClass:
define private property m_Total as integer no-undo
get.
set.

define PUBLIC PROPERTY propertyWidthGetterAndSetter AS SomeClass NO-UNDO
GET:
RETURN ?.
END GET.
SET(INPUT pValue AS SomeClass):
DO:
pValue:CallMethod().
END.
END SET.

define PRIVATE VARIABLE propertyWidthGetter_ AS SomeClass NO-UNDO.
define PROTECTED PROPERTY propertyWidthGetter AS SomeClass NO-UNDO
GET():

RETURN propertyWidthGetter_.
END GET.
end class.
22 changes: 22 additions & 0 deletions resources/functionalTests/property/5blocks2/input.p
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* formatterSettingsOverride */
/* { "AblFormatter.blockFormatting": true,
"AblFormatter.propertyFormatting": true }*/

class myRequest implements IWebRequest:
define public property Version as character no-undo
get():
return web-context:get-cgi-value("ENV", "SERVER_PROTOCOL").
end get.
set(cProp as char):
undo, throw new AppError(GetReadOnlyMessage(),?).
end set.

define public property ContentType as character no-undo
get():
return web-context:get-cgi-value("ENV", "CONTENT_TYPE").
end get.
set(cProp as char):
undo, throw new AppError(GetReadOnlyMessage(),?).
end set.

end class.
22 changes: 22 additions & 0 deletions resources/functionalTests/property/5blocks2/target.p
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* formatterSettingsOverride */
/* { "AblFormatter.blockFormatting": true,
"AblFormatter.propertyFormatting": true }*/

class myRequest implements IWebRequest:
define public property Version as character no-undo
get():
return web-context:get-cgi-value("ENV", "SERVER_PROTOCOL").
end get.
set(cProp as char):
undo, throw new AppError(GetReadOnlyMessage(),?).
end set.

define public property ContentType as character no-undo
get():
return web-context:get-cgi-value("ENV", "CONTENT_TYPE").
end get.
set(cProp as char):
undo, throw new AppError(GetReadOnlyMessage(),?).
end set.

end class.
19 changes: 19 additions & 0 deletions resources/functionalTests/property/5blocks3/input.p
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* formatterSettingsOverride */
/* { "AblFormatter.blockFormatting": true,
"AblFormatter.propertyFormatting": true }*/

class Writer implements IWebRequest:
define static public property Registry as BuilderRegistry no-undo
get():
define variable oRegistry as BuilderRegistry no-undo.
do:
do transaction:
fun(33).
end.
AuthenticationRequestWriterBuilder:InitializeRegistry(oRegistry).
end.
return AuthenticationRequestWriterBuilder:Registry.
end get.
private set.

end class.
19 changes: 19 additions & 0 deletions resources/functionalTests/property/5blocks3/target.p
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* formatterSettingsOverride */
/* { "AblFormatter.blockFormatting": true,
"AblFormatter.propertyFormatting": true }*/

class Writer implements IWebRequest:
define static public property Registry as BuilderRegistry no-undo
get():
define variable oRegistry as BuilderRegistry no-undo.
do:
do transaction:
fun(33).
end.
AuthenticationRequestWriterBuilder:InitializeRegistry(oRegistry).
end.
return AuthenticationRequestWriterBuilder:Registry.
end get.
private set.

end class.
19 changes: 16 additions & 3 deletions src/v2/formatters/property/PropertyFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import { IFormatter } from "../../formatterFramework/IFormatter";
import { CodeEdit } from "../../model/CodeEdit";
import { FullText } from "../../model/FullText";
import { AFormatter } from "../AFormatter";
import { SyntaxNodeType } from "../../../model/SyntaxNodeType";
import {
definitionKeywords,
SyntaxNodeType,
} from "../../../model/SyntaxNodeType";
import { FormatterHelper } from "../../formatterFramework/FormatterHelper";
import { PropertySettings } from "./PropertySettings";
import { IConfigurationManager } from "../../../utils/IConfigurationManager";
Expand Down Expand Up @@ -72,15 +75,25 @@ export class PropertyFormatter extends AFormatter implements IFormatter {
let newString = "";

switch (node.type) {
case SyntaxNodeType.DefineKeyword:
case definitionKeywords.hasFancy(node.type, ""):
newString = FormatterHelper.getCurrentText(node, fullText);
break;
case SyntaxNodeType.Getter:
case SyntaxNodeType.Setter:
const firstLineWhitespace =
FormatterHelper.getActualStatementIndentation(
node,
fullText
);
const statement = FormatterHelper.addIndentation(
FormatterHelper.getCurrentText(node, fullText).trim(),
-firstLineWhitespace + this.settings.tabSize(),
fullText.eolDelimiter
);
newString =
fullText.eolDelimiter +
" ".repeat(this.startColumn + this.settings.tabSize()) +
FormatterHelper.getCurrentText(node, fullText).trim();
statement;
break;
case SyntaxNodeType.Error:
newString = FormatterHelper.getCurrentText(node, fullText);
Expand Down