use of de.be4.classicalb.core.parser.exceptions.VisitorIOException in project probparsers by bendisposto.
the class ReferencedMachines method determineRootDirectory.
private void determineRootDirectory(final TPragmaIdOrString packageTerminal, final Node node) {
final String text = packageTerminal.getText();
if ((text.startsWith("\"") && text.endsWith("\""))) {
this.packageName = text.replaceAll("\"", "");
} else {
this.packageName = text;
}
final String[] packageNameArray = determinePackage(packageTerminal, node);
File dir;
try {
dir = mainFile.getCanonicalFile();
} catch (IOException e) {
throw new VisitorIOException(e);
}
for (int i = packageNameArray.length - 1; i >= 0; i--) {
final String name1 = packageNameArray[i];
dir = dir.getParentFile();
final String name2 = dir.getName();
if (!name1.equals(name2)) {
throw new VisitorException(new CheckException(String.format("Package declaration '%s' does not match the folder structure: %s vs %s", this.packageName, name1, name2), node));
}
}
rootDirectory = dir.getParentFile();
}
Aggregations