public BuildConfigModel buildModel(String configFilePath) {
File configFile = new File(configFilePath);
String rootPath = configFile.getParent();
String configFileName = configFile.getName();
BuildConfigModel model = new BuildConfigModel(configFilePath);
List configFiles = new ArrayList();
List importedFiles = new ArrayList();
List badEntries = null;
try {
LstBuildConfigFileParser configParser = new LstBuildConfigFileParser(configFilePath);
configParser.parseConfigFile(new File(configFilePath));
configFiles = configParser.getFiles();
importedFiles = configParser.getImportedFiles();
badEntries = configParser.getProblemEntries();
} catch (ConfigParser.ParseException pe) {
// String filePath = "<unknown>";
// if (pe.getFile() != null) filePath = pe.getFile().getAbsolutePath();
IMessage message = new Message(
pe.getMessage(),
IMessage.ERROR,
pe,
new SourceLocation(pe.getFile(), pe.getLine(), 1));
Ajde.getDefault().getMessageHandler().handleMessage(message);
}
List relativePaths = relativizeFilePaths(configFiles, rootPath);
BuildConfigNode root = new BuildConfigNode(configFileName, BuildConfigNode.Kind.FILE_LST, rootPath);
buildDirTree(root, rootPath, importedFiles, configFileName);
model.setRoot(root);
addFilesToDirTree(model, relativePaths, badEntries);
pruneEmptyDirs(root);
sortModel(model.getRoot(), ALPHABETICAL_COMPARATOR);
//addImportedFilesToDirTree(model, importedFiles);
addProblemEntries(root, badEntries);
return model;
}