Skip to content

Capitalize method names properly #504

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

Merged
merged 2 commits into from
Jul 18, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ class SummaryReturnExampleTest : SummaryTestCaseGeneratorTest(
" 2nd return statement: return a;\n"

val methodName1 = "testCompareChars_NLessThan1"
val methodName2 = "testCompareChars_0OfCharactertoCharsiEqualsA" // TODO: a weird unclear naming
val methodName3 = "testCompareChars_0OfCharactertoCharsiEqualsB"
val methodName4 = "testCompareChars_0OfCharactertoCharsiNotEqualsB" // TODO: si -> is
val methodName2 = "testCompareChars_0OfCharacterToCharsIEqualsA" // TODO: a weird unclear naming
val methodName3 = "testCompareChars_0OfCharacterToCharsIEqualsB"
val methodName4 = "testCompareChars_0OfCharacterToCharsINotEqualsB"

val displayName1 = "n < 1 : True -> return ' '"
val displayName2 = "Character.toChars(i)[0] == a : True -> return b"
Expand Down Expand Up @@ -196,9 +196,9 @@ class SummaryReturnExampleTest : SummaryTestCaseGeneratorTest(
" returns from: return a;"

val methodName1 = "testInnerVoidCompareChars_NLessThan1"
val methodName2 = "testInnerVoidCompareChars_0OfCharactertoCharsiEqualsA" // TODO: a weird unclear naming
val methodName3 = "testInnerVoidCompareChars_0OfCharactertoCharsiNotEqualsB"
val methodName4 = "testInnerVoidCompareChars_0OfCharactertoCharsiEqualsB" // TODO: si -> is
val methodName2 = "testInnerVoidCompareChars_0OfCharacterToCharsIEqualsA" // TODO: a weird unclear naming
val methodName3 = "testInnerVoidCompareChars_0OfCharacterToCharsINotEqualsB"
val methodName4 = "testInnerVoidCompareChars_0OfCharacterToCharsIEqualsB"

val displayName1 = "n < 1 : True -> return ' '"
val displayName2 = "Character.toChars(i)[0] == a : True -> return b"
Expand Down Expand Up @@ -270,9 +270,9 @@ class SummaryReturnExampleTest : SummaryTestCaseGeneratorTest(
"Test afterwards returns from: return compareChars(a, b, n);\n"

val methodName1 = "testInnerReturnCompareChars_NLessThan1"
val methodName2 = "testInnerReturnCompareChars_0OfCharactertoCharsiEqualsA" // TODO: a weird unclear naming
val methodName3 = "testInnerReturnCompareChars_0OfCharactertoCharsiNotEqualsB"
val methodName4 = "testInnerReturnCompareChars_0OfCharactertoCharsiEqualsB" // TODO: si -> is
val methodName2 = "testInnerReturnCompareChars_0OfCharacterToCharsIEqualsA" // TODO: a weird unclear naming
val methodName3 = "testInnerReturnCompareChars_0OfCharacterToCharsINotEqualsB"
val methodName4 = "testInnerReturnCompareChars_0OfCharacterToCharsIEqualsB"

val displayName1 = "n < 1 : True -> return ' '"
val displayName2 = "Character.toChars(i)[0] == a : True -> return b"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,13 @@ class NodeConvertor {
}

/**
* Filters out all of the symbols that cannot be used in a function name and capitalizes String
* Capitalizes method name.
*
* It splits the text by delimiters, capitalizes each part, removes special characters and concatenates result.
*/
private fun postProcessName(name: String) = name.filter { isLegitSymbolForFunctionName(it) }.capitalize()
private fun postProcessName(name: String) =
name.split(".", "(", ")", ",")
.joinToString("") { it -> it.capitalize().filter { isLegitSymbolForFunctionName(it) } }

/**
* Converts Javaparser BinaryOperator and all of its children into a String
Expand Down