this.workspacePath = workspacePath;
}
@Override
public Collection<FileAnnotation> parse(final File file, final String moduleName) throws InvocationTargetException {
SaxSetup sax = new SaxSetup();
FileInputStream inputStream = null;
try {
for (AbstractDryParser parser : parsers) {
inputStream = new FileInputStream(file);
if (parser.accepts(inputStream)) {
IOUtils.closeQuietly(inputStream);
inputStream = new FileInputStream(file);
Collection<DuplicateCode> result = parser.parse(inputStream, moduleName);
createLinkNames(result);
Set<FileAnnotation> warnings = Sets.newHashSet();
warnings.addAll(result);
ContextHashCode hashCode = new ContextHashCode();
for (FileAnnotation duplication : warnings) {
String fullPath = getFullPath(duplication);
long value = hashCode.create(fullPath,
duplication.getPrimaryLineNumber(), defaultEncoding);
duplication.setContextHashCode(value * 31 + (((DuplicateCode)duplication).getNumberOfLines()));
}
return warnings;
}
}
throw new IOException("No parser found for duplicated code results file " + file.getAbsolutePath());
}
catch (IOException exception) {
throw new InvocationTargetException(exception);
}
finally {
sax.cleanup();
IOUtils.closeQuietly(inputStream);
}
}