Skip to content

Commit

Permalink
Fix module-info parsing: consider "open module" notation
Browse files Browse the repository at this point in the history
  • Loading branch information
jjohannes committed Aug 22, 2023
1 parent 4f06080 commit 873a4b7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,14 @@ static String moduleName(String moduleInfoFileContent) {
List<String> tokens = Arrays.asList(cleanedLine.split("\\s+"));
if (moduleKeywordFound && !tokens.isEmpty()) {
return tokens.get(0);
} else if (tokens.indexOf("module") == 0) {
moduleKeywordFound = true;
}
if (tokens.size() > 1) {
return tokens.get(1);

int moduleKeywordIndex = tokens.indexOf("module");
if (moduleKeywordIndex == 0 || moduleKeywordIndex == 1) {
if (tokens.size() > moduleKeywordIndex) {
return tokens.get(moduleKeywordIndex + 1);
}
moduleKeywordFound = true;
}
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,20 @@ class ModuleInfoParseTest extends Specification {
expect:
nameFromFile == 'some.thing'
}

def "finds module name when open keyword is used"() {
given:
def nameFromFile = ModuleInfoParser.moduleName('''
open module /*module some.other*/ some.thing { /* module
odd comment*/ requires transitive foo.bar.la;
requires/* weird comment*/ static foo.bar.lo;
requires /*something to say*/foo.bar.li; /*
requires only.a.comment
*/
}
''')

expect:
nameFromFile == 'some.thing'
}
}

0 comments on commit 873a4b7

Please sign in to comment.