Search in sources :

Example 1 with DirectoryDescriptor

use of com.buschmais.jqassistant.plugin.common.api.model.DirectoryDescriptor in project jqa-java-plugin by buschmais.

the class PackageDirectoryScannerPlugin method scan.

@Override
public PackageDescriptor scan(DirectoryResource item, String path, Scope scope, Scanner scanner) throws IOException {
    ScannerContext context = scanner.getContext();
    DirectoryDescriptor directoryDescriptor = context.getCurrentDescriptor();
    PackageDescriptor descriptor = context.getStore().addDescriptorType(directoryDescriptor, PackageDescriptor.class);
    String packageName = path.substring(1).replaceAll("/", ".");
    String name;
    int separatorIndex = packageName.lastIndexOf('.');
    if (separatorIndex != -1) {
        name = packageName.substring(separatorIndex + 1);
    } else {
        name = packageName;
    }
    descriptor.setName(name);
    descriptor.setFullQualifiedName(packageName);
    return descriptor;
}
Also used : DirectoryDescriptor(com.buschmais.jqassistant.plugin.common.api.model.DirectoryDescriptor) ScannerContext(com.buschmais.jqassistant.core.scanner.api.ScannerContext) PackageDescriptor(com.buschmais.jqassistant.plugin.java.api.model.PackageDescriptor)

Aggregations

ScannerContext (com.buschmais.jqassistant.core.scanner.api.ScannerContext)1 DirectoryDescriptor (com.buschmais.jqassistant.plugin.common.api.model.DirectoryDescriptor)1 PackageDescriptor (com.buschmais.jqassistant.plugin.java.api.model.PackageDescriptor)1