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

Fix final and abstract access modifiers #34

Merged
merged 5 commits into from
Jul 7, 2020
Merged
Changes from 1 commit
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
21 changes: 18 additions & 3 deletions src/TcBlack/ObjectDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ private TcObject TokenizeFunctionBlock()

List<string> interfaces = new List<string>();
List<string> parents = new List<string>();
string accessModifier = "";
bool implements = false;
bool extends = false;
foreach (string part in splitDefinition)
Expand All @@ -123,12 +124,26 @@ private TcObject TokenizeFunctionBlock()
extends = true;
implements = false;
}
else if (part.ToLower() == "abstract" || part.ToLower() == "final")
{
accessModifier = part;
}
}
string name;
if (accessModifier.Length != 0)
{
// Access modifier exists and name is pushed back one
name = splitDefinition[2];
}
else
{
name = splitDefinition[1];
}

return new TcObject(
objectType: "FUNCTION_BLOCK",
accessModifier: "",
name: splitDefinition[1],
accessModifier: accessModifier,
name: name,
dataType: "",
extends: string.Join(", ", parents.ToArray()),
implements: string.Join(", ", interfaces.ToArray())
Expand All @@ -138,7 +153,7 @@ private TcObject TokenizeFunctionBlock()
private TcObject TokenizeMethodOrProperty()
{
string entityType = @"\s*(FUNCTION|METHOD|PROPERTY)\s*";
string accessModifier = @"(PRIVATE|PUBLIC|PROTECTED|INTERNAL)?\s*";
string accessModifier = @"(PRIVATE|PUBLIC|PROTECTED|INTERNAL|FINAL|ABSTRACT)?\s*";
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
string accessModifier = @"(PRIVATE|PUBLIC|PROTECTED|INTERNAL|FINAL|ABSTRACT)?\s*";
string accessModifier =
@"(PRIVATE|PUBLIC|PROTECTED|INTERNAL|FINAL|ABSTRACT)?\s*";

I'm trying to also maintain the 88 line length limit in the code itself. See for more info https://github.com/Roald87/TcBlack/blob/master/CONTRIBUTING.md#use-a-consistent-coding-style

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, is there a C# Black that can be added to the project?

Copy link
Owner

Choose a reason for hiding this comment

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

I haven't found a free one unfortunately. There is https://www.jetbrains.com/resharper/, but you have to pay for that one.

string name = @"(\w+)\s*:?";
string dataType = @"\s*(.*[^\s+;])?";

Expand Down