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

Enum values with underscores sometimes don't convert to native cross references #1542

Open
limingchina opened this issue Jul 29, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@limingchina
Copy link
Contributor

limingchina commented Jul 29, 2023

When enum values with underscores in their names are used in comments as cross references, they are not converted correctly as native cross references. I've constructed a test case CommentsWithCrossReferenceOfEnumValue.lime.

After building the gluecodium project, run the following command in the project root folder:

./generate -input ../functional-tests/functional/input/lime/CommentsWithCrossReferenceOfEnumValue.lime -generators cpp,swift,dart -output test

One can also use the absolute path for the input lime file.

Check the generated files

    /**
     * Note:* [Error.INVALID_PARAMETER] error is generated.
     */

instead of the correct one

    /**
     * Note:* ::test::Error::INVALID_PARAMETER error is generated.
     */

TestClassEnumValueWithoutUnderScore.h always working.

/// Note:* [Error.INVALID_PARAMETER] error is generated.

instead of the correct one

/// Note:* [Error.invalidParameter] error is generated.

test_class_enum_value_without_under_score.dart always working.

@limingchina limingchina added the bug Something isn't working label Jul 31, 2023
@limingchina
Copy link
Contributor Author

limingchina commented Jul 31, 2023

The problem might be related to the library https://github.com/vsch/flexmark-java which is used in this project. Currently gluecodium is using 0.64.0 tag of that project. I've tried 0.64.8, which is the latest available. The result is the same.

I've added the following diff to print out some information during comment processing

diff --git a/gluecodium/src/main/java/com/here/gluecodium/generator/common/CommentsProcessor.kt b/gluecodium/src/main/java/com/here/gluecodium/generator/common/CommentsProcessor.kt
index 3ea6624d5..520a3aa7a 100644
--- a/gluecodium/src/main/java/com/here/gluecodium/generator/common/CommentsProcessor.kt
+++ b/gluecodium/src/main/java/com/here/gluecodium/generator/common/CommentsProcessor.kt
@@ -59,12 +59,16 @@ abstract class CommentsProcessor(
     ): String {
         val document = parser.parse(comment.trim())
         val path = limeFullName.split(".")
-
+        println("======== Begin process")
+        println(comment.trim())
         val linkRefHandler = VisitHandler(LinkRef::class.java) {
+            println( "Inside LinkRefHandler" )
+
             if (it.isDefined) return@VisitHandler

             val rawReference = it.reference.toString()
             val normalizedReference = normalizeReference(rawReference)
+            println( normalizedReference.toString() )
             for (i in path.size downTo 0) {
                 val child = (path.take(i) + normalizedReference).joinToString(".")
                 val element = limeToLanguage[child]
@@ -85,6 +89,7 @@ abstract class CommentsProcessor(
         NodeVisitor(linkRefHandler, codeBlockHandler, autoLinkHandler).visit(document)

         val renderedDocument = renderer.render(document)
+        println("====== End process\n")
         return postRenderDocument(renderedDocument).trim()
     }

When I run

./generate -input ../functional-tests/functional/input/lime/CommentsWithCrossReferenceOfEnumValue.lime -generators dart -output test

I've got the following result for method comments of the test class.

======== Begin process
Note:a [Error.INVALID_PARAMETER] error is generated.
Inside LinkRefHandler
Error.INVALID_PARAMETER
====== End process

======== Begin process
Note:* [Error.INVALID_PARAMETER] error is generated.
====== End process

======== Begin process
*Note: [Error.INVALID_PARAMETER] error is generated.
====== End process

======== Begin process
This is a test

*Note: [Error.INVALID_PARAMETER] is generated.
Inside LinkRefHandler
Error.INVALID_PARAMETER
====== End process

======== Begin process
This is a tes

*Note: [Error.INVALID_PARAMETER] is generated.
====== End process

======== Begin process
Test class for cross reference of enum values without under score.

Always working.
====== End process

======== Begin process
Note:a [Error.INTERNAL] error is generated.
Inside LinkRefHandler
Error.INTERNAL
====== End process

======== Begin process
*Note: [Error.INTERNAL] error is generated.
Inside LinkRefHandler
Error.INTERNAL
====== End process

======== Begin process
Note:* [Error.INTERNAL] error is generated.
Inside LinkRefHandler
Error.INTERNAL
====== End process

======== Begin process
This is a test

**Note:** [Error.INTERNAL] is generated.
Inside LinkRefHandler
Error.INTERNAL
====== End process

======== Begin process
This is a tes

**Note:** [Error.INTERNAL] is generated.
Inside LinkRefHandler
Error.INTERNAL
====== End process

One can notice for the 3 bad cases for INVALID_PARAMETER, the LinkRefHandler is not getting called at all.

@limingchina
Copy link
Contributor Author

The ticket would be left open until we get a fix from vsch/flexmark-java project. Then we can update the dependent version in the build.gradle file of this project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant