public class CucumberJavaAllFeaturesInFolderRunConfigurationProducer extends CucumberJavaRunConfigurationProducer {
@Override
protected NullableComputable<String> getGlue(@NotNull final PsiElement element) {
final Set<String> glues = new HashSet<String>();
if (element instanceof PsiDirectory) {
final PsiDirectory dir = (PsiDirectory)element;
final CucumberJvmExtensionPoint[] extensions = Extensions.getExtensions(CucumberJvmExtensionPoint.EP_NAME);
return new NullableComputable<String>() {
@Nullable
@Override
public String compute() {
dir.accept(new PsiElementVisitor() {
@Override
public void visitFile(final PsiFile file) {
if (file instanceof GherkinFile) {
for (CucumberJvmExtensionPoint extension : extensions) {
extension.getGlues((GherkinFile)file, glues);
}
}
}
@Override
public void visitDirectory(PsiDirectory dir) {
for (PsiDirectory subDir : dir.getSubdirectories()) {
subDir.accept(this);
}
for (PsiFile file : dir.getFiles()) {
file.accept(this);
}
}
});