use of com.perl5.lang.perl.idea.sdk.PerlSdkType 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();
}
use of com.perl5.lang.perl.idea.sdk.PerlSdkType in project Perl5-IDEA by Camelcade.
the class Perl5SdkConfigurable method addSdk.
private void addSdk(@NotNull String home) {
PerlSdkType sdkType = PerlSdkType.INSTANCE;
String newSdkName = SdkConfigurationUtil.createUniqueSdkName(sdkType, home, Arrays.asList(PerlSdkTable.getInstance().getAllJdks()));
final ProjectJdkImpl newSdk = new ProjectJdkImpl(newSdkName, sdkType);
newSdk.setHomePath(home);
sdkType.setupSdkPaths(newSdk);
// should we check for version string?
myChange = true;
PerlSdkTable.getInstance().addJdk(newSdk);
}
Aggregations