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

Auto upper standard data types #37

Merged
merged 1 commit into from
Jul 12, 2020

Conversation

kdorsel
Copy link
Contributor

@kdorsel kdorsel commented Jul 1, 2020

Twincat will automatically capitalize types and keywords. This will do that for data types.

@Roald87
Copy link
Owner

Roald87 commented Jul 2, 2020

Thanks for the PR!

Doesn't TwinCAT automatically do this already? At least in my editor it already does this. See https://infosys.beckhoff.com/content/1033/tc3_plc_intro/9007201787974027.html?id=5455052691128461949 option Convert keywords to uppercase automatically (AutoFormat)

@kdorsel
Copy link
Contributor Author

kdorsel commented Jul 6, 2020

Yes, 99% of the time keywords are uppercase automatically. There are a few instances in which they do not though.

For example is you type up the variable type and then click into the body editor without changing lines in the variable definition it will stay lowercase. If the file is then saved it will never be uppercased automatically.

I understand it's rare, but I still think it's something that we should make sure of.

Copy link
Owner

@Roald87 Roald87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you

  1. Also make it pass the following tests:
[InlineData(
    "METHOD Read    : pointer to array[1..nNumber] of int    ",
    "METHOD Read : POINTER TO ARRAY[1..nNumber] OF INT"
)]
[InlineData(
    "METHOD Read    : String(nInt)    ",
    "METHOD Read : STRING(nInt)"
)] 
  1. Merge the current merge conflict?

@kdorsel
Copy link
Contributor Author

kdorsel commented Jul 10, 2020

Complete rewrite of this upper function. Now includes variable definition as well as objects and uses a static class for better performance.

Took the keyword list from here and added missing data types.
https://infosys.beckhoff.com/english.php?content=../content/1033/tc3_plc_intro/2529971595.html&id=

@@ -179,7 +179,7 @@ private void AssertEquals(TcDeclaration expected, TcDeclaration actual)
"deviceDown AT %QX0.2 : BOOL ; ",
"deviceDown AT %QX0.2 : BOOL;"
)]
[InlineData("devSpeed:TIME:=T#10ms;", "devSpeed : TIME := T#10ms;")]
[InlineData("devSpeed:TIME:=T#10ms;", "devSpeed : TIME := T#10MS;")]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very unfortunate that TwinCAT auto capitalize, converts the time units to upper case. The one with small case units is much better to read, because of the size difference of numbers and small case letters in most fonts. Since TwinCAT does this, I guess we'll stick with this.

Roald87 added a commit that referenced this pull request Jul 12, 2020
@Roald87 Roald87 merged commit 4f271de into Roald87:master Jul 12, 2020
@kdorsel kdorsel deleted the capitalize-data-types branch July 13, 2020 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants