use of com.buschmais.jqassistant.plugin.java.impl.scanner.visitor.ClassVisitor in project jqa-java-plugin by buschmais.
the class ClassFileScannerPlugin method scan.
@Override
public ClassFileDescriptor scan(FileResource file, String path, Scope scope, final Scanner scanner) throws IOException {
final FileDescriptor fileDescriptor = scanner.getContext().getCurrentDescriptor();
VisitorHelper visitorHelper = new VisitorHelper(scanner.getContext(), classModelConfiguration);
final ClassVisitor visitor = new ClassVisitor(fileDescriptor, visitorHelper);
ClassFileDescriptor classFileDescriptor;
try (InputStream stream = file.createStream()) {
classFileDescriptor = MD5DigestDelegate.getInstance().digest(stream, new MD5DigestDelegate.DigestOperation<ClassFileDescriptor>() {
@Override
public ClassFileDescriptor execute(InputStream inputStream) throws IOException {
new ClassReader(inputStream).accept(visitor, 0);
return visitor.getTypeDescriptor();
}
});
classFileDescriptor.setValid(true);
} catch (RuntimeException e) {
LOGGER.warn("Cannot scan class '" + path + "'.", e);
classFileDescriptor = visitor.getTypeDescriptor();
if (classFileDescriptor == null) {
classFileDescriptor = scanner.getContext().getStore().addDescriptorType(fileDescriptor, ClassFileDescriptor.class);
}
classFileDescriptor.setValid(false);
}
return classFileDescriptor;
}
Aggregations