Skip to content

Commit

Permalink
allow whitespace in annotation on module declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
xzel23 committed Nov 11, 2024
1 parent a911923 commit 4434636
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/main/groovy/org/beryx/jlink/util/Util.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class Util {
private static final String IMPORT_DECLARATION = 'import' + IGNORE + '(static' + IGNORE + ')?' + QUALIFIED_NAME + '(\\.\\*' + ')?' + IGNORE + ';'
private static final String IMPORT_DECLARATIONS = '(' + IMPORT_DECLARATION + IGNORE + ')*'

private static final String ANNOTATION = '(@' + QUALIFIED_NAME + '((' + WS + ')*(\\([^)]*\\)))?)'
private static final String ANNOTATION = '(@' + IGNORE + QUALIFIED_NAME + '((' + IGNORE + ')(\\([^)]*\\)))?)'
private static final String MODULE_ANNOTATIONS = '(' + ANNOTATION + IGNORE + ')*'

private static final String MODULE_DECLARATION = '(?s)' + IGNORE + IMPORT_DECLARATIONS + MODULE_ANNOTATIONS + '(open' + IGNORE + ')?' + 'module' + IGNORE + '(?<MODULE>' + QUALIFIED_NAME + ').*?'
Expand Down
20 changes: 11 additions & 9 deletions src/test/groovy/org/beryx/jlink/UtilSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,17 @@ class UtilSpec extends Specification {
Util.getModuleNameFrom(text) == moduleName

where:
text | moduleName
'module a.b.c\n{' | 'a.b.c'
'open module a.b.c{}' | 'a.b.c'
' \t open\t \tmodule \ta.b.c\t { ' | 'a.b.c'
'/*my module*/\nmodule /*---*/ a.b.c // declaration\n{\n exports a.b.c;\n}' | 'a.b.c'
'import x.y.Z;//comment\nimport x.y.W;\nmodule /*---*/ a.b.c' | 'a.b.c'
'import x.y.z.*;\nimport x.y/*WW*/./*ZZ*/w.*;\nmodule //x.y.z\n/*-->*/a.b.c' | 'a.b.c'
'import x.y.z.*;\n@Annotation\nmodule //x.y.z\n/*-->*/a.b.c' | 'a.b.c'
'import x.y.z.*;\n@Annotation("text")\nmodule //x.y.z\n/*-->*/a.b.c' | 'a.b.c'
text | moduleName
'module a.b.c\n{' | 'a.b.c'
'open module a.b.c{}' | 'a.b.c'
' \t open\t \tmodule \ta.b.c\t { ' | 'a.b.c'
'/*my module*/\nmodule /*---*/ a.b.c // declaration\n{\n exports a.b.c;\n}' | 'a.b.c'
'import x.y.Z;//comment\nimport x.y.W;\nmodule /*---*/ a.b.c' | 'a.b.c'
'import x.y.z.*;\nimport x.y/*WW*/./*ZZ*/w.*;\nmodule //x.y.z\n/*-->*/a.b.c' | 'a.b.c'
'import x.y.z.*;\n@Annotation\nmodule //x.y.z\n/*-->*/a.b.c' | 'a.b.c'
'import x.y.z.*;\n@Annotation("text")\nmodule //x.y.z\n/*-->*/a.b.c' | 'a.b.c'
'import x.y.z.*;\n@ Annotation("text")\nmodule //x.y.z\n/*-->*/a.b.c' | 'a.b.c'
'import x.y.z.*;\n@Annotation\n(\n var = "text"\n)\nmodule //x.y.z\n/*-->*/a.b.c' | 'a.b.c'
}

@Unroll
Expand Down

0 comments on commit 4434636

Please sign in to comment.