Remove path from grammar name when present

This commit is contained in:
Marco Hunsicker 2016-11-20 19:19:53 +01:00
parent d9af7896a7
commit 89e3f063c9
1 changed files with 8 additions and 1 deletions

View File

@ -234,7 +234,9 @@ class GrammarDependencies {
if ("tokenVocab".equals(key)) {
// make sure to have the name unquoted
String grammarName = value.replaceAll("\\A'|'\\Z", "");
String name = value.replaceAll("\\A'|'\\Z", "");
// the grammar name may be qualified, but we resolve the path anyway
String grammarName = stripPath(name);
String grammarPath = MojoUtils.findSourceSubdir(sourceDirectory,
grammarFile);
File depGrammarFile = resolve(grammarName, grammarPath);
@ -299,4 +301,9 @@ class GrammarDependencies {
return new HashMap<File, Map.Entry<byte[], Collection<String>>>();
}
private String stripPath(String str) {
return str.replaceAll("^.*[/\\\\]", "");
}
}