if(file == null)
throw new IllegalArgumentException("File can not be null");
// Create a puppet distro target and parse info from the file path
//
PuppetDistribution puppetDistro = PPTPFactory.eINSTANCE.createPuppetDistribution();
puppetDistro.setDescription("Puppet Distribution");
IPath path = Path.fromOSString(file.getAbsolutePath());
// NOTE: This is wrong, will always result in a version == "" as the version is
// part of the "puppet" directory, not the directory puppet-x.x.x/lib/puppet that is given to
// this function.
//
// String versionString = "";
// boolean nextIsVersion = false;
String[] segments = path.segments();
int sc = segments.length;
if(segments.length < 3 || !"puppet".equals(segments[sc - 1]) || !"lib".equals(segments[sc - 2]))
throw new IllegalArgumentException("path to .../puppet/lib is not correct");
final String distroName = segments[sc - 3];
if(!distroName.startsWith("puppet-"))
throw new IllegalArgumentException(
"The ../../ of the given directory must be named on the form: 'puppet-<version>'");
puppetDistro.setLabel("puppet");
// 7 is the first char after 'puppet-'
puppetDistro.setVersion(distroName.substring(7));
// Load functions
File parserDir = new File(file, "parser");
File functionsDir = new File(parserDir, "functions");
loadFunctions(puppetDistro, functionsDir);
// Load logger functions
for(Function f : loadLoggerFunctions(new File(file, "util/log.rb")))
puppetDistro.getFunctions().add(f);
// Load types
try {
File typesDir = new File(file, "type");
loadTypes(puppetDistro, typesDir);