use of de.be4.classicalb.core.parser.node.AFileMachineReference in project probparsers by bendisposto.
the class ReferencedMachines method caseAMachineReference.
/**
* INCLUDES, EXTENDS, IMPORTS
*/
@Override
public void caseAMachineReference(AMachineReference node) {
String name = getIdentifier(node.getMachineName());
if (node.parent() instanceof AFileMachineReference) {
final AFileMachineReference fileNode = (AFileMachineReference) node.parent();
String file = fileNode.getFile().getText().replaceAll("\"", "");
MachineReference ref;
try {
ref = new MachineReference(name, node, file);
referncesTable.put(name, ref);
} catch (CheckException e) {
throw new VisitorException(e);
}
} else {
MachineReference machineReference = new MachineReference(name, node);
if (this.filePathTable.containsKey(name)) {
machineReference.setDirectoryPath(filePathTable.get(name));
}
referncesTable.put(name, machineReference);
}
}
use of de.be4.classicalb.core.parser.node.AFileMachineReference in project probparsers by bendisposto.
the class RulesReferencesFinder method registerMachineNames.
private void registerMachineNames(final PMachineReference machineReference) {
if (machineReference instanceof AFileMachineReference) {
registerMachineByFilePragma((AFileMachineReference) machineReference);
} else {
AMachineReference mchRef = (AMachineReference) machineReference;
registerMachineReference(mchRef);
}
}
use of de.be4.classicalb.core.parser.node.AFileMachineReference in project probparsers by bendisposto.
the class RulesReferencesFinder method registerMachineByFilePragma.
private void registerMachineByFilePragma(AFileMachineReference fileNode) {
final String filePath = fileNode.getFile().getText().replaceAll("\"", "");
final AMachineReference ref = (AMachineReference) fileNode.getReference();
final String name = ref.getMachineName().get(0).getText();
File file = null;
File tempFile = new File(filePath);
if (tempFile.exists() && tempFile.isAbsolute() && !tempFile.isDirectory()) {
file = tempFile;
} else {
tempFile = new File(mainFile.getParentFile(), filePath);
if (tempFile.exists() && !tempFile.isDirectory()) {
file = tempFile;
}
}
if (tempFile.isDirectory()) {
errorList.add(new CheckException(String.format("File '%s' is a directory.", filePath), fileNode.getFile()));
return;
} else if (file == null) {
errorList.add(new CheckException(String.format("File '%s' does not exist.", filePath), fileNode.getFile()));
return;
} else {
RulesMachineReference rulesMachineReference = new RulesMachineReference(file, name, fileNode.getReference());
referncesTable.put(name, rulesMachineReference);
return;
}
}
Aggregations