use of com.perl5.lang.perl.util.PerlRunUtil in project Perl5-IDEA by Camelcade.
the class PerlRunUtil method getBinDirectories.
/**
* @return list of perl bin directories where script from library may be located
*/
@NotNull
public static Stream<VirtualFile> getBinDirectories(@Nullable Sdk sdk) {
if (sdk == null) {
return Stream.empty();
}
ApplicationManager.getApplication().assertReadAccessAllowed();
SdkTypeId sdkType = sdk.getSdkType();
if (!(sdkType instanceof PerlSdkType)) {
throw new IllegalArgumentException("Got non-perl sdk: " + sdk);
}
List<VirtualFile> files = new ArrayList<>(ContainerUtil.map(sdk.getRootProvider().getFiles(OrderRootType.CLASSES), PerlRunUtil::findLibsBin));
PerlHostData<?, ?> hostData = PerlHostData.notNullFrom(sdk);
File localSdkBinDir = hostData.getLocalPath(new File(StringUtil.notNullize(PerlProjectManager.getInterpreterPath(sdk))).getParentFile());
if (localSdkBinDir != null) {
files.add(VfsUtil.findFileByIoFile(localSdkBinDir, false));
}
PerlVersionManagerData.notNullFrom(sdk).getBinDirsPath().forEach(it -> ObjectUtils.doIfNotNull(hostData.getLocalPath(it), localPath -> files.add(VfsUtil.findFileByIoFile(localPath, false))));
return files.stream().filter(Objects::nonNull).distinct();
}
Aggregations