Search in sources :

Example 1 with PerlSdkType

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();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) CpanminusAdapter(com.perl5.lang.perl.adapters.CpanminusAdapter) PerlBundle(com.perl5.PerlBundle) VirtualFile(com.intellij.openapi.vfs.VirtualFile) PerlTerminalExecutionConsole(com.perl5.lang.perl.idea.execution.PerlTerminalExecutionConsole) ProcessAdapter(com.intellij.execution.process.ProcessAdapter) PerlSdkType(com.perl5.lang.perl.idea.sdk.PerlSdkType) ReadAction(com.intellij.openapi.application.ReadAction) PerlCommandLine(com.perl5.lang.perl.idea.execution.PerlCommandLine) Task(com.intellij.openapi.progress.Task) ConsoleViewContentType(com.intellij.execution.ui.ConsoleViewContentType) Semaphore(com.intellij.util.concurrency.Semaphore) Disposer(com.intellij.openapi.util.Disposer) Logger(com.intellij.openapi.diagnostic.Logger) PerlHostData(com.perl5.lang.perl.idea.sdk.host.PerlHostData) Notifications(com.intellij.notification.Notifications) ProgressManager(com.intellij.openapi.progress.ProgressManager) OrderRootType(com.intellij.openapi.roots.OrderRootType) NotificationType(com.intellij.notification.NotificationType) Notification(com.intellij.notification.Notification) Nullable(org.jetbrains.annotations.Nullable) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) Contract(org.jetbrains.annotations.Contract) ProcessListener(com.intellij.execution.process.ProcessListener) Stream(java.util.stream.Stream) RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) ApplicationManager(com.intellij.openapi.application.ApplicationManager) ProcessEvent(com.intellij.execution.process.ProcessEvent) NotNull(org.jetbrains.annotations.NotNull) PerlProjectManager(com.perl5.lang.perl.idea.project.PerlProjectManager) java.util(java.util) WriteAction(com.intellij.openapi.application.WriteAction) PerlVersionManagerData(com.perl5.lang.perl.idea.sdk.versionManager.PerlVersionManagerData) RunContentManager(com.intellij.execution.ui.RunContentManager) ExecutionException(com.intellij.execution.ExecutionException) DaemonCodeAnalyzer(com.intellij.codeInsight.daemon.DaemonCodeAnalyzer) ContainerUtil(com.intellij.util.containers.ContainerUtil) PerlOsHandler(com.perl5.lang.perl.idea.sdk.host.os.PerlOsHandler) PerlRunConsole(com.perl5.lang.perl.idea.run.PerlRunConsole) ProjectRootManagerEx(com.intellij.openapi.roots.ex.ProjectRootManagerEx) PerlIcons(com.perl5.PerlIcons) Project(com.intellij.openapi.project.Project) DefaultRunExecutor(com.intellij.execution.executors.DefaultRunExecutor) SdkTypeId(com.intellij.openapi.projectRoots.SdkTypeId) StringUtil(com.intellij.openapi.util.text.StringUtil) Key(com.intellij.openapi.util.Key) AnAction(com.intellij.openapi.actionSystem.AnAction) Executor(com.intellij.execution.Executor) Disposable(com.intellij.openapi.Disposable) Sdk(com.intellij.openapi.projectRoots.Sdk) File(java.io.File) ProcessHandler(com.intellij.execution.process.ProcessHandler) TestOnly(org.jetbrains.annotations.TestOnly) CpanAdapter(com.perl5.lang.perl.adapters.CpanAdapter) DumbAwareAction(com.intellij.openapi.project.DumbAwareAction) PerlConsoleView(com.perl5.lang.perl.idea.sdk.host.PerlConsoleView) VfsUtil(com.intellij.openapi.vfs.VfsUtil) ObjectUtils(com.intellij.util.ObjectUtils) EmptyRunnable(com.intellij.openapi.util.EmptyRunnable) PerlSdkType(com.perl5.lang.perl.idea.sdk.PerlSdkType) SdkTypeId(com.intellij.openapi.projectRoots.SdkTypeId) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with PerlSdkType

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);
}
Also used : ProjectJdkImpl(com.intellij.openapi.projectRoots.impl.ProjectJdkImpl) PerlSdkType(com.perl5.lang.perl.idea.sdk.PerlSdkType)

Aggregations

DaemonCodeAnalyzer (com.intellij.codeInsight.daemon.DaemonCodeAnalyzer)1 ExecutionException (com.intellij.execution.ExecutionException)1 Executor (com.intellij.execution.Executor)1 DefaultRunExecutor (com.intellij.execution.executors.DefaultRunExecutor)1 ProcessAdapter (com.intellij.execution.process.ProcessAdapter)1 ProcessEvent (com.intellij.execution.process.ProcessEvent)1 ProcessHandler (com.intellij.execution.process.ProcessHandler)1 ProcessListener (com.intellij.execution.process.ProcessListener)1 ConsoleViewContentType (com.intellij.execution.ui.ConsoleViewContentType)1 RunContentDescriptor (com.intellij.execution.ui.RunContentDescriptor)1 RunContentManager (com.intellij.execution.ui.RunContentManager)1 Notification (com.intellij.notification.Notification)1 NotificationType (com.intellij.notification.NotificationType)1 Notifications (com.intellij.notification.Notifications)1 Disposable (com.intellij.openapi.Disposable)1 AnAction (com.intellij.openapi.actionSystem.AnAction)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 ApplicationManager (com.intellij.openapi.application.ApplicationManager)1 ReadAction (com.intellij.openapi.application.ReadAction)1 WriteAction (com.intellij.openapi.application.WriteAction)1