/**
* Gets or creates a CompilationResult for the given JavaScript program.
*/
public StandardCompilationResult getCompilation(TreeLogger logger,
File resultFile) throws UnableToCompleteException {
PermutationResult permutationResult;
try {
permutationResult = Util.readFileAsObject(resultFile,
PermutationResult.class);
} catch (ClassNotFoundException e) {
logger.log(TreeLogger.ERROR, "Unable to instantiate PermutationResult", e);
throw new UnableToCompleteException();
}
if (permutationResult == null) {
logger.log(TreeLogger.ERROR, "Unable to read PermutationResult");
throw new UnableToCompleteException();
}
String strongName = Util.computeStrongName(Util.getBytes(permutationResult.getJs()));
StandardCompilationResult result = resultsByStrongName.get(strongName);
if (result == null) {
result = new StandardCompilationResult(permutationResult.getJs(),
strongName, resultFile);
resultsByStrongName.put(result.getStrongName(), result);
artifacts.add(result);
}
return result;